Conversation
β¦eads
mock.patch("sys.argv") inside each thread body is not thread-safe: threads
racing to enter/exit the context manager corrupt the save/restore chain and
expose the real pytest argv to versiontracker_main(), which made argparse
reject the test runner arguments as unrecognized CLI flags.
Fix: hoist both sys.argv and _get_apps_data patches outside the thread spawn
loop, matching the existing pattern established in #134-136. Also capture
thread exceptions into an errors list and assert threads completed within the
timeout, so future failures surface a clear message instead of a count mismatch.
Also bumps .python-version from 3.13.3 β 3.13.13 (pyenv minor update).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
Reviewer's guide (collapsed on small PRs)Reviewer's GuideRefactors a concurrent end-to-end test to use thread-safe patching of sys.argv and app data, adds better diagnostics for thread failures, and updates the Python version pin. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
π Security Analysis ReportSecurity Analysis ReportGenerated: Fri May 1 09:27:16 UTC 2026 Bandit Security ScanSafety Check ResultsPip-Audit Results |
Contributor
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Catching
Exceptioninrun_versiontrackerand only storing the exception object will hide the traceback context; consider capturingtraceback.format_exc()or usingexception.__traceback__so the failure message includes full stack traces for easier debugging. - The
.python-versionbump is orthogonal to the thread-safety/test fix; consider moving that change into a separate PR or at least a separate commit to keep concerns isolated.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Catching `Exception` in `run_versiontracker` and only storing the exception object will hide the traceback context; consider capturing `traceback.format_exc()` or using `exception.__traceback__` so the failure message includes full stack traces for easier debugging.
- The `.python-version` bump is orthogonal to the thread-safety/test fix; consider moving that change into a separate PR or at least a separate commit to keep concerns isolated.Help me be more useful! Please click π or π on each comment and I'll use the feedback to improve your reviews.
Codecov Reportβ All modified and coverable lines are covered by tests. π’ Thoughts on this report? Let us know! |
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
mock.patch("sys.argv")inside each thread body is not thread-safe: threads racing to enter/exit the context manager corrupt the save/restore chain, exposing the real pytest argv toversiontracker_main(), which caused argparse to fail with "unrecognized arguments: tests/test_end_to_end_integration.py --timeout=900 --tb=long --capture=no" β manifesting asassert 2 == 3(one thread raised, never appended)sys.argvand_get_apps_datapatches outside the thread spawn loop, matching the pattern from fix: flaky e2e tests, performance threshold, and exceptions/error_codes coverageΒ #134βtest: fix two more flaky e2e tests with proper handler-level mocksΒ #136errorslist) and athread.is_alive()assertion so future failures produce actionable messages instead of a count mismatch.python-version3.13.3 β 3.13.13Test plan
test_concurrent_operations_workflowβ passes locally (was the failing test)π€ Generated with Claude Code
Summary by Sourcery
Stabilize the concurrent end-to-end workflow test by making its mocking fully thread-safe and strengthening failure diagnostics.
Tests:
Chores: