Skip to content

Commit a8ce93e

Browse files
author
vyuroshchin
committed
minimum python3.10 and pytest8.0
1 parent 8aa4b8c commit a8ce93e

File tree

9 files changed

+67
-76
lines changed

9 files changed

+67
-76
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ jobs:
88
fail-fast: false
99
matrix:
1010
python:
11-
- v: "3.8"
12-
tox_env: "py38"
13-
- v: "3.9"
14-
tox_env: "py39"
1511
- v: "3.10"
1612
tox_env: "py310"
1713
- v: "3.11"
@@ -28,9 +24,9 @@ jobs:
2824
run: |
2925
git config --global core.autocrlf false
3026
git config --global core.eol lf
31-
- uses: actions/checkout@v3
27+
- uses: actions/checkout@v5
3228
- name: Set up Python
33-
uses: actions/setup-python@v4
29+
uses: actions/setup-python@v6
3430
with:
3531
python-version: ${{ matrix.python.v }}
3632
- name: Install tox

.pre-commit-config.yaml

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,55 @@
11
---
22
repos:
33
- repo: https://github.com/psf/black
4-
rev: 23.12.1
4+
rev: 25.11.0
55
hooks:
66
- id: black
7-
args: [--safe, --quiet, --target-version, py37]
7+
args: [--safe, --quiet, --target-version, py310]
88
- repo: https://github.com/asottile/blacken-docs
9-
rev: 1.16.0
9+
rev: 1.20.0
1010
hooks:
1111
- id: blacken-docs
12-
additional_dependencies: [black==23.12.1]
12+
additional_dependencies: [black==25.9.0]
1313
- repo: https://github.com/pre-commit/pre-commit-hooks
14-
rev: v4.6.0
14+
rev: v6.0.0
1515
hooks:
16-
- id: trailing-whitespace
17-
- id: end-of-file-fixer
18-
- id: fix-encoding-pragma
19-
args: [--remove]
16+
- id: check-ast
17+
- id: check-case-conflict
18+
- id: check-json
19+
- id: check-merge-conflict
20+
- id: check-toml
2021
- id: check-yaml
22+
- id: check-illegal-windows-names
23+
- id: check-symlinks
24+
- id: check-added-large-files
25+
args: ['--maxkb=500']
2126
- id: debug-statements
27+
- id: destroyed-symlinks
28+
- id: end-of-file-fixer
29+
- id: mixed-line-ending
30+
args: ["--fix=lf"]
31+
- id: trailing-whitespace
2232
language_version: python3
2333
- repo: https://github.com/PyCQA/flake8
2434
rev: 7.0.0
2535
hooks:
2636
- id: flake8
2737
language_version: python3
28-
additional_dependencies: [flake8-typing-imports==1.15.0]
29-
- repo: https://github.com/PyCQA/flake8
38+
additional_dependencies: [flake8-typing-imports==1.17.0]
39+
- repo: https://github.com/pycqa/isort
3040
rev: 7.0.0
3141
hooks:
32-
- id: flake8
33-
language_version: python3
34-
- repo: https://github.com/asottile/reorder_python_imports
35-
rev: v3.12.0
36-
hooks:
37-
- id: reorder-python-imports
42+
- id: isort
3843
- repo: https://github.com/asottile/pyupgrade
39-
rev: v3.15.0
44+
rev: v3.21.1
4045
hooks:
4146
- id: pyupgrade
42-
args: [--keep-percent-format, --py37-plus]
47+
args: [--keep-percent-format, --py310-plus]
4348
- repo: https://github.com/pre-commit/pygrep-hooks
4449
rev: v1.10.0
4550
hooks:
4651
- id: rst-backticks
4752
- repo: https://github.com/adrienverge/yamllint.git
48-
rev: v1.33.0
53+
rev: v1.37.1
4954
hooks:
5055
- id: yamllint

README.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -394,10 +394,9 @@ Changelog
394394

395395
x.y.z
396396
-----
397-
- Add support Python3.13 and Python3.14. Thanks Vladimir
398-
Roshchin.
399-
- Detect debuggers registered with sys.monitoring. Thanks Rich
400-
Chiodo.
397+
- Minimum support Python3.10 and pytest=8.0. Thanks Vladimir Roshchin.
398+
- Add support Python3.13 and Python3.14. Thanks Vladimir Roshchin.
399+
- Detect debuggers registered with sys.monitoring. Thanks Rich Chiodo.
401400

402401
2.3.1
403402
-----

failure_demo.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
55
pytest failure_demo.py
66
"""
7+
78
import threading
89
import time
910

pytest_timeout.py

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
If the platform supports SIGALRM this is used to raise an exception in
77
the test, otherwise os._exit(1) is used.
88
"""
9+
910
import inspect
1011
import os
1112
import signal
@@ -17,17 +18,13 @@
1718

1819
import pytest
1920

