test: drop the cwd-relative sys.path.insert calls from the test suite - #37802
Merged
yuneng-berri merged 6 commits intoAug 22, 2026
Merged
Conversation
TQ003 stands at 1,077 across 1,058 files, and 1,015 of them are the same shape:
sys.path.insert(0, os.path.abspath("../..")) and its deeper siblings. The
argument resolves against the working directory rather than the file, so from
the repo root, where every job runs pytest, it inserts the directory two levels
above the checkout. It has never pointed at litellm. The package is installed
into the environment anyway, which is what actually makes the import work, and
what the rule's message has said all along.
Removing them leaves 1,634 imports of sys and os with no remaining reference,
and those go too, except where another test module imports the name back out of
the file. The rest of TQ003 is 62 call sites that resolve against __file__ or a
variable, which are a different question and are left alone.
Collection is identical either way: 45,871 tests and the same 51 pre-existing
collection errors before and after, and ruff reports no new undefined name.
Contributor
|
Too many files changed for review (999 files, 100 file limit). |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This was referenced Aug 21, 2026
tin-berri
approved these changes
Aug 22, 2026
…itellm_drop_cwd_relative_syspath # Conflicts: # test-quality-budget.json # tests/audio_tests/test_whisper.py # tests/enterprise/litellm_enterprise/integrations/test_prometheus_unit_tests.py # tests/llm_translation/test_infinity.py # tests/llm_translation/test_litellm_proxy_provider.py # tests/local_testing/test_blocked_user_list.py # tests/local_testing/test_braintrust.py # tests/local_testing/test_embedding.py # tests/local_testing/test_rules.py # tests/local_testing/test_update_spend.py # tests/logging_callback_tests/test_alerting.py # tests/logging_callback_tests/test_opentelemetry_unit_tests.py # tests/pass_through_unit_tests/test_assemblyai_unit_tests_passthrough.py # tests/proxy_admin_ui_tests/test_role_based_access.py # tests/proxy_unit_tests/test_key_generate_prisma.py # tests/proxy_unit_tests/test_unit_test_max_model_budget_limiter.py # tests/proxy_unit_tests/test_user_api_key_auth.py # tests/test_litellm/google_genai/test_google_genai_adapter.py # tests/test_litellm/google_genai/test_google_genai_main.py # tests/test_litellm/integrations/bitbucket/test_bitbucket_prompt_manager.py # tests/test_litellm/integrations/gitlab/test_gitlab_prompt_manager.py # tests/test_litellm/integrations/test_langfuse.py # tests/test_litellm/litellm_core_utils/llm_cost_calc/test_llm_cost_calc_utils.py # tests/test_litellm/litellm_core_utils/test_token_counter.py # tests/test_litellm/llms/bedrock/test_cross_region_inference_profile_mapping.py # tests/test_litellm/proxy/guardrails/guardrail_hooks/test_onyx.py # tests/test_litellm/proxy/guardrails/test_prompt_security_guardrails.py # tests/test_litellm/proxy/management_endpoints/test_key_management_endpoints.py # tests/test_litellm/proxy/pass_through_endpoints/test_pass_through_endpoints.py # tests/test_litellm/test_cost_calculator.py # tests/test_litellm/test_router_model_cost_isolation.py
…itellm_drop_cwd_relative_syspath
…itellm_drop_cwd_relative_syspath
yassin-berriai
added a commit
that referenced
this pull request
Aug 22, 2026
The two new CLI-session test files were added before #37802 swept the suite's sys.path.insert(0, os.path.abspath(...)) calls, so rebasing onto staging put them over the TQ003 test-quality-budget ceiling and failed lint.
5 tasks
shudonglin
pushed a commit
to rayward-external/litellm
that referenced
this pull request
Aug 23, 2026
- restore MagicMock import dropped from the bedrock adaptive-thinking test (upstream BerriAI#37802 merged the import line to its own version) - bump job-timeout-minutes 55->60 on 3 new test-unit.yml shards upstream added with insufficient headroom for their own startup-safety check
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.
TLDR
Problem this solves:
How it solves it:
User Flow
No end-user behavior changes and no test behavior changes. A contributor copying
an existing test file as a template stops inheriting a line that does nothing.
Relevant issues
Linear ticket
Pre-Submission checklist
Screenshots / Proof of Fix
Before (ff02d5c)
What the line actually inserts
because the package is installed into the environment
The rule's count and shape
python scripts/check_test_quality.py tests | grep -c ' TQ003 'directory:
Collection baseline
pytest <every touched tree> --collect-only -qAfter (a704dfb)
The count drops to the calls that resolve against file
python scripts/check_test_quality.py tests | grep -c ' TQ003 'os.path.dirname(__file__),Path(__file__)or a variable, sothey are a different question and are untouched
Collection is unchanged
diffof the two runs'ERRORlines is empty, so the same 51 pre-existingcollection errors and no new ones
No new undefined names
ruff check --select F821 tests/before and afterit was still using. One file keeps its
import osbecause another test moduleimports the name back out of it
The gates agree
Type
🧹 Refactoring
✅ Test
Caveats (if any)
__file__-relative call sites are deliberately leftFinal Attestation