fix(tests): Add error handling and environment variable validation to test files#552
Merged
mbaldessari merged 3 commits intovalidatedpatterns:mainfrom Jan 19, 2026
Merged
Conversation
…e.py - Use os.environ.get() for HOME to avoid KeyError at module load - Handle all exception types in get_openshift_version() (KeyError, JSONDecodeError, etc.) - Check subprocess return code before processing output - Validate versions tuple is not None before indexing - Validate WORKSPACE exists and is a directory before os.listdir() - Validate PATTERN_SHORTNAME and INFRA_PROVIDER before string concatenation - Exit with error code on failures instead of crashing
…_web_content.py - Initialize route variable before loop to avoid UnboundLocalError - Add explicit check for route being None after loop - Check subprocess return codes for git add, commit, and push - Log errors when git commands fail - Make timeout and poll interval configurable via environment variables - Initialize new_content before while loop to avoid UnboundLocalError
- Add PATTERNS_REPO_PATH environment variable with sensible default - Use os.path.join for proper path construction - Removes hardcoded path that assumed specific directory structure
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
os.environ.get()with fallbacksUnboundLocalErrorcheck=Trueto subprocess calls to catch failuresChanges
create_ci_badge.py
os.environ.get("HOME", "/tmp")instead of direct dict accessWORKSPACEandversionsbefore useexcept Exceptionwith specific exception typestest_modify_web_content.py
route = Nonebefore loop to fix scope issuecheck=Truetosubprocess.run()callsPATTERNS_REPO_PATHenvironment variable for configurable pathsTest Plan
Fixes #512
Fixes #513
Fixes #514
Fixes #515
Fixes #516
Fixes #517
Fixes #518
Fixes #519
Fixes #520
Fixes #521