fix: filter test_*.py files and pytest fixtures from optimization#1471
Merged
fix: filter test_*.py files and pytest fixtures from optimization#1471
Conversation
When tests_root overlaps with module_root (e.g., both set to "."), the pattern matching in is_test_file() missed Python's standard test_*.py naming convention and conftest.py files. Also adds pytest fixture filtering in the libcst FunctionVisitor to prevent fixtures from being discovered as optimizable functions.
Contributor
PR Review SummaryPrek ChecksFixed: 2 formatting issues resolved and pushed:
All checks now pass (ruff check + ruff format). MypyAll mypy errors in the changed files are pre-existing (not introduced by this PR). The source file errors are in unchanged lines, and the test file errors (missing Code ReviewNo critical issues found. The changes are well-structured:
Test Coverage
Codeflash Optimization PRsChecked 7 open optimization PRs targeting main. All have failing CI — none eligible for merge. Last updated: 2026-02-12T17:30 UTC |
KRRT7
added a commit
that referenced
this pull request
Feb 19, 2026
fix: filter test_*.py files and pytest fixtures from optimization
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
test_*.pyprefix andconftest.pypatterns tois_test_file()for the overlappingtests_rootcase@pytest.fixturefiltering in libcstFunctionVisitorto exclude fixtures from discoveryFixes test functions being optimized when
tests-root = "."(e.g.,test_fallback_agent.pyintest_unst_prop/directory).Test plan
test_filter_functions_python_test_prefix_convention— verifiestest_*.pyandconftest.pyfilteringtest_pytest_fixture_not_discovered— verifies all forms of@pytest.fixtureare excluded