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

Function test_testcase_adderrorandfailure_defers

testing/test_unittest.py:353–373  ·  view source on GitHub ↗
(pytester: Pytester, type: str)

Source from the content-addressed store, hash-verified

351
352@pytest.mark.parametrize("type", ["Error", "Failure"])
353def test_testcase_adderrorandfailure_defers(pytester: Pytester, type: str) -> None:
354 pytester.makepyfile(
355 """
356 from unittest import TestCase
357 import pytest
358 class MyTestCase(TestCase):
359 def run(self, result):
360 excinfo = pytest.raises(ZeroDivisionError, lambda: 0/0)
361 try:
362 result.add%s(self, excinfo._excinfo)
363 except KeyboardInterrupt:
364 raise
365 except:
366 pytest.fail("add%s should not raise")
367 def test_hello(self):
368 pass
369 """
370 % (type, type)
371 )
372 result = pytester.runpytest()
373 result.stdout.no_fnmatch_line("*should not raise*")
374
375
376@pytest.mark.parametrize("type", ["Error", "Failure"])

Callers

nothing calls this directly

Calls 3

no_fnmatch_lineMethod · 0.80
makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected