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

Method test_avoid_double_stdout

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

Source from the content-addressed store, hash-verified

904
905 @pytest.mark.parametrize("junit_logging", ["no", "system-out"])
906 def test_avoid_double_stdout(
907 self, pytester: Pytester, run_and_parse: RunAndParse, junit_logging: str
908 ) -> None:
909 pytester.makepyfile(
910 """
911 import sys
912 import pytest
913
914 @pytest.fixture
915 def arg(request):
916 yield
917 sys.stdout.write('hello-stdout teardown')
918 raise ValueError()
919 def test_function(arg):
920 sys.stdout.write('hello-stdout call')
921 """
922 )
923 result, dom = run_and_parse("-o", "junit_logging=%s" % junit_logging)
924 node = dom.find_first_by_tag("testsuite")
925 pnode = node.find_first_by_tag("testcase")
926 if junit_logging == "no":
927 assert not node.find_by_tag(
928 "system-out"
929 ), "system-out should not be generated"
930 if junit_logging == "system-out":
931 systemout = pnode.find_first_by_tag("system-out")
932 assert "hello-stdout call" in systemout.toxml()
933 assert "hello-stdout teardown" in systemout.toxml()
934
935
936def test_mangle_test_address() -> None:

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