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

Function test_deferred_hook_checking

testing/acceptance_test.py:1113–1138  ·  view source on GitHub ↗

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 """Check hooks as late as possible (#1821)."""
1115 pytester.syspathinsert()
1116 pytester.makepyfile(
1117 **{
1118 "plugin.py": """
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 """,
1126 "conftest.py": """
1127 pytest_plugins = ['plugin']
1128 def pytest_my_hook(config):
1129 return 40
1130 """,
1131 "test_foo.py": """
1132 def test(request):
1133 assert request.config.hook.pytest_my_hook(config=request.config) == [40]
1134 """,
1135 }
1136 )
1137 result = pytester.runpytest()
1138 result.stdout.fnmatch_lines(["* 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

Used in the wild real call sites across dependent graphs

searching dependent graphs…