(self, pytester: Pytester)
| 1018 | assert "request" in item.funcargs |
| 1019 | |
| 1020 | def test_request_addfinalizer(self, pytester: Pytester) -> None: |
| 1021 | item = pytester.getitem( |
| 1022 | """ |
| 1023 | import pytest |
| 1024 | teardownlist = [] |
| 1025 | @pytest.fixture |
| 1026 | def something(request): |
| 1027 | request.addfinalizer(lambda: teardownlist.append(1)) |
| 1028 | def test_func(something): pass |
| 1029 | """ |
| 1030 | ) |
| 1031 | assert isinstance(item, Function) |
| 1032 | item.session._setupstate.setup(item) |
| 1033 | item._request._fillfixtures() |
| 1034 | # successively check finalization calls |
| 1035 | parent = item.getparent(pytest.Module) |
| 1036 | assert parent is not None |
| 1037 | teardownlist = parent.obj.teardownlist |
| 1038 | ss = item.session._setupstate |
| 1039 | assert not teardownlist |
| 1040 | ss.teardown_exact(None) |
| 1041 | print(ss.stack) |
| 1042 | assert teardownlist == [1] |
| 1043 | |
| 1044 | def test_request_addfinalizer_failing_setup(self, pytester: Pytester) -> None: |
| 1045 | pytester.makepyfile( |
nothing calls this directly
no test coverage detected