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

Function test_testcase_handles_init_exceptions

testing/test_unittest.py:1093–1111  ·  view source on GitHub ↗

Regression test to make sure exceptions in the __init__ method are bubbled up correctly. See https://github.com/pytest-dev/pytest/issues/3788

(pytester: Pytester)

Source from the content-addressed store, hash-verified

1091
1092
1093def test_testcase_handles_init_exceptions(pytester: Pytester) -> None:
1094 """
1095 Regression test to make sure exceptions in the __init__ method are bubbled up correctly.
1096 See https://github.com/pytest-dev/pytest/issues/3788
1097 """
1098 pytester.makepyfile(
1099 """
1100 from unittest import TestCase
1101 import pytest
1102 class MyTestCase(TestCase):
1103 def __init__(self, *args, **kwargs):
1104 raise Exception("should raise this exception")
1105 def test_hello(self):
1106 pass
1107 """
1108 )
1109 result = pytester.runpytest()
1110 assert "should raise this exception" in result.stdout.str()
1111 result.stdout.no_fnmatch_line("*ERROR at teardown of MyTestCase.test_hello*")
1112
1113
1114def test_error_message_with_parametrized_fixtures(pytester: Pytester) -> None:

Callers

nothing calls this directly

Calls 4

strMethod · 0.80
no_fnmatch_lineMethod · 0.80
makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected