Skip to content

Commit 4b1cd8d

Browse files
authored
Merge pull request #301 from hugovk/add-3.14
2 parents e42957a + 53a7ef0 commit 4b1cd8d

8 files changed

Lines changed: 56 additions & 60 deletions

File tree

.github/workflows/build-and-test.yaml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: build
22

3-
on: [push, pull_request]
3+
on: [push, pull_request, workflow_dispatch]
44

55
jobs:
66
test:
@@ -9,21 +9,21 @@ jobs:
99
fail-fast: false # run all tests anyway
1010
matrix:
1111
include:
12-
# Python 3.8 && Pytest 6.2
13-
- toxenv: py38-pytest62-supported-xdist
14-
python: 3.8
12+
# Python 3.10 && Pytest 7
13+
- toxenv: py310-pytest7-supported-xdist
14+
python: "3.10"
1515

1616
# Latest Python & Pytest
17-
- toxenv: py313-pytest_latest-supported-xdist
18-
python: 3.13
17+
- toxenv: py314-pytest_latest-supported-xdist
18+
python: 3.14
1919

2020
# QA
2121
- toxenv: qa
22-
python: 3.8
22+
python: "3.10"
2323
steps:
24-
- uses: actions/checkout@v4
24+
- uses: actions/checkout@v6
2525
- name: Set up Python
26-
uses: actions/setup-python@v5
26+
uses: actions/setup-python@v6
2727
with:
2828
python-version: ${{ matrix.python }}
2929
cache: 'pip'
@@ -48,12 +48,12 @@ jobs:
4848
if: github.ref=='refs/heads/main' && github.event_name!='pull_request'
4949

5050
steps:
51-
- uses: actions/checkout@v4
51+
- uses: actions/checkout@v6
5252

5353
- name: Setup Python
54-
uses: actions/setup-python@v5
54+
uses: actions/setup-python@v6
5555
with:
56-
python-version: "3.9"
56+
python-version: "3.x"
5757

5858
- name: Check release
5959
id: check_release

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ repos:
1717
rev: v3.15.0
1818
hooks:
1919
- id: pyupgrade
20-
args: [--py38-plus]
20+
args: [--py310-plus]
2121

22-
- repo: https://github.com/psf/black
22+
- repo: https://github.com/psf/black-pre-commit-mirror
2323
rev: 24.1.1
2424
hooks:
2525
- id: black

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ For long-running tests, display minutes and not only seconds.
9393

9494
You will need the following prerequisites in order to use pytest-sugar:
9595

96-
- Python 3.8 or newer
97-
- pytest 6.2 or newer
96+
- Python 3.10 or newer
97+
- pytest 7 or newer
9898

9999
## Running on Windows
100100

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ Homepage = "https://github.com/Teemu/pytest-sugar"
2222
"Issue Tracker" = "https://github.com/Teemu/pytest-sugar/issues"
2323

2424
[tool.poetry.dependencies]
25-
python = ">=3.8.1,<4.0"
26-
pytest = ">=6.2.0"
25+
python = ">=3.10,<4.0"
26+
pytest = ">=7"
2727
termcolor = ">=2.1.0"
2828

2929
[tool.poetry.dev-dependencies]

pytest_sugar.py

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
import re
1616
import sys
1717
import time
18+
from collections.abc import Generator, Sequence
1819
from configparser import ConfigParser # type: ignore
19-
from typing import Any, Dict, Generator, List, Optional, Sequence, TextIO, Tuple, Union
20+
from typing import Any, TextIO
2021

2122
import pytest
2223
from _pytest.config import Config
@@ -32,23 +33,23 @@
3233
LEN_RIGHT_MARGIN = 0
3334
LEN_PROGRESS_PERCENTAGE = 5
3435
LEN_PROGRESS_BAR_SETTING = "10"
35-
LEN_PROGRESS_BAR: Optional[int] = None
36+
LEN_PROGRESS_BAR: int | None = None
3637

3738

