Skip to content

Commit

Permalink
--tags filter issue(locustio#2849) fix
Browse files Browse the repository at this point in the history
  • Loading branch information
vijay59122 committed Oct 28, 2024
1 parent ab5faf3 commit cea77ab
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions locust/user/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,13 +472,15 @@ class DefaultTaskSet(TaskSet):

def get_next_task(self):
if not self.user.tasks:
warning_message = "Use the @task decorator or set the 'tasks' attribute of the User (or mark it as abstract = True if you only intend to subclass it)"
if getattr(self.user, "task", None):
extra_message = ", but you have set a 'task' attribute on your class - maybe you meant to set 'tasks'?"
extra_message = f", but you have set a 'task' attribute on your class - maybe you meant to set 'tasks'?"
raise Exception(
f"No tasks defined on {self.user.__class__.__name__}{extra_message}{warning_message}"
)
else:
extra_message = "."
raise Exception(
f"No tasks defined on {self.user.__class__.__name__}{extra_message} Use the @task decorator or set the 'tasks' attribute of the User (or mark it as abstract = True if you only intend to subclass it)"
)
logger.warning(f"No tasks defined on {self.user.__class__.__name__}. {warning_message}")
raise StopUser
return random.choice(self.user.tasks)

def execute_task(self, task):
Expand Down

0 comments on commit cea77ab

Please sign in to comment.