question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No Locust class found!

See original GitHub issue

Describe the bug

Cannot run simple locust example

Expected behavior

The test should run - not sure what to expect since I’ve never seen a successful example

Actual behavior

I received the error:

[2020-04-09 14:52:59,330] sami/ERROR/locust.main: No Locust class found!

Steps to reproduce

  1. Install virtualenv && activate virtualenv venv --python python3 source venv/bin/activate

  2. Install locust

    pip3 install locust

  3. Create a locustfile called “locustfile.py” with content

import random
from locust import HttpLocust, task, between

class WebsiteUser(HttpLocust):
    wait_time = between(5, 9)

    @task(1)
    def index(self):
        self.client.get("/")
  1. Run it and see error:
> locust --host=https://google.com --locustfile locustfile.py
[2020-04-09 14:56:22,097] sami/ERROR/locust.main: No Locust class found!

Environment

  • OS: 18.04.4 LTS
  • Python version: Python 3.7.3
  • Locust version: locust 0.14.5
  • Locust command line that you ran: locust --host=https://google.com --locustfile locustfile.py
  • Locust file contents (anonymized if necessary):
import random
from locust import HttpLocust, task, between

class WebsiteUser(HttpLocust):
    wait_time = between(5, 9)

    @task(1)
    def index(self):
        self.client.get("/")

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
samiujancommented, Apr 9, 2020

yes you are right - thanks for the clarification

For anyone else reading this, please look at the following reference code that works for locust 0.14.5

from locust import HttpLocust, TaskSet, task, between

class UserBehaviour(TaskSet):
    @task(1)
    def index(self):
        self.client.get("/")


class WebsiteUser(HttpLocust):
    task_set = UserBehaviour
    wait_time = between(5, 9)
1reaction
heymancommented, Apr 17, 2020

Oh, nice catch! I have actually been wondering why so many people have referred to the /latest/ docs instead of /stable/ when we’ve set stable as default in Readthedocs. Now I have the answer 😃.

Fixed now!

Read more comments on GitHub >

github_iconTop Results From Across the Web

No Locust class found when running locustfile - Stack Overflow
The error message should actually have read "No Locust class with tasks found!". Just uncomment your task and it will be found correctly....
Read more >
ERROR/locust.main: No User class found! #1620 - GitHub
Not able to run even the basic example it just fails. $ sudo docker run -p 8089:8089 -v $PWD:/mnt/locust locustio/locust --version
Read more >
Writing a locustfile — Locust 0.6 documentation
A locust class represents one user (or a swarming locust if you will). ... a host attribute in the locust class, it will...
Read more >
locustio/locust - Gitter
locustio/locust ... although I was not running in distributed mode... this is the command that I executed: locust -f locustfile.py --no-web -c 1...
Read more >
Locust + Python Examples: Variables + Assertions - BlazeMeter
from locust import HttpUser, task class User(HttpUser): @task def mainPage(self): ... If we run the test we can see that it has no...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found