fix(tests): ignore .env under pytest except the LLM API keys - #4111
Open
paul-nechifor wants to merge 1 commit into
Open
fix(tests): ignore .env under pytest except the LLM API keys#4111paul-nechifor wants to merge 1 commit into
paul-nechifor wants to merge 1 commit into
Conversation
A developer's .env (ROBOT_IP, SIMULATION, ...) leaked into tests through two doors: GlobalConfig's env_file, and the conftest load_dotenv() that exported the whole file into os.environ, which every GlobalConfig() and every forkserver worker then read. ENV_FILE in global_config is now the single switch: None when pytest's PYTEST_VERSION is in the environment (set before conftests load and inherited by every child process), ".env" otherwise. GlobalConfig, the CLI's load_dotenv() and blueprint_config.sources all follow it. The root conftest exports only OPENAI_API_KEY, ANTHROPIC_API_KEY and ALIBABA_API_KEY from .env, skipping empty values and never overriding a shell variable; the redundant load_dotenv() calls in nested conftests are gone.
paul-nechifor
marked this pull request as ready for review
September 13, 2026 01:26
paul-nechifor
requested review from
Dreamsorcerer,
TomCC7,
aclauer,
bogwi,
jeff-hykin,
leshy,
mustafab0 and
spomichter
as code owners
September 13, 2026 01:26
1 task
Codecov Report❌ Patch coverage is @@ Coverage Diff @@
## main #4111 +/- ##
==========================================
- Coverage 78.59% 78.59% -0.01%
==========================================
Files 1460 1460
Lines 138230 138402 +172
Branches 11881 11912 +31
==========================================
+ Hits 108642 108772 +130
- Misses 26244 26298 +54
+ Partials 3344 3332 -12
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 7 files with indirect coverage changes 🚀 New features to boost your workflow:
|
Contributor
|
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.
Problem
ROBOT_IP in .env (and others) leaked into tests.
Solution
Ignore
.envwhen running tests (but do add OPENAI_API_KEY and a few others we use).