pytest-dev / pytest-dev/pytest
Package-level pytestmark in __init__.py no longer propagates to tests
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 14.5k
- Forks
- 3.4k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 35
Description
a detailed description of the bug or problem you are having
A package-level pytestmark = pytest.mark.skip(...) defined in __init__.py is no longer propagated to tests inside that package. Tests that should be skipped run and fail instead.
This is a regression introduced by PR #6197.
pytest and operating system versions
pytest 9.1.1
Python 3.11.13
Linux
minimal example if possible
from pathlib import Path
import shutil
import pytest
root = Path("/tmp/pytest_pkg_skip_test")
shutil.rmtree(root, ignore_errors=True)
package = root / "skippedpkg"
package.mkdir(parents=True)
(package / "__init__.py").write_text(
"import pytest\n"
"pytestmark = pytest.mark.skip(reason='package is disabled')\n"
)
(package / "test_skipped.py").write_text(
"def test_should_be_skipped():\n"
" assert False\n"
)
result = pytest.main(["-q", str(package)])
print("exit code:", int(result))
shutil.rmtree(root, ignore_errors=True)
Expected: 1 skipped, exit code 0
Actual: 1 failed (assert False runs because skip marker is not applied), exit code 1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Run the minimal example from the issue first, using skippedpkg/init.py and test_skipped.py, then read PR #6197 to understand the regression. Add coverage for the package-level pytestmark case; done means the test is reported as skipped and pytest exits with code 0 rather than failing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100