From 668cdf7d87d802a4351e5cd59016581605da15e4 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 11 Nov 2025 12:43:00 -0300 Subject: [PATCH 1/2] Fix subtests jsonl report to be consistent with other reports Fix #90 --- CHANGELOG.rst | 1 + src/pytest_reportlog/plugin.py | 5 +++++ tests/test_reportlog.py | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index c0f5243..baf23e6 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,7 @@ UNRELEASED ---------- +* `#90 `_: Fix jsonl output for pytest subtests (introduced in pytest 9.0). * Added official support for Python 3.12 and 3.13. * Dropped support for EOL Python 3.7 and Python 3.8. diff --git a/src/pytest_reportlog/plugin.py b/src/pytest_reportlog/plugin.py index 8c2a672..d44d56f 100644 --- a/src/pytest_reportlog/plugin.py +++ b/src/pytest_reportlog/plugin.py @@ -89,6 +89,11 @@ def pytest_runtest_logreport(self, report): data = self._config.hook.pytest_report_to_serializable( config=self._config, report=report ) + + # Workaround for subtests that output `_report_type` instead of `$report_type` (#90). + if "_report_type" in data: + data["$report_type"] = data.pop("_report_type") + if ( self._config.option.report_log_exclude_logs_on_passed_tests and data.get("outcome", "") == "passed" diff --git a/tests/test_reportlog.py b/tests/test_reportlog.py index 2586c69..0fcde91 100644 --- a/tests/test_reportlog.py +++ b/tests/test_reportlog.py @@ -186,3 +186,21 @@ def __str__(self): bad = {"x": 1, "y": ["a", "b"], "c": C()} new = cleanup_unserializable(bad) assert new == {"x": 1, "c": "C instance", "y": ["a", "b"]} + + +def test_subtest(pytester, tmp_path): + """Regression test for #90.""" + pytester.makepyfile( + """ + def test_foo(subtests): + with subtests.test(): + pass + """ + ) + fn = tmp_path / "result.log" + result = pytester.runpytest(f"--report-log={fn}") + result.stdout.fnmatch_lines("*1 passed in*") + lines = fn.read_text("UTF-8").splitlines() + for line in lines: + data = json.loads(line) + assert "$report_type" in data From 91af148e7c98b704e03f1bba36da778356084571 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 11 Nov 2025 12:52:36 -0300 Subject: [PATCH 2/2] Add Python 3.14 and drop Python 3.9 (EOL( --- .github/workflows/test.yml | 2 +- CHANGELOG.rst | 4 ++-- pyproject.toml | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 635a5eb..4721c09 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,7 +31,7 @@ jobs: strategy: fail-fast: false matrix: - python: ["3.9", "3.10", "3.11", "3.12", "3.13"] + python: ["3.10", "3.11", "3.12", "3.13", "3.14"] os: [ubuntu-latest, windows-latest] steps: diff --git a/CHANGELOG.rst b/CHANGELOG.rst index baf23e6..b2daf32 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,8 +2,8 @@ UNRELEASED ---------- * `#90 `_: Fix jsonl output for pytest subtests (introduced in pytest 9.0). -* Added official support for Python 3.12 and 3.13. -* Dropped support for EOL Python 3.7 and Python 3.8. +* Added official support for Python 3.12, 3.13, and 3.14. +* Dropped support for EOL Python 3.7, 3.8, and 3.9. 0.4.0 (2023-05-22) ------------------ diff --git a/pyproject.toml b/pyproject.toml index b1e5005..07d5b73 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,7 +16,7 @@ dynamic = ["version"] description = "Replacement for the --resultlog option, focused in simplicity and extensibility" readme = "README.rst" license = "MIT" -requires-python = ">=3.9" +requires-python = ">=3.10" authors = [ { name = "Bruno Oliveira", email = "bruno@pytest.org" }, ] @@ -30,11 +30,11 @@ classifiers = [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.13", - "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", "Topic :: Software Development :: Testing", ] dependencies = [