Skip to content

Commit

Permalink
Merge pull request #1 from locustio/master
Browse files Browse the repository at this point in the history
Merge changes from locustio/locust
  • Loading branch information
ps-george authored May 17, 2018
2 parents 469edf8 + 391c4cf commit 8eb6aff
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 54 deletions.
4 changes: 2 additions & 2 deletions locust/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,10 +554,10 @@ def median_from_dict(total, count):
A global instance for holding the statistics. Should be removed eventually.
"""

def on_request_success(request_type, name, response_time, response_length):
def on_request_success(request_type, name, response_time, response_length, **kwargs):
global_stats.log_request(request_type, name, response_time, response_length)

def on_request_failure(request_type, name, response_time, exception):
def on_request_failure(request_type, name, response_time, exception, **kwargs):
global_stats.log_error(request_type, name, exception)

def on_report_to_master(client_id, data):
Expand Down
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

0 comments on commit 8eb6aff

Please sign in to comment.