fix: replace clear=True with surgical env cleanup in session tests#1279
Open
fix: replace clear=True with surgical env cleanup in session tests#1279
Conversation
Six session tests were failing due to missing /state endpoint mocks when using clear=True to remove GitHub Actions environment variables. The clear=True approach wiped all environment variables, including SMART_TESTS_BASE_URL, causing the CLI to use production URLs while mocks were configured for localhost:8080. This commit replaces clear=True with a _clean_github_env() helper that: - Explicitly clears only GITHUB_* variables that affect test behavior - Preserves inherited environment like SMART_TESTS_BASE_URL, PATH, etc. - Eliminates need for manual re-adding of environment variables - Makes tests work in any environment (local dev, CI, Docker) Benefits: - Tests now inherit SMART_TESTS_BASE_URL from shell environment - No redundant HTTP mock setup needed in each test - Single source of truth for GitHub variable cleanup - Production-ready: works with corporate proxies, custom URLs, etc. Fixes 6 test failures in SessionTest: - test_run_session - test_run_session_with_flavor - test_run_session_with_observation - test_run_session_with_timestamp - test_run_session_with_link - test_run_session_with_no_build Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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.
Six session tests were failing due to missing /state endpoint mocks when using clear=True to remove GitHub Actions environment variables. The clear=True approach wiped all environment variables, including SMART_TESTS_BASE_URL, causing the CLI to use production URLs while mocks were configured for localhost:8080.
This commit replaces clear=True with a _clean_github_env() helper
Benefits: