Test option to dump tracebacks after a certain timeout. If faulthandler is disabled, no traceback will be dumped.
(pytester: Pytester, enabled: bool)
| 78 | ], |
| 79 | ) |
| 80 | def 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"]) |
nothing calls this directly
no test coverage detected