Skip to content

Commit 38c59cc

Browse files
authored
Fix subtests jsonl report to be consistent with other reports (#91)
* Fix subtests jsonl report to be consistent with other reports Fix #90 * Add Python 3.14 and drop Python 3.9 (EOL(
2 parents 986dbfb + 91af148 commit 38c59cc

File tree

5 files changed

+30
-6
lines changed

5 files changed

+30
-6
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
strategy:
3232
fail-fast: false
3333
matrix:
34-
python: ["3.9", "3.10", "3.11", "3.12", "3.13"]
34+
python: ["3.10", "3.11", "3.12", "3.13", "3.14"]
3535
os: [ubuntu-latest, windows-latest]
3636

3737
steps:

CHANGELOG.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
UNRELEASED
22
----------
33

4-
* Added official support for Python 3.12 and 3.13.
5-
* Dropped support for EOL Python 3.7 and Python 3.8.
4+
* `#90 <https://github.com/pytest-dev/pytest-reportlog/issues/90>`_: Fix jsonl output for pytest subtests (introduced in pytest 9.0).
5+
* Added official support for Python 3.12, 3.13, and 3.14.
6+
* Dropped support for EOL Python 3.7, 3.8, and 3.9.
67

78
0.4.0 (2023-05-22)
89
------------------

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ dynamic = ["version"]
1616
description = "Replacement for the --resultlog option, focused in simplicity and extensibility"
1717
readme = "README.rst"
1818
license = "MIT"
19-
requires-python = ">=3.9"
19+
requires-python = ">=3.10"
2020
authors = [
2121
{ name = "Bruno Oliveira", email = "[email protected]" },
2222
]
@@ -30,11 +30,11 @@ classifiers = [
3030
"License :: OSI Approved :: MIT License",
3131
"Operating System :: OS Independent",
3232
"Programming Language :: Python :: 3",
33-
"Programming Language :: Python :: 3.13",
34-
"Programming Language :: Python :: 3.9",
3533
"Programming Language :: Python :: 3.10",
3634
"Programming Language :: Python :: 3.11",
3735
"Programming Language :: Python :: 3.12",
36+
"Programming Language :: Python :: 3.13",
37+
"Programming Language :: Python :: 3.14",
3838
"Topic :: Software Development :: Testing",
3939
]
4040
dependencies = [

src/pytest_reportlog/plugin.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ def pytest_runtest_logreport(self, report):
8989
data = self._config.hook.pytest_report_to_serializable(
9090
config=self._config, report=report
9191
)
92+
93+
# Workaround for subtests that output `_report_type` instead of `$report_type` (#90).
94+
if "_report_type" in data:
95+
data["$report_type"] = data.pop("_report_type")
96+
9297
if (
9398
self._config.option.report_log_exclude_logs_on_passed_tests
9499
and data.get("outcome", "") == "passed"

tests/test_reportlog.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,21 @@ def __str__(self):
186186
bad = {"x": 1, "y": ["a", "b"], "c": C()}
187187
new = cleanup_unserializable(bad)
188188
assert new == {"x": 1, "c": "C instance", "y": ["a", "b"]}
189+
190+
191+
def test_subtest(pytester, tmp_path):
192+
"""Regression test for #90."""
193+
pytester.makepyfile(
194+
"""
195+
def test_foo(subtests):
196+
with subtests.test():
197+
pass
198+
"""
199+
)
200+
fn = tmp_path / "result.log"
201+
result = pytester.runpytest(f"--report-log={fn}")
202+
result.stdout.fnmatch_lines("*1 passed in*")
203+
lines = fn.read_text("UTF-8").splitlines()
204+
for line in lines:
205+
data = json.loads(line)
206+
assert "$report_type" in data

0 commit comments

Comments
 (0)