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 c0f5243..b2daf32 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,8 +1,9 @@ UNRELEASED ---------- -* Added official support for Python 3.12 and 3.13. -* Dropped support for EOL Python 3.7 and Python 3.8. +* `#90 `_: Fix jsonl output for pytest subtests (introduced in pytest 9.0). +* 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 = [ 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