Test option to dump tracebacks after a certain timeout. If faulthandler is disabled, no traceback will be dumped.
(pytester: Pytester, enabled: bool)
| 89 | ], |
| 90 | ) |
| 91 | def test_timeout(pytester: Pytester, enabled: bool) -> None: |
| 92 | """Test option to dump tracebacks after a certain timeout. |
| 93 | |
| 94 | If faulthandler is disabled, no traceback will be dumped. |
| 95 | """ |
| 96 | pytester.makepyfile( |
| 97 | """ |
| 98 | import os, time |
| 99 | def test_timeout(): |
| 100 | time.sleep(1 if "CI" in os.environ else 0.1) |
| 101 | """ |
| 102 | ) |
| 103 | pytester.makeini( |
| 104 | """ |
| 105 | [pytest] |
| 106 | faulthandler_timeout = 0.01 |
| 107 | """ |
| 108 | ) |
| 109 | args = ["-p", "no:faulthandler"] if not enabled else [] |
| 110 | |
| 111 | result = pytester.runpytest_subprocess(*args) |
| 112 | tb_output = "most recent call first" |
| 113 | if enabled: |
| 114 | result.stderr.fnmatch_lines([f"*{tb_output}*"]) |
| 115 | else: |
| 116 | assert tb_output not in result.stderr.str() |
| 117 | result.stdout.fnmatch_lines(["*1 passed*"]) |
| 118 | assert result.ret == 0 |
| 119 | |
| 120 | |
| 121 | @pytest.mark.keep_ci_var |
nothing calls this directly
no test coverage detected