Skip to content

Add pytest-reportlog integration test and document compatibility - #379

Open
LouisDeconinck wants to merge 2 commits into
pytest-dev:masterfrom
LouisDeconinck:issue-134-reportlog
Open

LouisDeconinck wants to merge 2 commits into
pytest-dev:masterfrom
LouisDeconinck:issue-134-reportlog

Conversation

@LouisDeconinck

@LouisDeconinck LouisDeconinck commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • As suspected in the issue, this already works on current master: rerun attempts are published through pytest_runtest_logreport, so pytest-reportlog emits a TestReport per attempt with outcome: "rerun" and a rerun counter
  • Adds an integration test pinning that behavior, adds pytest-reportlog to the tox test deps, and documents the compatibility in the README

Closes #134

Test plan

  • New test runs --report-log and asserts the JSONL contains a rerun call report followed by the final passed report with correct rerun indices

Rerun attempts are already published through pytest_runtest_logreport, so
pytest-reportlog emits a TestReport per attempt with outcome "rerun" and a
rerun counter. Pin that with a test, add pytest-reportlog to the tox test
deps, and note the compatibility in the README.

Closes pytest-dev#134.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

@icemac icemac left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

— Comment created by Claude

Code review findings (high effort) are posted inline.

Comment thread tox.ini
commands = pytest tests/ {posargs}
deps =
xdist: pytest-xdist
pytest-reportlog

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

— Comment created by Claude

This only affects local tox runs. The GitHub Actions jobs in .github/workflows/test.yml don't use tox. They run pip install pytest / pip install -e ., so pytest-reportlog is never installed there and test_reportlog_contains_rerun_reports is always skipped by importorskip. The behavior this PR wants to pin is therefore never checked in CI. Please add pytest-reportlog to the pip install steps in test.yml, or at least to the main matrix job.

Comment thread changes/134.misc.rst
@@ -0,0 +1,3 @@
Add an integration test covering ``pytest-reportlog`` compatibility: each

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

— Comment created by Claude

changes/README.rst says: "Do not hard wrap the text of an entry: towncrier re-wraps each paragraph to fit the change log, and hard wrapping produces a ragged result." This entry is hard wrapped across three lines. It also repeats the README wording. A single short line is enough:

Suggested change
Add an integration test covering ``pytest-reportlog`` compatibility: each
Add an integration test for ``pytest-reportlog`` compatibility.

Comment thread README.rst
* This plugin is compatible with
`pytest-reportlog <https://pypi.org/project/pytest-reportlog/>`_: each
attempt is emitted as a ``TestReport``, with retried failures using the
``"rerun"`` outcome.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

— Comment created by Claude

The user-facing part of this PR is this new compatibility note. The only change log fragment is 134.misc.rst, and it describes the test setup. If the note should show up under Documentation in the change log, consider adding a 134.doc.rst fragment, e.g. Document compatibility with pytest-reportlog.

if line.strip()
]
test_reports = [r for r in reports if r.get("$report_type") == "TestReport"]
call_reports = [r for r in test_reports if r.get("when") == "call"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

— Comment created by Claude

The test only checks when == "call" reports. The README now says each attempt is emitted as a TestReport, but these cases are not covered:

  • setup/teardown reports of the rerun attempt
  • xdist crash reruns, where the rerun report from pytest_handlecrashitem has when == "???". I checked this manually and it currently works.

A regression in those paths would not be caught. Either check all TestReports for the item, or narrow the README wording.

result = testdir.runpytest("--reruns", "1", "--report-log=log.jsonl")
assert_outcomes(result, passed=1, rerun=1)

import json

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

— Comment created by Claude

Minor: import json is function-local. The rest of the module imports stdlib modules at the top (import random, import re, ...). Please move it up there.

@icemac icemac left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the fix but I'd like to propose a different integration.

Comment thread tox.ini
commands = pytest tests/ {posargs}
deps =
xdist: pytest-xdist
pytest-reportlog

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes pytest-reportlog a dependency for all tests, which I do not like.
I'd prefer a conditional dependency like it is done for xdist, but we should combine xdist and reflog into one group "deps" so we do not have a runner for each dependency. Also update the GitHub workflow accordingly.

— 100 % human review, no AI involved: Weight higher than the AI generated comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for pytest-reportlog

2 participants