Test for issue https://github.com/pytest-dev/pytest/issues/331 In this case an INTERNALERROR occurred trying to report the failure of a test like this one because pytest failed to get the source lines.
(pytester: Pytester)
| 1277 | |
| 1278 | @pytest.mark.filterwarnings("default::pytest.PytestCollectionWarning") |
| 1279 | def test_dont_collect_non_function_callable(pytester: Pytester) -> None: |
| 1280 | """Test for issue https://github.com/pytest-dev/pytest/issues/331 |
| 1281 | |
| 1282 | In this case an INTERNALERROR occurred trying to report the failure of |
| 1283 | a test like this one because pytest failed to get the source lines. |
| 1284 | """ |
| 1285 | pytester.makepyfile( |
| 1286 | """ |
| 1287 | class Oh(object): |
| 1288 | def __call__(self): |
| 1289 | pass |
| 1290 | |
| 1291 | test_a = Oh() |
| 1292 | |
| 1293 | def test_real(): |
| 1294 | pass |
| 1295 | """ |
| 1296 | ) |
| 1297 | result = pytester.runpytest() |
| 1298 | result.stdout.fnmatch_lines( |
| 1299 | [ |
| 1300 | "*collected 1 item*", |
| 1301 | "*test_dont_collect_non_function_callable.py:2: *cannot collect 'test_a' because it is not a function*", |
| 1302 | "*1 passed, 1 warning in *", |
| 1303 | ] |
| 1304 | ) |
| 1305 | |
| 1306 | |
| 1307 | def test_class_injection_does_not_break_collection(pytester: Pytester) -> None: |
nothing calls this directly
no test coverage detected