20-
21-
__all__ = ("is_debugging", "Settings")
21+
__all__ = ("Settings", "is_debugging")
2222
SESSION_TIMEOUT_KEY = pytest.StashKey[float]()
2323
SESSION_EXPIRE_KEY = pytest.StashKey[float]()
2424
PYTEST_FAILURE_MESSAGE = "Timeout (>%ss) from pytest-timeout."
2525

2626
HAVE_SIGALRM = hasattr(signal, "SIGALRM")
27-
if HAVE_SIGALRM:
28-
DEFAULT_METHOD = "signal"
29-
else:
30-
DEFAULT_METHOD = "thread"
27+
DEFAULT_METHOD = "signal" if HAVE_SIGALRM else "thread"
3128
TIMEOUT_DESC = """
3229
Timeout in seconds before dumping the stacks. Default is 0 which
3330
means no timeout.
@@ -112,7 +109,7 @@ class TimeoutHooks:
112109
"""Timeout specific hooks."""
113110

114111
@pytest.hookspec(firstresult=True)
115-
def pytest_timeout_set_timer(item, settings):
112+
def pytest_timeout_set_timer(self, item, settings):
116113
"""Called at timeout setup.
117114
118115
'item' is a pytest node to setup timeout for.
@@ -122,7 +119,7 @@ def pytest_timeout_set_timer(item, settings):
122119
"""
123120

124121
@pytest.hookspec(firstresult=True)
125-
def pytest_timeout_cancel_timer(item):
122+
def pytest_timeout_cancel_timer(self, item):
126123
"""Called at timeout teardown.
127124
128125
'item' is a pytest node which was used for timeout setup.
@@ -223,19 +220,17 @@ def pytest_report_header(config):
223220

224221
if config._env_timeout:
225222
timeout_header.append(
226-
"timeout: %ss\ntimeout method: %s\ntimeout func_only: %s"
227-
% (
228-
config._env_timeout,
229-
config._env_timeout_method,
230-
config._env_timeout_func_only,
231-
)
223+
f"timeout: {config._env_timeout}s\n"
224+
f"timeout method: {config._env_timeout_method}\n"
225+
f"timeout func_only: {config._env_timeout_func_only}"
232226
)
233227

234228
session_timeout = config.getoption("session_timeout")
235229
if session_timeout:
236-
timeout_header.append("session timeout: %ss" % session_timeout)
230+
timeout_header.append(f"session timeout: {session_timeout}s")
237231
if timeout_header:
238232
return timeout_header
233+
return None
239234

240235

241236
@pytest.hookimpl(tryfirst=True)
@@ -249,10 +244,10 @@ def pytest_exception_interact(node):
249244
def pytest_enter_pdb():
250245
"""Stop the timeouts when we entered pdb.
251246
252-
This stops timeouts from triggering when pytest's builting pdb
247+
This stops timeouts from triggering when pytest's builtin pdb
253248
support notices we entered pdb.
254249
"""
255-
# Since pdb.set_trace happens outside of any pytest control, we don't have
250+
# Since pdb.set_trace happens outside any pytest control, we don't have
256251
# any pytest ``item`` here, so we cannot use timeout_teardown. Thus, we
257252
# need another way to signify that the timeout should not be performed.
258253
global SUPPRESS_TIMEOUT
@@ -326,7 +321,7 @@ def cancel():
326321
signal.setitimer(signal.ITIMER_REAL, settings.timeout)
327322
elif timeout_method == "thread":
328323
timer = threading.Timer(settings.timeout, timeout_timer, (item, settings))
329-
timer.name = "%s %s" % (__name__, item.nodeid)
324+
timer.name = f"{__name__} {item.nodeid}"
330325

331326
def cancel():
332327
timer.cancel()
@@ -427,14 +422,15 @@ def _parse_marker(marker):
427422
elif kw == "func_only":
428423
func_only = val
429424
else:
430-
raise TypeError("Invalid keyword argument for timeout marker: %s" % kw)
425+
msg = f"Invalid keyword argument for timeout marker: {kw}"
426+
raise TypeError(msg)
431427
if len(marker.args) >= 1 and timeout is not NOTSET:
432428
raise TypeError("Multiple values for timeout argument of timeout marker")
433-
elif len(marker.args) >= 1:
429+
if len(marker.args) >= 1:
434430
timeout = marker.args[0]
435431
if len(marker.args) >= 2 and method is not NOTSET:
436432
raise TypeError("Multiple values for method argument of timeout marker")
437-
elif len(marker.args) >= 2:
433+
if len(marker.args) >= 2:
438434
method = marker.args[1]
439435
if len(marker.args) > 2:
440436
raise TypeError("Too many arguments for timeout marker")
@@ -453,22 +449,25 @@ def _validate_timeout(timeout, where):
453449
try:
454450
return float(timeout)
455451
except ValueError:
456-
raise ValueError("Invalid timeout %s from %s" % (timeout, where))
452+
msg = f"Invalid timeout {timeout} from {where}"
453+
raise ValueError(msg)
457454

458455

