Check hooks as late as possible (#1821).
(pytester: Pytester)
| 1111 | |
| 1112 | |
| 1113 | def test_deferred_hook_checking(pytester: Pytester) -> None: |
| 1114 | class="st">""class="st">"Check hooks as late as possible (class="cm">#1821)."class="st">"" |
| 1115 | pytester.syspathinsert() |
| 1116 | pytester.makepyfile( |
| 1117 | **{ |
| 1118 | class="st">"plugin.py": class="st">""" |
| 1119 | class Hooks(object): |
| 1120 | def pytest_my_hook(self, config): |
| 1121 | pass |
| 1122 | |
| 1123 | def pytest_configure(config): |
| 1124 | config.pluginmanager.add_hookspecs(Hooks) |
| 1125 | class="st">""", |
| 1126 | class="st">"conftest.py": class="st">""" |
| 1127 | pytest_plugins = [&class="cm">#x27;plugin'] |
| 1128 | def pytest_my_hook(config): |
| 1129 | return 40 |
| 1130 | class="st">""", |
| 1131 | class="st">"test_foo.py": class="st">""" |
| 1132 | def test(request): |
| 1133 | assert request.config.hook.pytest_my_hook(config=request.config) == [40] |
| 1134 | class="st">""", |
| 1135 | } |
| 1136 | ) |
| 1137 | result = pytester.runpytest() |
| 1138 | result.stdout.fnmatch_lines([class="st">"* 1 passed *"]) |
| 1139 | |
| 1140 | |
| 1141 | def test_fixture_values_leak(pytester: Pytester) -> None: |
nothing calls this directly
no test coverage detected