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

Method test_setup_error_captures_stderr

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

Source from the content-addressed store, hash-verified

874
875 @pytest.mark.parametrize("junit_logging", ["no", "system-err"])
876 def test_setup_error_captures_stderr(
877 self, pytester: Pytester, run_and_parse: RunAndParse, junit_logging: str
878 ) -> None:
879 pytester.makepyfile(
880 """
881 import sys
882 import pytest
883
884 @pytest.fixture
885 def arg(request):
886 sys.stderr.write('hello-stderr')
887 raise ValueError()
888 def test_function(arg):
889 pass
890 """
891 )
892 result, dom = run_and_parse("-o", "junit_logging=%s" % junit_logging)
893 node = dom.find_first_by_tag("testsuite")
894 pnode = node.find_first_by_tag("testcase")
895 if junit_logging == "no":
896 assert not node.find_by_tag(
897 "system-err"
898 ), "system-err should not be generated"
899 if junit_logging == "system-err":
900 systemerr = pnode.find_first_by_tag("system-err")
901 assert (
902 "hello-stderr" in systemerr.toxml()
903 ), "'hello-stderr' should be in system-err"
904
905 @pytest.mark.parametrize("junit_logging", ["no", "system-out"])
906 def test_avoid_double_stdout(

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