Skip to content

Avoid PytestAssertRewriteWarning in tests using runpytest#1508

Open
pctablet505 wants to merge 2 commits into
pytest-dev:mainfrom
pctablet505:fix-1334-assert-rewrite-warning
Open

Avoid PytestAssertRewriteWarning in tests using runpytest#1508
pctablet505 wants to merge 2 commits into
pytest-dev:mainfrom
pctablet505:fix-1334-assert-rewrite-warning

Conversation

@pctablet505

@pctablet505 pctablet505 commented Jul 15, 2026

Copy link
Copy Markdown

Fixes #1334

Pass --assert=plain to the in-process runpytest calls for the six tests that emit PytestAssertRewriteWarning, keeping the #1227 in-process fix intact. Also drop the explicit pytest_plugins assignment in the two event-loop fixture tests so they do not mark the already-loaded plugin for assertion rewriting.

Adds --assert=plain to inner runpytest calls for tests that check warning
counts, and removes redundant pytest_plugins declarations in generated test
code. Keeps in-process execution so the pytest-dev#1227 FreeBSD fix remains effective.

Fixes pytest-dev#1334
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.50%. Comparing base (1975f90) to head (cacf361).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1508   +/-   ##
=======================================
  Coverage   94.50%   94.50%           
=======================================
  Files           2        2           
  Lines         510      510           
  Branches       62       62           
=======================================
  Hits          482      482           
  Misses         22       22           
  Partials        6        6           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@pctablet505
pctablet505 marked this pull request as ready for review July 17, 2026 12:47
@seifertm seifertm self-assigned this Jul 21, 2026

@seifertm seifertm 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.

Thanks for the initiative.

The code changes do make sense superficially, but I'm reluctant to integrate them when there's no proof the patch actually solves the problem. Personally, I also don't understand the nature of what causes the issue. In order to progress this, I think we need to find answers to one or more of the following questions:

What is the reason assertion rewriting or setting pytest_plugins causes problems in the first place?
Can you provide a reproducer that verifies this patch fixes the linked GUIX issue?
Can you provide a reproducer that verifies for FreeBSD that this patch does not regress #1227 ?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PytestAssertRewriteWarning due to runpytest and pytest_plugins

3 participants