Skip to content

Speed up test collection for large suites#1

Open
adamtheturtle wants to merge 5 commits into
mainfrom
adamtheturtle/faster-test-collection
Open

Speed up test collection for large suites#1
adamtheturtle wants to merge 5 commits into
mainfrom
adamtheturtle/faster-test-collection

Conversation

@adamtheturtle

Copy link
Copy Markdown
Owner

Summary

Test plan

  • testing/test_pluginmanager.py::TestPytestPluginInteractions::test_hook_proxy
  • testing/test_conftest.py::test_hook_proxy
  • testing/test_assertion.py::test_assertrepr_loaded_per_dir
  • testing/python/fixtures.py getfuncargnames tests + fixtures/metafunc/scope/assertion suites
  • Sanity check that module-scoped parametrize reordering still clusters matching params
  • CI on this PR

Made with Cursor

adamtheturtle and others added 3 commits July 17, 2026 08:18
Cache path-sensitive hook proxies, skip unnecessary fixture reordering,
and avoid expensive signature/path work on common collection hot paths.

Co-authored-by: Cursor <cursoragent@cursor.com>
Reuse FunctionDefinition nodes for non-parametrized tests, defer TopRequest
until setup, share resolved markers across parametrized items, and build the
first CallSpec2 batch without empty-map copies.

Co-authored-by: Cursor <cursoragent@cursor.com>
Declare callspec on Item, type hook proxies as HookRelay | FSHookProxy,
model request lifecycle with Optional instead of False, and reuse
FunctionDefinition via a runnable flag instead of mutating __class__.

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread src/_pytest/python.py Outdated
Restores post-collection item._request compatibility while still skipping
TopRequest construction on collect-only paths that never read it, and keeps
teardown clearing from immediately recreating the request.

Co-authored-by: Cursor <cursoragent@cursor.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b514004. Configure here.

Comment thread src/_pytest/main.py Outdated
Caching an FSHookProxy when a path's directory was not yet in
_dirpath2confmods permanently stripped root conftests from Package
collection, because later association does not grow _conftest_plugins.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

1 participant