pytest-xdist
pytest-xdist copied to clipboard
3.4.0: testing fails with some pytest plugins installed
I found that when pytest-xdist is tested with pytest-console-scripts or pytest-checkdocs or pytest-randomly installed and disabled using -p no:XXX set in PYTEST_ADDOPTS environment variable then the testing fails:
============================= test session starts ==============================
platform sunos5 -- Python 3.9.16, pytest-7.4.3, pluggy-1.3.0 -- $(BUILD_DIR)/.tox/py39/bin/python
cachedir: .tox/py39/.pytest_cache
rootdir: $(BUILD_DIR)
configfile: tox.ini
testpaths: testing
plugins: xdist-3.4.0
collecting ... collected 203 items
testing/acceptance_test.py::TestDistribution::test_n1_pass PASSED [ 0%]
testing/acceptance_test.py::TestDistribution::test_n1_fail FAILED [ 0%]
=================================== FAILURES ===================================
________________________ TestDistribution.test_n1_fail _________________________
self = <acceptance_test.TestDistribution object at 0x7fffadcb2760>
pytester = <Pytester PosixPath('/tmp/pytest-of-marcel/pytest-79/test_n1_fail0')>
def test_n1_fail(self, pytester: pytest.Pytester) -> None:
p1 = pytester.makepyfile(
"""
def test_fail():
assert 0
"""
)
result = pytester.runpytest(p1, "-n1")
> assert result.ret == 1
E assert <ExitCode.USAGE_ERROR: 4> == 1
E + where <ExitCode.USAGE_ERROR: 4> = <RunResult ret=ExitCode.USAGE_ERROR len(stdout.lines)=0 len(stderr.lines)=5 duration=0.03s>.ret
$(BUILD_DIR)/testing/acceptance_test.py:32: AssertionError
----------------------------- Captured stderr call -----------------------------
ERROR: usage: __main__.py [options] [file_or_dir] [file_or_dir] [...]
__main__.py: error: unrecognized arguments: -n1
inifile: None
rootdir: /tmp/pytest-of-marcel/pytest-79/test_n1_fail0
=========================== short test summary info ============================
FAILED testing/acceptance_test.py::TestDistribution::test_n1_fail - assert <E...
!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!
Interestingly, testing pass when there are some other pytest plugins installed, for example pytest-black or pytest-mypy.
See also: https://github.com/kvas-it/pytest-console-scripts/issues/85
Hi @mtelka,
That error looks a bit strange to me, why would that test (and only that test) fail to load pytest-xdist's -n option? Weird. The header does show that only xdist is active...
To avoid this issue we should simply do not install (or load) pytest plugins that are not needed to run tests for pytest-xdist.