(self, pytester: Pytester)
| 275 | assert rep.location == ("test_logstart_logfinish_hooks.py", 1, "test_func") |
| 276 | |
| 277 | def test_exact_teardown_issue90(self, pytester: Pytester) -> None: |
| 278 | rec = pytester.inline_runsource( |
| 279 | """ |
| 280 | import pytest |
| 281 | |
| 282 | class TestClass(object): |
| 283 | def test_method(self): |
| 284 | pass |
| 285 | def teardown_class(cls): |
| 286 | raise Exception() |
| 287 | |
| 288 | def test_func(): |
| 289 | import sys |
| 290 | # on python2 exc_info is kept till a function exits |
| 291 | # so we would end up calling test functions while |
| 292 | # sys.exc_info would return the indexerror |
| 293 | # from guessing the lastitem |
| 294 | excinfo = sys.exc_info() |
| 295 | import traceback |
| 296 | assert excinfo[0] is None, \ |
| 297 | traceback.format_exception(*excinfo) |
| 298 | def teardown_function(func): |
| 299 | raise ValueError(42) |
| 300 | """ |
| 301 | ) |
| 302 | reps = rec.getreports("pytest_runtest_logreport") |
| 303 | print(reps) |
| 304 | for i in range(2): |
| 305 | assert reps[i].nodeid.endswith("test_method") |
| 306 | assert reps[i].passed |
| 307 | assert reps[2].when == "teardown" |
| 308 | assert reps[2].failed |
| 309 | assert len(reps) == 6 |
| 310 | for i in range(3, 5): |
| 311 | assert reps[i].nodeid.endswith("test_func") |
| 312 | assert reps[i].passed |
| 313 | assert reps[5].when == "teardown" |
| 314 | assert reps[5].nodeid.endswith("test_func") |
| 315 | assert reps[5].failed |
| 316 | |
| 317 | def test_exact_teardown_issue1206(self, pytester: Pytester) -> None: |
| 318 | """Issue shadowing error with wrong number of arguments on teardown_method.""" |
nothing calls this directly
no test coverage detected