Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog/15132.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
``faulthandler_timeout`` is now registered with type ``float``, so native TOML
integers and floats (e.g. ``faulthandler_timeout = 5`` in ``pytest.toml``)
are accepted instead of being rejected with ``expects a string, got int``.
2 changes: 1 addition & 1 deletion src/_pytest/faulthandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def pytest_addoption(parser: Parser) -> None:
"Exit the test process if a test takes more than "
"faulthandler_timeout seconds to finish"
)
parser.addini("faulthandler_timeout", help_timeout, default=0.0)
parser.addini("faulthandler_timeout", help_timeout, type="float", default=0.0)
parser.addini(
"faulthandler_exit_on_timeout", help_exit_on_timeout, type="bool", default=False
)
Expand Down
19 changes: 19 additions & 0 deletions testing/test_faulthandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,3 +219,22 @@ def fileno(self):
# Even when the stderr wrapper signals an invalid file descriptor,
# ``_get_stderr_fileno()`` should return the real one.
assert get_stderr_fileno() == 2


def test_timeout_accepts_native_toml_numbers(pytester: Pytester) -> None:
"""faulthandler_timeout is float-typed, so native TOML numbers work (#15132)."""
pytester.makepyprojecttoml(
"""
[tool.pytest]
faulthandler_timeout = 5
"""
)
assert pytester.parseconfig().getini("faulthandler_timeout") == 5.0

pytester.makepyprojecttoml(
"""
[tool.pytest]
faulthandler_timeout = 2.5
"""
)
assert pytester.parseconfig().getini("faulthandler_timeout") == 2.5
Loading