Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove compatibility workarounds for Python 2.6 #770

Merged
merged 1 commit into from
Apr 28, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 2 additions & 52 deletions locust/test/testcases.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,6 @@
from locust.stats import global_stats


def safe_repr(obj, short=False):
"""
Function from python 2.7's unittest.util. Used in methods that is copied
from 2.7's unittest.TestCase to work in python 2.6.
"""
_MAX_LENGTH = 80
try:
result = repr(obj)
except Exception:
result = object.__repr__(obj)
if not short or len(result) < _MAX_LENGTH:
return result
return result[:_MAX_LENGTH] + ' [truncated]...'



app = Flask(__name__)

@app.route("/ultra_fast")
Expand Down Expand Up @@ -153,42 +137,8 @@ def setUp(self):
def tearDown(self):
for event, handlers in six.iteritems(self._event_handlers):
event._handlers = handlers

def assertIn(self, member, container, msg=None):
"""
Just like self.assertTrue(a in b), but with a nicer default message.
Implemented here to work with Python 2.6
"""
if member not in container:
standardMsg = '%s not found in %s' % (safe_repr(member),
safe_repr(container))
self.fail(self._formatMessage(msg, standardMsg))

def assertLess(self, a, b, msg=None):
"""Just like self.assertTrue(a < b), but with a nicer default message."""
if not a < b:
standardMsg = '%s not less than %s' % (safe_repr(a), safe_repr(b))
self.fail(self._formatMessage(msg, standardMsg))

def assertLessEqual(self, a, b, msg=None):
"""Just like self.assertTrue(a <= b), but with a nicer default message."""
if not a <= b:
standardMsg = '%s not less than or equal to %s' % (safe_repr(a), safe_repr(b))
self.fail(self._formatMessage(msg, standardMsg))

def assertGreater(self, a, b, msg=None):
"""Just like self.assertTrue(a > b), but with a nicer default message."""
if not a > b:
standardMsg = '%s not greater than %s' % (safe_repr(a), safe_repr(b))
self.fail(self._formatMessage(msg, standardMsg))

def assertGreaterEqual(self, a, b, msg=None):
"""Just like self.assertTrue(a >= b), but with a nicer default message."""
if not a >= b:
standardMsg = '%s not greater than or equal to %s' % (safe_repr(a), safe_repr(b))
self.fail(self._formatMessage(msg, standardMsg))




class WebserverTestCase(LocustTestCase):
"""
Test case class that sets up an HTTP server which can be used within the tests
Expand Down