MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_strict_xfail

Method test_strict_xfail

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

fnmatch_linesMethod · 0.80
makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected