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

Function test_timeout

testing/test_faulthandler.py:80–107  ·  view source on GitHub ↗

Test option to dump tracebacks after a certain timeout. If faulthandler is disabled, no traceback will be dumped.

(pytester: Pytester, enabled: bool)

Source from the content-addressed store, hash-verified

78 ],
79)
80def test_timeout(pytester: Pytester, enabled: bool) -> None:
81 """Test option to dump tracebacks after a certain timeout.
82
83 If faulthandler is disabled, no traceback will be dumped.
84 """
85 pytester.makepyfile(
86 """
87 import os, time
88 def test_timeout():
89 time.sleep(1 if "CI" in os.environ else 0.1)
90 """
91 )
92 pytester.makeini(
93 """
94 [pytest]
95 faulthandler_timeout = 0.01
96 """
97 )
98 args = ["-p", "no:faulthandler"] if not enabled else []
99
100 result = pytester.runpytest_subprocess(*args)
101 tb_output = "most recent call first"
102 if enabled:
103 result.stderr.fnmatch_lines(["*%s*" % tb_output])
104 else:
105 assert tb_output not in result.stderr.str()
106 result.stdout.fnmatch_lines(["*1 passed*"])
107 assert result.ret == 0
108
109
110@pytest.mark.parametrize("hook_name", ["pytest_enter_pdb", "pytest_exception_interact"])

Callers

nothing calls this directly

Calls 5

fnmatch_linesMethod · 0.80
strMethod · 0.80
makepyfileMethod · 0.45
makeiniMethod · 0.45
runpytest_subprocessMethod · 0.45

Tested by

no test coverage detected