Skip to content

Commit 9952bd7

Browse files
committed
Fixup: extract msg to constant and remove 'plugin' word
As suggested, removed the unecessary 'plugin' word. Also, extracted the message to a constant.
1 parent 55338af commit 9952bd7

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

pytest_timeout.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
__all__ = ("is_debugging", "Settings")
2222
SESSION_TIMEOUT_KEY = pytest.StashKey[float]()
2323
SESSION_EXPIRE_KEY = pytest.StashKey[float]()
24-
24+
PYTEST_FAILURE_MESSAGE = "Timeout (>%ss) from pytest-timeout."
2525

2626
HAVE_SIGALRM = hasattr(signal, "SIGALRM")
2727
if HAVE_SIGALRM:
@@ -495,7 +495,7 @@ def timeout_sigalrm(item, settings):
495495
dump_stacks(terminal)
496496
if nthreads > 1:
497497
terminal.sep("+", title="Timeout")
498-
pytest.fail("Timeout (>%ss) from pytest-timeout plugin." % settings.timeout)
498+
pytest.fail(PYTEST_FAILURE_MESSAGE % settings.timeout)
499499

500500

501501
def timeout_timer(item, settings):

test_pytest_timeout.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55

66
import pexpect
77
import pytest
8+
from pytest_timeout import PYTEST_FAILURE_MESSAGE
89

10+
11+
MATCH_FAILURE_MESSAGE = f"*Failed: {PYTEST_FAILURE_MESSAGE}*"
912
pytest_plugins = "pytester"
1013

1114
have_sigalrm = pytest.mark.skipif(
@@ -44,7 +47,7 @@ def test_foo():
4447
"""
4548
)
4649
result = pytester.runpytest_subprocess("--timeout=1")
47-
result.stdout.fnmatch_lines(["*Failed: Timeout (>1.0s) from pytest-timeout plugin.*"])
50+
result.stdout.fnmatch_lines([MATCH_FAILURE_MESSAGE % "1.0"])
4851

4952

5053
def test_thread(pytester):
@@ -239,7 +242,7 @@ def test_foo():
239242
"""
240243
)
241244
result = pytester.runpytest_subprocess()
242-
result.stdout.fnmatch_lines(["*Failed: Timeout (>1.0s) from pytest-timeout plugin.*"])
245+
result.stdout.fnmatch_lines([MATCH_FAILURE_MESSAGE % "1.0"])
243246

244247

245248
def test_timeout_mark_timer(pytester):

0 commit comments

Comments
 (0)