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

Method test_setup_error

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

Source from the content-addressed store, hash-verified

282
283 @parametrize_families
284 def test_setup_error(
285 self, pytester: Pytester, run_and_parse: RunAndParse, xunit_family: str
286 ) -> None:
287 pytester.makepyfile(
288 """
289 import pytest
290
291 @pytest.fixture
292 def arg(request):
293 raise ValueError("Error reason")
294 def test_function(arg):
295 pass
296 """
297 )
298 result, dom = run_and_parse(family=xunit_family)
299 assert result.ret
300 node = dom.find_first_by_tag("testsuite")
301 node.assert_attr(errors=1, tests=1)
302 tnode = node.find_first_by_tag("testcase")
303 tnode.assert_attr(classname="test_setup_error", name="test_function")
304 fnode = tnode.find_first_by_tag("error")
305 fnode.assert_attr(message='failed on setup with "ValueError: Error reason"')
306 assert "ValueError" in fnode.toxml()
307
308 @parametrize_families
309 def test_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