pytest-dev / pytest-dev/pytest
The first test is run in skipped package
Open
Nobody has claimed this yet.
topic: marks
type: bug
- Dominant language
- Python
- Stars
- 14.5k
- Forks
- 3.4k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 35
Description
Hi,
In my use case I need to skip all tests in some python package. For this purpose I added pytestmark to __init__.py:
# __init__.py
import pytest
pytestmark = pytest.mark.skip
I expect all tests to be skipped in this package. However, the first test in this package runs.
Here is a failed test for this issue:
def test_skip_package(testdir):
testdir.makepyfile(
__init__="""
import pytest
pytestmark = pytest.mark.skip
"""
)
testdir.makepyfile(
"""
import pytest
def test_skip1():
assert 0
def test_skip2():
assert 0
"""
)
result = testdir.inline_run()
_, skipped, _ = result.listoutcomes()
assert len(skipped) == 2
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
Start by running the issue's test_skip_package reproduction with testdir and inspect the package-level pytestmark behavior during collection. Confirm the current result and trace why the first test is not skipped. Done means both test_skip1 and test_skip2 are reported as skipped, with the regression test passing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100