Skip to content

Commit

Permalink
fix a unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
myzhan committed Jan 9, 2017
1 parent 6b4889e commit f239a17
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions locust/test/testcases.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

def safe_repr(obj, short=False):
"""
Function from python 2.7's unittest.util. Used in methods that is copied
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
Expand Down Expand Up @@ -90,7 +90,8 @@ def basic_auth():

@app.route("/no_content_length")
def no_content_length():
r = send_file(BytesIO("This response does not have content-length in the header".encode('utf-8')), add_etags=False)
r = send_file(BytesIO("This response does not have content-length in the header".encode('utf-8')), mimetype="application/octet-stream",
add_etags=False)
return r

@app.errorhandler(404)
Expand Down Expand Up @@ -123,11 +124,11 @@ def setUp(self):
event = getattr(events, name)
if isinstance(event, events.EventHook):
self._event_handlers[event] = copy(event._handlers)

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.
Expand All @@ -137,7 +138,7 @@ def assertIn(self, member, container, msg=None):
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:
Expand All @@ -162,7 +163,7 @@ def assertGreaterEqual(self, a, b, msg=None):
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

0 comments on commit f239a17

Please sign in to comment.