MCPcopy
hub / github.com/pytest-dev/pytest / test_deferred_hook_checking

Function test_deferred_hook_checking

testing/acceptance_test.py:1113–1138  ·  testing/acceptance_test.py::test_deferred_hook_checking

Check hooks as late as possible (#1821).

(pytester: Pytester)

Source from the content-addressed store, hash-verified

1111
1112
1113def 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
1141def test_fixture_values_leak(pytester: Pytester) -> None:

Callers

nothing calls this directly

Calls 4

fnmatch_linesMethod · 0.80
syspathinsertMethod · 0.45
makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected