Questions tagged [xdist]

PyTest xdist is a plugin that allows parallel and distributed execution of unittests.

PyTest xdist is a plugin that allows parallel and distributed execution of unittests.

http://pytest.org/latest/xdist.html

74 questions
5
votes
1 answer

How can I convert Python unittests to py.test when having global fixtures?

I do have a set of unit tests written using the Python's unittest module. They are using the setUpModule() function to load a global variable with the shared "stuff" that is required to run the tests (including some HTTP sessions). When running my…
sorin
  • 161,544
  • 178
  • 535
  • 806
4
votes
0 answers

Using pytest-xdist causes AttributeError: module '__main__' has no attribute '__file__'

I am trying to use pytest-xdist to run my tests faster by running on multiple CPUs. However, when I switch to using multiple CPUs the tests don't run because there is an error when collecting the tests. More specifically, the error…
bswiecicki
  • 71
  • 4
4
votes
2 answers

Pytest Xdist parallel execution, prevent recreating the database

I'm trying to speed up the Selenium tests in my python Django web application by using parallel execution of 4 threads (-n=4) Of the first 4 tests, 3 give the following error: [test setup] [Test Error Output] Got an error creating the test database:…
Cloud
  • 458
  • 1
  • 13
  • 34
4
votes
2 answers

Using Docker, with Selenium and Pytest to run parallel tests

I'm trying to use these all things together to run parallel tests in a headless chrome: Docker, Selenium, Pytest However, I'm wondering where it makes sense to run the parallel part of the system? Docker can do this (using selenium grid). Both…
Ke.
  • 2,484
  • 8
  • 40
  • 78
4
votes
1 answer

py.test fixture how can I change fixture's scope

I am running tests in two modes: with bare pytest and with pytest-xdist. I have a heavy fixture that was defined with module scope. Inside this fixture, I have some optimization for the case when I am running tests with…
Aleksandr Karasev
  • 437
  • 1
  • 4
  • 12
4
votes
1 answer

How to run setup in each pytest-xdist process

When my test runner starts, I want to set some stuff up (adjust sys.path, add some environment variables, start some global fixtures). What hook can I use to make these changes in each xdist process that is spawned? I've tried overloading a couple…
dbn
  • 13,144
  • 3
  • 60
  • 86
4
votes
2 answers

py.test with xdist is not executing tests parametrized with random values

Does anybody noticed the following strange behaviour for pytest and xdist. When trying to run the test that is parametrized with some randomly selected values the test are not actualy run. The same test is executed without any problems if xdist is…
Marek
  • 71
  • 6
3
votes
0 answers

Access CLI parameters with pytest and xdist

I have a file data.py where i get the data that is used in each test depending of the environment, i get the environment with sys.argv since it's specified in CLI. def env(): if "--env=DEV" in sys.argv: return 'DEV' elif "--env=UAT" in…
JulianC
  • 101
  • 1
  • 10
3
votes
0 answers

How to make working Allure when running tests in parallel using Pytest?

The problem is that I'm using Pytest+Selenium+Allure+Selenoid+Testrail. When tests are running in 1 thread, all is working fine. But when I try to run parallel tests execution: pytest-xdist: Allure creates an empty report pytest-parallel: does not…
Sergei
  • 195
  • 1
  • 11
3
votes
2 answers

How to aggregate test results to publish to testrail after executing pytest tests with xdist?

I'm running into a problem like this. I'm currently using pytest to run test cases, and reducing execution time using xdist to run tests in parallel and publishing tests results to TestRail. The issue is when using xdist, pytest-testrail plugin…
3
votes
1 answer

How can I enable parallelism via pytest -nauto if pytest-xdist is installed?

To enable parallel tests, one has to install pytest-xdist and use pass the -nauto option to pytest to use all available CPUs. I would like to enable -nauto by default, but still make pytest-xdist optional. So this would not work: [pytest] addopts =…
Lekensteyn
  • 64,486
  • 22
  • 159
  • 192
3
votes
0 answers

pytest-xdist indirect fixtures with class scope

I have some complicated and heavy logic to build a test object and the tests are very long running. They are integration tests and I wanted to try and parallelize them a bit. So i found the pytest-xdist library. Because of the heavy nature of…
Cameron Hurst
  • 263
  • 1
  • 13
3
votes
2 answers

Pytest Xdist different tests were collected error

First time posting here, and I've tried to search these past 2 days for a solution to my problem with xdist. When I try to run with n=2 or anything higher, I sometimes (I say sometimes because it works randomly) get an error along the lines of…
Jace Romero
  • 31
  • 1
  • 4
3
votes
1 answer

pytest configure upfront before running in parallel with xdist

I just started to use pytest in combination with xdist to run tests in parallel. I my contest.py I have a configure hook to create some test data direcories (with a time stamp) and files I need for my test run. All works fine until I use xdist. It…
3
votes
0 answers

pytest-xdist running 1 test per slave

My scenario consists of a server that notify to attached websockets when some event occurs. The websocket query params specify for which kind of events the client should be notified. I have a set of predefined events for the notification, and a set…
Teudimundo
  • 2,610
  • 20
  • 28