3839
@dataclasses.dataclass
3940
class Theme:
40-
header: Optional[str] = "magenta"
41-
skipped: Optional[str] = "blue"
42-
success: Optional[str] = "green"
43-
warning: Optional[str] = "yellow"
44-
fail: Optional[str] = "red"
45-
error: Optional[str] = "red"
46-
xfailed: Optional[str] = "green"
47-
xpassed: Optional[str] = "red"
48-
progressbar: Optional[str] = "green"
49-
progressbar_fail: Optional[str] = "red"
50-
progressbar_background: Optional[str] = "grey"
51-
path: Optional[str] = "cyan"
41+
header: str | None = "magenta"
42+
skipped: str | None = "blue"
43+
success: str | None = "green"
44+
warning: str | None = "yellow"
45+
fail: str | None = "red"
46+
error: str | None = "red"
47+
xfailed: str | None = "green"
48+
xpassed: str | None = "red"
49+
progressbar: str | None = "green"
50+
progressbar_fail: str | None = "red"
51+
progressbar_background: str | None = "grey"
52+
path: str | None = "cyan"
5253
name = None
5354
symbol_passed: str = "✓"
5455
symbol_skipped: str = "s"
@@ -57,16 +58,16 @@ class Theme:
5758
symbol_xfailed_skipped: str = "x"
5859
symbol_xfailed_failed: str = "X"
5960
symbol_unknown: str = "?"
60-
unknown: Optional[str] = "blue"
61-
symbol_rerun: Optional[str] = "R"
62-
rerun: Optional[str] = "blue"
61+
unknown: str | None = "blue"
62+
symbol_rerun: str | None = "R"
63+
rerun: str | None = "blue"
6364

6465
def __getitem__(self, x):
6566
return getattr(self, x)
6667

6768

