Questions tagged [pytest-xdist]

pytest-xdist is a pytest plugin which allows test execution in parallel. Paralellization works both by running a configurable number of processes on the same host, and across multiple hosts. It also supports running tests on multiple platforms and Python interpreters in parallel. Additionally, it supports automatic re-running of failed tests.

Reference:

88 questions
25
votes
2 answers

How to print output when using pytest with xdist

I'm using py.test to run tests. I'm using it with pytest-xdist to run the tests in parallel. I want to see the output of print statements in my tests. I have: Ubuntu 15.10, Python 2.7.10, pytest-2.9.1, pluggy-0.3.1. Here's my test file: def…
Steve Saporta
  • 4,581
  • 3
  • 30
  • 32
21
votes
3 answers

Why does pytest + xdist not capture output?

I'm using pytest with pytest-xdist for parallel test running. It doesn't seem to honour the -s option for passing through the standard output to the terminal as the tests are run. Is there any way to make this happen? I realise this could cause the…
Andrew Magee
  • 6,506
  • 4
  • 35
  • 58
12
votes
2 answers

How to fix "pytest: error: unrecognized arguments: -n"

Hi I am trying to run my tests parallely(pytest-xdist) on the azure pipelines. Till now the tests were running perfectly fine. Suddenly the pytest is throwing a weird error saying "unrecognized argument". The file name : integration_test.py Command…
Dhanush Prabhakar
  • 121
  • 1
  • 1
  • 5
8
votes
1 answer

Pytest: run teardown once for all workers using pytest-xdist

I have a pytest fixture that I need to run only once across all pytest workers. @pytest.fixture(scope="session") @shared # this will call setup once for all processes def cache(request): acc = Account(id=10) acc.create() …
Vladimir Yahello
  • 243
  • 1
  • 2
  • 10
7
votes
1 answer

pytest-xdist: LookupError: setuptools-scm was unable to detect version

When installing pytest-xdist, I'm getting this error: Collecting pytest-xdist>=1.15.0 Downloading https://company.com/pypi/packages/dc/b2/a59db3ef996b93c3ef35dbbc33557a71ef67a6839d94a52c88eeb1086002/pytest-xdist-1.15.0.tar.gz (87kB) 100%…
yndolok
  • 5,197
  • 2
  • 42
  • 46
7
votes
2 answers

Is there a way to find out which pytest-xdist gateway is running?

I would like to create a separate log file for each subprocess/gateway that is spawned by pytest-xdist. Is there an elegant way of finding out in which subprocess/gateway pytest is currently in? I'm configuring my root logger with a session scoped…
Kanguros
  • 1,902
  • 2
  • 12
  • 18
6
votes
1 answer

pytest issues with a session scoped fixture and asyncio

I have multiple test files, each has an async fixture that looks like this: @pytest.fixture(scope="module") def event_loop(request): loop = asyncio.get_event_loop_policy().new_event_loop() yield loop …
Uri
  • 25,622
  • 10
  • 45
  • 72
6
votes
1 answer

How to tell pytest-xdist to run tests from one folder sequencially and the rest in parallel?

Imagine that I have test/unit/... which are safe to run in parallel and test/functional/... which cannot be run in parallel yet. Is there an easy way to convince pytest to run the functional ones sequentially? Consider that we are talking about a…
sorin
  • 161,544
  • 178
  • 535
  • 806
6
votes
0 answers

Why does pytest_sessionstart hook run multiple times when using pytest-xdist?

Im trying to run pytests in parallel across my selenium grid using pytest-xdist. Prior to using pytest-xdist, I had one time setup being executed once before all tests even started using the pytest_sessionstart hook. It worked perfectly. It would be…
JerryBringer
  • 150
  • 1
  • 1
  • 8
6
votes
4 answers

Pytest doesn't recognize -n option after pytest-xdist installation

I have installed pytest-xdist on top of a working pytest environment : pip install pytest-xdist and I have received this output Downloading/unpacking pytest-xdist Downloading pytest-xdist-1.10.tar.gz Running setup.py egg_info for package…
Salvatore Avanzo
  • 2,656
  • 1
  • 21
  • 30
5
votes
0 answers

pytest-xdist crashes with pytest-cov error

I was trying to execute tests for my package over remote machine through ssh from my master node. Both nodes have same version of the packages installed. I'm running test like this, pytest -d --tx ssh=ubuntu//python=python3 --rsyncdir…
Sreeram TP
  • 11,346
  • 7
  • 54
  • 108
5
votes
0 answers

Pytest live logging with parallel execution - possible?

I have a test suite that I run with python3 -mpytest --log-cli-level=DEBUG ... on the build server. The live logs are useful to troubleshoot if the tests get stuck or are slow for some reason (the tests use external resources). To speed things up,…
Krumelur
  • 31,081
  • 7
  • 77
  • 119
5
votes
0 answers

Serialization Issue in Pytest/xdist

Replacing crashed worker gw0 INTERNALERROR> Traceback (most recent call last): INTERNALERROR> File "/usr/local/lib/python3.7/site-packages/_pytest/main.py", line 191, in wrap_session INTERNALERROR> session.exitstatus = doit(config, session) or…
NJN
  • 79
  • 8
5
votes
1 answer

How to run setup (fixture) once and then tests in parallel

I was using pytest-xdist to run tests in parallel, but my suite setup is very huge and bulky, which I want to avoid running multiple times in each tests execution. While I was using pytest-xdist to run all the tests in parallel, I came across the…
5
votes
1 answer

pytest-xdist IOError: cannot send to

I'm using pytest with pytest-xdist to test django app,when i run py.test -n 1 i get an error: Test session starts (platform: linux2, Python 2.7.12, pytest 2.9.2, pytest-sugar 0.7.1) django settings: icbase.settings (from ini file) rootdir:…
Roy.S
  • 51
  • 5
1
2 3 4 5 6