-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Add test_stopping event #2033
Add test_stopping event #2033
Conversation
locust/test/test_runners.py
Outdated
@@ -2224,11 +2230,15 @@ def my_task(self): | |||
with mock.patch("locust.rpc.rpc.Server", mocked_rpc()) as server: | |||
master = self.get_runner(user_classes=[TestUser]) | |||
|
|||
run_count = [0] | |||
run_count = [0, 0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a list here is more or less a hack for modifying values outside the function. I think this can be done in a more obvious way. even using a (properly named) global is preferable.
Looks good apart from my comment about the test. Can you add this event to this example? https://github.com/locustio/locust/blob/master/examples/test_data_management.py |
Will do |
@@ -60,11 +60,16 @@ def _(environment, **_kwargs): | |||
).json()["data"] | |||
|
|||
|
|||
@events.test_stop.add_listener | |||
@events.test_stopping.add_listener |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you update the comment at the start of the file too!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
like this?
# 6. Test run stopping
# 7. User stop
# 8. Test run stop
# 9. (not shown in this example) Locust quit
Adding test_stopping event - fired before stopping users.
It resolves #2031