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

Method test_setup_error_captures_stdout

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

Source from the content-addressed store, hash-verified

845
846 @pytest.mark.parametrize("junit_logging", ["no", "system-out"])
847 def test_setup_error_captures_stdout(
848 self, pytester: Pytester, run_and_parse: RunAndParse, junit_logging: str
849 ) -> None:
850 pytester.makepyfile(
851 """
852 import pytest
853
854 @pytest.fixture
855 def arg(request):
856 print('hello-stdout')
857 raise ValueError()
858 def test_function(arg):
859 pass
860 """
861 )
862 result, dom = run_and_parse("-o", "junit_logging=%s" % junit_logging)
863 node = dom.find_first_by_tag("testsuite")
864 pnode = node.find_first_by_tag("testcase")
865 if junit_logging == "no":
866 assert not node.find_by_tag(
867 "system-out"
868 ), "system-out should not be generated"
869 if junit_logging == "system-out":
870 systemout = pnode.find_first_by_tag("system-out")
871 assert (
872 "hello-stdout" in systemout.toxml()
873 ), "'hello-stdout' should be in system-out"
874
875 @pytest.mark.parametrize("junit_logging", ["no", "system-err"])
876 def test_setup_error_captures_stderr(

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected