Check hooks as late as possible (#1821).
(pytester: Pytester)
| 1005 | |
| 1006 | |
| 1007 | def test_deferred_hook_checking(pytester: Pytester) -> None: |
| 1008 | """Check hooks as late as possible (#1821).""" |
| 1009 | pytester.syspathinsert() |
| 1010 | pytester.makepyfile( |
| 1011 | **{ |
| 1012 | "plugin.py": """ |
| 1013 | class Hooks(object): |
| 1014 | def pytest_my_hook(self, config): |
| 1015 | pass |
| 1016 | |
| 1017 | def pytest_configure(config): |
| 1018 | config.pluginmanager.add_hookspecs(Hooks) |
| 1019 | """, |
| 1020 | "conftest.py": """ |
| 1021 | pytest_plugins = ['plugin'] |
| 1022 | def pytest_my_hook(config): |
| 1023 | return 40 |
| 1024 | """, |
| 1025 | "test_foo.py": """ |
| 1026 | def test(request): |
| 1027 | assert request.config.hook.pytest_my_hook(config=request.config) == [40] |
| 1028 | """, |
| 1029 | } |
| 1030 | ) |
| 1031 | result = pytester.runpytest() |
| 1032 | result.stdout.fnmatch_lines(["* 1 passed *"]) |
| 1033 | |
| 1034 | |
| 1035 | def test_fixture_values_leak(pytester: Pytester) -> None: |
nothing calls this directly
no test coverage detected