How to run tests asynchronously using pytest and gevent or another asynchronous approach?

I have a lot of tests that expose REST API using requests library. All tests take a lot of time to finish. And I want to make them asynchronous, but I don't such experience. Can someone help me with giving some advice or articles where I can find information about it? Or maybe you know another approach.

P.S: using xdist pytest plugin does not work for me, it does not start running my tests in parallel due to some reason that I don't know, not only me faced with this issue.

Upvotes: 5

Views: 608

Answers (1)

Oleg Neumyvakin
Oleg Neumyvakin

Reputation: 10312

I'd tried pytest-xdist, unittest-parallel with geventmp but only internal Gevent's testing framework actually works for me: https://www.gevent.org/development/running_tests.html

You can run your tests with the following command:

python -m gevent.tests --config /yourtests/yoursuite/known_failures.py -j 3 --no-combine --package yourtests.yoursuite

known_failures.py can be a copy of src/gevent/tests/known_failures.py or just contains lists: FAILING_TESTS=[], IGNORED_TESTS=[], RUN_ALONE=[]

Upvotes: 0

Related Questions