Skip to content

Commit

Permalink
Merge pull request #2175 from alterhu2020/master
Browse files Browse the repository at this point in the history
fix: when run from web with `-f a_file_folder/` caused page title is None as  `locustfile` argument is None
  • Loading branch information
cyberw authored Sep 11, 2022
2 parents 86dbfce + e95d606 commit ea7c81c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions locust/test/test_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,9 @@ def t(self):
self.assertEqual(self.environment.host, "https://localhost")
self.assertListEqual(["User1", "User2"], response.json()["user_classes"])

self.assertIsNotNone(self.environment.locustfile, 'verify locustfile is not empty')
self.assertEqual(self.environment.locustfile, "User1,User2", "Verify locustfile variable used in web ui title")

# stop
gevent.sleep(1)
response = requests.get("http://127.0.0.1:%i/stop" % self.web_port)
Expand Down
3 changes: 3 additions & 0 deletions locust/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,9 @@ def _update_shape_class(self, shape_class_name):

def _update_user_classes(self, user_classes):
self.environment.user_classes = list(user_classes.values())
# populate the locustfile which used in web ui title only
if self.environment.locustfile is None:
self.environment.locustfile = ",".join(self.environment.user_classes_by_name.keys())

# Validating UserClasses
self.environment._remove_user_classes_with_weight_zero()
Expand Down

0 comments on commit ea7c81c

Please sign in to comment.