pytest
pytest copied to clipboard
List of disabled plugins is not passed down to `runpytest()`
When there are some pytest plugins disabled using the -p no:XXX option the information about disabled plugins is not passed down to the runpytest() call, so the initially disabled plugin appears as enabled there.
Simple test to show the issue:
$ wget https://files.pythonhosted.org/packages/source/p/pytest_metadata/pytest_metadata-3.1.1.tar.gz
$ tar xf pytest_metadata-3.1.1.tar.gz
$ cd pytest_metadata-3.1.1/
$ sed -i -e '/\[testenv\]/a\'$'\n''deps = pytest-checkdocs' tox.ini
$ sed -i -e 's/setenv =/& PYTEST_ADDOPTS="-p no:checkdocs"/' tox.ini
$ tox -e py39
py39: install_deps> python -I -m pip install pytest-checkdocs
.pkg: install_requires> python -I -m pip install 'hatch-vcs>=0.3' 'hatchling>=1.13'
.pkg: _optional_hooks> python /usr/lib/python3.9/vendor-packages/pyproject_api/_backend.py True hatchling.build
.pkg: get_requires_for_build_sdist> python /usr/lib/python3.9/vendor-packages/pyproject_api/_backend.py True hatchling.build
.pkg: build_sdist> python /usr/lib/python3.9/vendor-packages/pyproject_api/_backend.py True hatchling.build
py39: install_package_deps> python -I -m pip install 'pytest>=7.0.0'
py39: install_package> python -I -m pip install --force-reinstall --no-deps /tmp/pytest_metadata-3.1.1/.tox/.tmp/package/1/pytest_metadata-3.1.1.tar.gz
py39: commands[0]> pytest -s -ra --color=yes
============================= test session starts ==============================
platform sunos5 -- Python 3.9.19, pytest-8.1.1, pluggy-1.4.0
cachedir: .tox/py39/.pytest_cache
rootdir: /tmp/pytest_metadata-3.1.1
configfile: tox.ini
testpaths: tests
plugins: metadata-3.1.1
collected 10 items
tests/test_metadata.py ============================= test session starts ==============================
platform sunos5 -- Python 3.9.19, pytest-8.1.1, pluggy-1.4.0
rootdir: /tmp/pytest-of-marcel/pytest-2/test_metadata0
plugins: checkdocs-2.12.0, metadata-3.1.1
collected 1 item
test_metadata.py . [100%]
============================== 1 passed in 0.02s ===============================
... [snip] ...
Please note the plugins: checkdocs-2.12.0, metadata-3.1.1 line above. I expect to do not see checkdocs-2.12.0 there.
Related issue: #12073