Skip to content

Commit

Permalink
Merge branch 'fix_none_issue' of https://github.com/ydshieh/pytest-su…
Browse files Browse the repository at this point in the history
…btests into fix_none_issue
  • Loading branch information
ydshieh committed Dec 9, 2024
2 parents 2712576 + 8965561 commit 9d238fa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/pytest_subtests/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def _addSkip(self: TestCaseFunction, testcase: TestCase, reason: str) -> None:
# For python < 3.11: the non-subtest skips have to be added by `_originaladdSkip` only after all subtest
# failures are processed by `_addSubTest`. (`self.instance._outcome` has no attribute `skipped/errors` anymore.)
# For python < 3.11, we also need to check if `self.instance._outcome` is `None` (this happens if the test
# class/method is decorated with `unittest.skip`).
# class/method is decorated with `unittest.skip`, see #173).
if sys.version_info < (3, 11) and self.instance._outcome is not None:
subtest_errors = [
x
Expand Down
6 changes: 4 additions & 2 deletions tests/test_subtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,14 +336,14 @@ def test_foo(self):
["collected 1 item", "* 3 xfailed, 1 passed in *"]
)

# A test for https://github.com/pytest-dev/pytest-subtests/issues/173
@pytest.mark.parametrize("runner", ["pytest-normal"])
def test_only_original_skip_is_called(
self,
pytester: pytest.Pytester,
monkeypatch: pytest.MonkeyPatch,
runner: Literal["pytest-normal"],
) -> None:
"""Regression test for #173."""
monkeypatch.setenv("COLUMNS", "200")
p = pytester.makepyfile(
"""
Expand All @@ -360,7 +360,9 @@ def test_foo(self):
"""
)
result = pytester.runpytest(p, "-v", "-rsf")
result.stdout.fnmatch_lines(["SKIPPED [1] test_only_original_skip_is_called.py:6: skip this test"])
result.stdout.fnmatch_lines(
["SKIPPED [1] test_only_original_skip_is_called.py:6: skip this test"]
)

@pytest.mark.parametrize("runner", ["unittest", "pytest-normal", "pytest-xdist"])
def test_skip_with_failure(
Expand Down

0 comments on commit 9d238fa

Please sign in to comment.