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)
| 1091 | |
| 1092 | |
| 1093 | def 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 | |
| 1114 | def test_error_message_with_parametrized_fixtures(pytester: Pytester) -> None: |
nothing calls this directly
no test coverage detected