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

Method test_teardown_error

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

Source from the content-addressed store, hash-verified

307
308 @parametrize_families
309 def test_teardown_error(
310 self, pytester: Pytester, run_and_parse: RunAndParse, xunit_family: str
311 ) -> None:
312 pytester.makepyfile(
313 """
314 import pytest
315
316 @pytest.fixture
317 def arg():
318 yield
319 raise ValueError('Error reason')
320 def test_function(arg):
321 pass
322 """
323 )
324 result, dom = run_and_parse(family=xunit_family)
325 assert result.ret
326 node = dom.find_first_by_tag("testsuite")
327 tnode = node.find_first_by_tag("testcase")
328 tnode.assert_attr(classname="test_teardown_error", name="test_function")
329 fnode = tnode.find_first_by_tag("error")
330 fnode.assert_attr(message='failed on teardown with "ValueError: Error reason"')
331 assert "ValueError" in fnode.toxml()
332
333 @parametrize_families
334 def test_call_failure_teardown_error(

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected