MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_deferred_hook_checking

Function test_deferred_hook_checking

testing/acceptance_test.py:1007–1032  ·  view source on GitHub ↗

Check hooks as late as possible (#1821).

(pytester: Pytester)

Source from the content-addressed store, hash-verified

1005
1006
1007def 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
1035def 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