459456
def _validate_method(method, where):
460457
if method is None:
461458
return None
462459
if method not in ["signal", "thread"]:
463-
raise ValueError("Invalid method %s from %s" % (method, where))
460+
msg = f"Invalid method {method} from {where}"
461+
raise ValueError(msg)
464462
return method
465463

466464

467465
def _validate_func_only(func_only, where):
468466
if func_only is None:
469467
return None
470468
if not isinstance(func_only, bool):
471-
raise ValueError("Invalid func_only value %s from %s" % (func_only, where))
469+
msg = f"Invalid func_only value {func_only} from {where}"
470+
raise ValueError(msg)
472471
return func_only
473472

474473

@@ -555,5 +554,5 @@ def dump_stacks(terminal):
555554
break
556555
else:
557556
thread_name = "<unknown>"
558-
terminal.sep("~", title="Stack of %s (%s)" % (thread_name, thread_ident))
557+
terminal.sep("~", title=f"Stack of {thread_name} ({thread_ident})")
559558
terminal.write("".join(traceback.format_stack(frame)))

setup.cfg

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ classifiers =
2121
Programming Language :: Python :: Implementation :: CPython
2222
Programming Language :: Python :: 3
2323
Programming Language :: Python :: 3 :: Only
24-
Programming Language :: Python :: 3.7
25-
Programming Language :: Python :: 3.8
26-
Programming Language :: Python :: 3.9
2724
Programming Language :: Python :: 3.10
2825
Programming Language :: Python :: 3.11
2926
Programming Language :: Python :: 3.12
@@ -35,8 +32,8 @@ classifiers =
3532
[options]
3633
py_modules = pytest_timeout
3734
install_requires =
38-
pytest>=7.0.0
39-
python_requires = >=3.7
35+
pytest>=8.0.0
36+
python_requires = >=3.10
4037

4138
[options.entry_points]
4239
pytest11 =

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Setuptools install script for pytest-timeout."""
2+
23
from setuptools import setup
34

45
if __name__ == "__main__":

test_pytest_timeout.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
from pytest_timeout import PYTEST_FAILURE_MESSAGE
1010

11-
1211
MATCH_FAILURE_MESSAGE = f"*Failed: {PYTEST_FAILURE_MESSAGE}*"
1312
pytest_plugins = "pytester"
1413

@@ -136,7 +135,7 @@ def test_foo():
136135
@pytest.mark.parametrize("scope", ["function", "class", "module", "session"])
137136
def test_fix_setup(meth, scope, pytester):
138137
pytester.makepyfile(
139-
"""
138+
f"""
140139
import time, pytest
141140
142141
class TestFoo:
@@ -147,9 +146,7 @@ def fix(self):
147146
148147
def test_foo(self, fix):
149148
pass
150-
""".format(
151-
scope=scope
152-
)
149+
"""
153150
)
154151
result = pytester.runpytest_subprocess("--timeout=1", f"--timeout-method={meth}")
155152
assert result.ret > 0
@@ -466,15 +463,13 @@ def test_suppresses_timeout_when_debugger_is_entered(
466463
pytester, debugging_module, debugging_set_trace
467464
):
468465
p1 = pytester.makepyfile(
469-
"""
466+
f"""
470467
import pytest, {debugging_module}
471468
472469
@pytest.mark.timeout(1)
473470
def test_foo():
474471
{debugging_module}.{debugging_set_trace}
475-
""".format(
476-
debugging_module=debugging_module, debugging_set_trace=debugging_set_trace
477-
)
472+
"""
478473
)
479474
child = pytester.spawn_pytest(str(p1))
480475
child.expect("test_foo")
@@ -512,15 +507,13 @@ def test_disable_debugger_detection_flag(
512507
pytester, debugging_module, debugging_set_trace
513508
):
514509
p1 = pytester.makepyfile(
515-
"""
510+
f"""
516511
import pytest, {debugging_module}
517512
518513
@pytest.mark.timeout(1)
519514
def test_foo():
520515
{debugging_module}.{debugging_set_trace}
521-
""".format(
522-
debugging_module=debugging_module, debugging_set_trace=debugging_set_trace
523-
)
516+
"""
524517
)
525518
child = pytester.spawn_pytest(f"{p1} --timeout-disable-debugger-detection")
526519
child.expect("test_foo")

tox.ini

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[pytest]
2-
minversion = 7.0
2+
minversion = 8.0
33
addopts = -ra
44

55
[tox]
6-
envlist = py38,py39,py310,py311,py312,py313,py314,pypy3
6+
envlist = py310,py311,py312,py313,py314,pypy3
77

88
[testenv]
99
deps = pytest
@@ -16,7 +16,7 @@ commands = pytest {posargs}
1616
[testenv:linting]
1717
skip_install = True
1818
basepython = python3
19-
deps = pre-commit>=1.11.0
19+
deps = pre-commit>=4.0.0
2020
commands = pre-commit run --all-files --show-diff-on-failure
2121

2222

0 commit comments

Comments
 (0)