1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Using locust with pytest

Discussão em 'Python' iniciado por Stack, Setembro 9, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to run locust using pytest. I have created this python file but it is not showing any output. pytest doesnot collect the test. How can I use locust with pytest

    from locust import HttpUser, TaskSet, task
    class WebsiteTasks(TaskSet):
    def on_start(self):
    self.index()

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

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


    class WebsiteUser(HttpUser):
    task = WebsiteTasks
    host = "localhost:5000"
    min_wait = 1000
    max_wait = 5000


    When I run pytest locust_test.py this is the output:

    ================================================================ test session starts ================================================================
    platform linux -- Python 3.8.5, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
    rootdir: /home/user/Desktop/testing
    collected 0 items

    Continue reading...

Compartilhe esta Página