(pytester: Pytester)
| 503 | |
| 504 | @pytest.mark.xfail |
| 505 | def test_runtest_in_module_ordering(pytester: Pytester) -> None: |
| 506 | p1 = pytester.makepyfile( |
| 507 | """ |
| 508 | import pytest |
| 509 | def pytest_runtest_setup(item): # runs after class-level! |
| 510 | item.function.mylist.append("module") |
| 511 | class TestClass(object): |
| 512 | def pytest_runtest_setup(self, item): |
| 513 | assert not hasattr(item.function, 'mylist') |
| 514 | item.function.mylist = ['class'] |
| 515 | @pytest.fixture |
| 516 | def mylist(self, request): |
| 517 | return request.function.mylist |
| 518 | @pytest.hookimpl(hookwrapper=True) |
| 519 | def pytest_runtest_call(self, item): |
| 520 | try: |
| 521 | (yield).get_result() |
| 522 | except ValueError: |
| 523 | pass |
| 524 | def test_hello1(self, mylist): |
| 525 | assert mylist == ['class', 'module'], mylist |
| 526 | raise ValueError() |
| 527 | def test_hello2(self, mylist): |
| 528 | assert mylist == ['class', 'module'], mylist |
| 529 | def pytest_runtest_teardown(item): |
| 530 | del item.function.mylist |
| 531 | """ |
| 532 | ) |
| 533 | result = pytester.runpytest(p1) |
| 534 | result.stdout.fnmatch_lines(["*2 passed*"]) |
| 535 | |
| 536 | |
| 537 | def test_outcomeexception_exceptionattributes() -> None: |
nothing calls this directly
no test coverage detected