6869
THEME: Theme = Theme()
69-
PROGRESS_BAR_BLOCKS: List[str] = [
70+
PROGRESS_BAR_BLOCKS: list[str] = [
7071
" ",
7172
"▏",
7273
"▎",
@@ -155,16 +156,16 @@ def pytest_sessionstart(session: Session) -> None:
155156
config = ConfigParser()
156157
config.read(["pytest-sugar.conf", os.path.expanduser("~/.pytest-sugar.conf")])
157158

158-
theme_attributes: Dict[str, Optional[str]] = {}
159-
fields: Tuple[dataclasses.Field, ...] = dataclasses.fields(Theme)
159+
theme_attributes: dict[str, str | None] = {}
160+
fields: tuple[dataclasses.Field, ...] = dataclasses.fields(Theme)
160161

161162
for field in fields:
162163
key = field.name
163164
if not config.has_option("theme", key):
164165
continue
165166

166167
value_str: str = config.get("theme", key).lower()
167-
value: Optional[str] = value_str
168+
value: str | None = value_str
168169
if value in ("", "none"):
169170
value = None
170171

@@ -212,7 +213,7 @@ def pytest_configure(config) -> None:
212213
config.pluginmanager.register(sugar_reporter, "terminalreporter")
213214

214215

215-
def pytest_report_teststatus(report: BaseReport) -> Optional[Tuple[str, str, str]]:
216+
def pytest_report_teststatus(report: BaseReport) -> tuple[str, str, str] | None:
216217
if not IS_SUGAR_ENABLED:
217218
return None
218219

@@ -247,7 +248,7 @@ def pytest_report_teststatus(report: BaseReport) -> Optional[Tuple[str, str, str
247248

248249

249250
class SugarTerminalReporter(TerminalReporter):
250-
def __init__(self, config: Config, file: Union[TextIO, None] = None) -> None:
251+
def __init__(self, config: Config, file: TextIO | None = None) -> None:
251252
TerminalReporter.__init__(self, config, file)
252253
self.paths_left = []
253254
self.tests_count = 0
@@ -287,12 +288,8 @@ def pytest_sessionstart(self, session: Session) -> None:
287288
),
288289
bold=True,
289290
)
290-
if int(pytest.__version__.split(".")[0]) <= 6:
291-
hook_call_kwargs = {"startdir": self.startpath}
292-
else:
293-
hook_call_kwargs = {"start_path": self.startpath}
294291
lines = self.config.hook.pytest_report_header(
295-
config=self.config, **hook_call_kwargs
292+
config=self.config, start_path=self.startpath
296293
)
297294
lines.reverse()
298295
for line in flatten(lines):
@@ -301,7 +298,7 @@ def pytest_sessionstart(self, session: Session) -> None:
301298
def write_fspath_result(self, nodeid: str, res, **markup: bool) -> None:
302299
return
303300

304-
def insert_progress(self, report: Union[CollectReport, TestReport]) -> None:
301+
def insert_progress(self, report: CollectReport | TestReport) -> None:
305302
def get_progress_bar() -> str:
306303
length = LEN_PROGRESS_BAR
307304
if not length:
@@ -397,7 +394,7 @@ def get_max_column_for_test_status(self) -> int:
397394
)
398395

399396
def begin_new_line(
400-
self, report: Union[CollectReport, TestReport], print_filename: bool
397+
self, report: CollectReport | TestReport, print_filename: bool
401398
) -> None:
402399
path = self.report_key(report)
403400
self.current_line_num += 1
@@ -435,7 +432,7 @@ def begin_new_line(
435432
self.write("\r\n")
436433

437434
def reached_last_column_for_test_status(
438-
self, report: Union[CollectReport, TestReport]
435+
self, report: CollectReport | TestReport
439436
) -> bool:
440437
len_line = real_string_length(self.current_lines[self.report_key(report)])
441438
return len_line >= self.get_max_column_for_test_status()
@@ -450,14 +447,14 @@ def pytest_runtest_logfinish(self, nodeid: str) -> None:
450447
# pytest's default progress
451448
pass
452449

453-
def report_key(self, report: Union[CollectReport, TestReport]) -> Any:
450+
def report_key(self, report: CollectReport | TestReport) -> Any:
454451
"""Returns a key to identify which line the report should write to."""
455452
return (
456453
(report.location or "") if self.showlongtestinfo else (report.fspath or "")
457454
)
458455

459456
def pytest_runtest_logreport(self, report: TestReport) -> None:
460-
global LEN_PROGRESS_BAR_SETTING, LEN_PROGRESS_BAR
457+
global LEN_PROGRESS_BAR
461458

462459
res = pytest_report_teststatus(report=report)
463460
assert res
@@ -615,7 +612,7 @@ def summary_stats(self) -> None:
615612
colored(" % 5d deselected" % self.count("deselected"), THEME.warning)
616613
)
617614

618-
def _find_playwright_trace(self, report: TestReport) -> Optional[str]:
615+
def _find_playwright_trace(self, report: TestReport) -> str | None:
619616
"""
620617
Finds the Playwright trace file associated with a specific test report.
621618
@@ -727,7 +724,7 @@ def summary_errors(self) -> None:
727724
# show the error instantly after error has occurred.
728725
pass
729726

730-
def print_failure(self, report: Union[CollectReport, TestReport]) -> None:
727+
def print_failure(self, report: CollectReport | TestReport) -> None:
731728
# https://github.com/Frozenball/pytest-sugar/issues/34
732729
if hasattr(report, "wasxfail"):
733730
return

setup.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def get_version(filename):
2626
" look and feel of pytest (e.g. progressbar, show tests that"
2727
" fail instantly)."
2828
),
29-
long_description=codecs.open("README.md", encoding="utf-8").read(),
29+
long_description=open("README.md", encoding="utf-8").read(),
3030
long_description_content_type="text/markdown",
3131
version=get_version("pytest_sugar.py"),
3232
url="https://github.com/Teemu/pytest-sugar",
@@ -41,7 +41,7 @@ def get_version(filename):
4141
zip_safe=False,
4242
include_package_data=True,
4343
platforms="any",
44-
install_requires=["pytest>=6.2.0", "termcolor>=2.1.0"],
44+
install_requires=["pytest>=7", "termcolor>=2.1.0"],
4545
extras_require={
4646
"dev": [
4747
"black",
@@ -60,12 +60,11 @@ def get_version(filename):
6060
"Topic :: Software Development :: Libraries",
6161
"Topic :: Utilities",
6262
"Programming Language :: Python :: 3",
63-
"Programming Language :: Python :: 3.8",
64-
"Programming Language :: Python :: 3.9",
6563
"Programming Language :: Python :: 3.10",
6664
"Programming Language :: Python :: 3.11",
6765
"Programming Language :: Python :: 3.12",
6866
"Programming Language :: Python :: 3.13",
67+
"Programming Language :: Python :: 3.14",
6968
"Programming Language :: Python :: Implementation :: PyPy",
7069
],
7170
)

test_sugar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def test_sample():
114114
def test_report_header(self, testdir):
115115
testdir.makeconftest(
116116
"""
117-
def pytest_report_header(startdir):
117+
def pytest_report_header(start_path):
118118
pass
119119
"""
120120
)

tox.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[tox]
22
minversion = 3.14.0
3-
envlist = py{38,313,py}-pytest_latest-supported-xdist
3+
envlist = py{310,314,py}-pytest_latest-supported-xdist
44
qa
55
requires = virtualenv>=20.0.31
66

77
[testenv]
88
install_command = python -m pip install --use-feature=fast-deps {opts} {packages}
99
deps =
10-
pytest62: pytest~=6.2.5
10+
pytest7: pytest~=7.4
1111
pytest_latest: pytest
1212
termcolor>=1.1.0
1313
supported-xdist: pytest-xdist

0 commit comments

Comments
 (0)