MCPcopy
hub / github.com/pytest-dev/pytest / test_call_failure_teardown_error

Method test_call_failure_teardown_error

testing/test_junitxml.py:403–431  ·  view source on GitHub ↗
(
        self, pytester: Pytester, run_and_parse: RunAndParse, xunit_family: str
    )

Source from the content-addressed store, hash-verified

401
402 @parametrize_families
403 def test_call_failure_teardown_error(
404 self, pytester: Pytester, run_and_parse: RunAndParse, xunit_family: str
405 ) -> None:
406 pytester.makepyfile(
407 """
408 import pytest
409
410 @pytest.fixture
411 def arg():
412 yield
413 raise Exception("Teardown Exception")
414 def test_function(arg):
415 raise Exception("Call Exception")
416 """
417 )
418 result, dom = run_and_parse(family=xunit_family)
419 assert result.ret
420 node = dom.get_first_by_tag("testsuite")
421 node.assert_attr(errors=1, failures=1, tests=2)
422 first, second = dom.find_by_tag("testcase")
423 assert first
424 assert second
425 assert first != second
426 fnode = first.get_first_by_tag("failure")
427 fnode.assert_attr(message="Exception: Call Exception")
428 snode = second.get_first_by_tag("error")
429 snode.assert_attr(
430 message='failed on teardown with "Exception: Teardown Exception"'
431 )
432
433 @parametrize_families
434 def test_skip_contains_name_reason(

Callers

nothing calls this directly

Calls 5

run_and_parseFunction · 0.85
get_first_by_tagMethod · 0.80
assert_attrMethod · 0.80
find_by_tagMethod · 0.80
makepyfileMethod · 0.45

Tested by

no test coverage detected