MCPcopy
hub / github.com/pytest-dev/pytest / test_strict_xfail

Method test_strict_xfail

testing/test_skipping.py:630–654  ·  view source on GitHub ↗
(self, pytester: Pytester, strict: bool)

Source from the content-addressed store, hash-verified

628
629 @pytest.mark.parametrize("strict", [True, False])
630 def test_strict_xfail(self, pytester: Pytester, strict: bool) -> None:
631 p = pytester.makepyfile(
632 f"""
633 import pytest
634
635 @pytest.mark.xfail(reason='unsupported feature', strict={strict})
636 def test_foo():
637 with open('foo_executed', 'w', encoding='utf-8'):
638 pass # make sure test executes
639 """
640 )
641 result = pytester.runpytest(p, "-rxX")
642 if strict:
643 result.stdout.fnmatch_lines(
644 ["*test_foo*", "*XPASS(strict)*unsupported feature*"]
645 )
646 else:
647 result.stdout.fnmatch_lines(
648 [
649 "*test_strict_xfail*",
650 "XPASS test_strict_xfail.py::test_foo - unsupported feature",
651 ]
652 )
653 assert result.ret == (1 if strict else 0)
654 assert pytester.path.joinpath("foo_executed").exists()
655
656 @pytest.mark.parametrize("strict", [True, False])
657 def test_strict_xfail_condition(self, pytester: Pytester, strict: bool) -> None:

Callers

nothing calls this directly

Calls 4

fnmatch_linesMethod · 0.80
makepyfileMethod · 0.45
runpytestMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected