Skip to content

[PR #13525/391324e1 backport][8.4.x] pytester: avoid unraisableexception gc collects in inline runs to speed up test suite #13526

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

patchback[bot]
Copy link

@patchback patchback bot commented Jun 16, 2025

This is a backport of PR #13525 as merged into main (391324e).

This is an alternative to #13513. I had to change some tests to run in a subprocess and tweak them a bit to make it work.

Fixes #13482.

Closes #13513.

…ed up test suite (#13525)

Because `pytester.runpytest()` executes the full session cycle (including
`pytest_unconfigure`), it was calling `gc.collect()` in a loop multiple
times—even for small, fast tests. This significantly increased the total
test suite runtime.

To optimize performance, disable the gc runs in inline pytester runs
entirely, matching the behavior before #12958.

Locally the test suite runtime improved dramatically, dropping from 425s
to 160s.

Fixes #13482.

Co-authored-by: Bruno Oliveira <[email protected]>
(cherry picked from commit 391324e)
@nicoddemus nicoddemus merged commit 4c161ab into 8.4.x Jun 16, 2025
29 of 31 checks passed
@nicoddemus nicoddemus deleted the patchback/backports/8.4.x/391324e13a6589f5d824d053240d4b9a4139a115/pr-13525 branch June 16, 2025 21:52
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.

2 participants