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

Method test_setup_error

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

Source from the content-addressed store, hash-verified

350
351 @parametrize_families
352 def test_setup_error(
353 self, pytester: Pytester, run_and_parse: RunAndParse, xunit_family: str
354 ) -> None:
355 pytester.makepyfile(
356 """
357 import pytest
358
359 @pytest.fixture
360 def arg(request):
361 raise ValueError("Error reason")
362 def test_function(arg):
363 pass
364 """
365 )
366 result, dom = run_and_parse(family=xunit_family)
367 assert result.ret
368 node = dom.get_first_by_tag("testsuite")
369 node.assert_attr(errors=1, tests=1)
370 tnode = node.get_first_by_tag("testcase")
371 tnode.assert_attr(classname="test_setup_error", name="test_function")
372 fnode = tnode.get_first_by_tag("error")
373 fnode.assert_attr(message='failed on setup with "ValueError: Error reason"')
374 assert "ValueError" in fnode.toxml()
375
376 @parametrize_families
377 def test_teardown_error(

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected