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

Method test_xfail_captures_output_once

testing/test_junitxml.py:683–709  ·  view source on GitHub ↗
(
        self, pytester: Pytester, junit_logging: str, run_and_parse: RunAndParse
    )

Source from the content-addressed store, hash-verified

681 "junit_logging", ["no", "log", "system-out", "system-err", "out-err", "all"]
682 )
683 def test_xfail_captures_output_once(
684 self, pytester: Pytester, junit_logging: str, run_and_parse: RunAndParse
685 ) -> None:
686 pytester.makepyfile(
687 """
688 import sys
689 import pytest
690
691 @pytest.mark.xfail()
692 def test_fail():
693 sys.stdout.write('XFAIL This is stdout')
694 sys.stderr.write('XFAIL This is stderr')
695 assert 0
696 """
697 )
698 result, dom = run_and_parse("-o", "junit_logging=%s" % junit_logging)
699 node = dom.find_first_by_tag("testsuite")
700 tnode = node.find_first_by_tag("testcase")
701 if junit_logging in ["system-err", "out-err", "all"]:
702 assert len(tnode.find_by_tag("system-err")) == 1
703 else:
704 assert len(tnode.find_by_tag("system-err")) == 0
705
706 if junit_logging in ["log", "system-out", "out-err", "all"]:
707 assert len(tnode.find_by_tag("system-out")) == 1
708 else:
709 assert len(tnode.find_by_tag("system-out")) == 0
710
711 @parametrize_families
712 def test_xfailure_xpass(

Callers

nothing calls this directly

Calls 4

run_and_parseFunction · 0.85
find_first_by_tagMethod · 0.80
find_by_tagMethod · 0.80
makepyfileMethod · 0.45

Tested by

no test coverage detected