pytest-dev / pytest-dev/pytest

The first test is run in skipped package

Open
#5,830 4 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.