3

I have an existing api testing framework which uses requests module of python3. I decided to use locust module to load test my apis using the same framework. From what I understand locust uses its own client to make api calls.

Is there a way where I can use pythons requests module with locust? So that I don't have to write same code again for locust ( using its own client )

Please see that using requests module with locust does make the api calls but does not capture the response times ( main thing when doing a load testing ) in both gui and non gui mode.

Abhishek Malani
  • 93
  • 1
  • 11

2 Answers2

4

I think you have misunderstood, Locust does not implement its own HTTP client.

Locust User classes just provide a wrapper around other clients and the most commonly used one (HttpUser) uses requests!

So if you call (for example) self.client.request("GET", "someurl") in your HttpUser subclass you will actually be calling requests.

https://docs.locust.io/en/stable/api.html#httpuser-class

Cyberwiz
  • 11,027
  • 3
  • 20
  • 40
0

Locust is a wrapper. You can reuse your existing "requests" client in locust: https://stackoverflow.com/a/66270578/10299604

Frank Escobar
  • 648
  • 5
  • 15