Skip to content
Merged
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
4 changes: 2 additions & 2 deletions pytest_timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
__all__ = ("is_debugging", "Settings")
SESSION_TIMEOUT_KEY = pytest.StashKey[float]()
SESSION_EXPIRE_KEY = pytest.StashKey[float]()

PYTEST_FAILURE_MESSAGE = "Timeout (>%ss) from pytest-timeout."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
PYTEST_FAILURE_MESSAGE = "Timeout (>%ss) from pytest-timeout."
PYTEST_FAILURE_TEMPLATE = "Timeout (>%ss) from pytest-timeout."

maybe? It's a little confusing otherwise to me


HAVE_SIGALRM = hasattr(signal, "SIGALRM")
if HAVE_SIGALRM:
Expand Down Expand Up @@ -495,7 +495,7 @@ def timeout_sigalrm(item, settings):
dump_stacks(terminal)
if nthreads > 1:
terminal.sep("+", title="Timeout")
pytest.fail("Timeout >%ss" % settings.timeout)
pytest.fail(PYTEST_FAILURE_MESSAGE % settings.timeout)


def timeout_timer(item, settings):
Expand Down
11 changes: 7 additions & 4 deletions test_pytest_timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@

import pexpect
import pytest
from pytest_timeout import PYTEST_FAILURE_MESSAGE


MATCH_FAILURE_MESSAGE = f"*Failed: {PYTEST_FAILURE_MESSAGE}*"
pytest_plugins = "pytester"

have_sigalrm = pytest.mark.skipif(
Expand Down Expand Up @@ -44,7 +47,7 @@ def test_foo():
"""
)
result = pytester.runpytest_subprocess("--timeout=1")
result.stdout.fnmatch_lines(["*Failed: Timeout >1.0s*"])
result.stdout.fnmatch_lines([MATCH_FAILURE_MESSAGE % "1.0"])


def test_thread(pytester):
Expand Down Expand Up @@ -239,7 +242,7 @@ def test_foo():
"""
)
result = pytester.runpytest_subprocess()
result.stdout.fnmatch_lines(["*Failed: Timeout >1.0s*"])
result.stdout.fnmatch_lines([MATCH_FAILURE_MESSAGE % "1.0"])


def test_timeout_mark_timer(pytester):
Expand Down Expand Up @@ -480,7 +483,7 @@ def test_foo():
result = child.read().decode().lower()
if child.isalive():
child.terminate(force=True)
assert "timeout >1.0s" not in result
assert "timeout (>1.0s)" not in result
assert "fail" not in result


Expand Down Expand Up @@ -524,7 +527,7 @@ def test_foo():
result = child.read().decode().lower()
if child.isalive():
child.terminate(force=True)
assert "timeout >1.0s" in result
assert "timeout (>1.0s)" in result
assert "fail" in result


Expand Down
Loading