test: fix two more flaky e2e tests with proper handler-level mocks#136
Merged
test: fix two more flaky e2e tests with proper handler-level mocks#136
Conversation
test_concurrent_operations_workflow: patch _get_apps_data once outside threads — mock.patch is not thread-safe; patching from 3 threads simultaneously corrupted the save/restore chain leaving the mock live after the test. test_outdated_applications_workflow: mock _get_installed_applications and _get_homebrew_casks at the handler's local scope to prevent real system_profiler / brew subprocess calls regardless of test execution order. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
Reviewer's GuideStabilizes two flaky end-to-end tests by correctly scoping handler-level mocks: one by moving a shared mock.patch out of worker threads to avoid thread-safety issues, and another by mocking all subprocess-driven helpers at the handler import level so the workflow never reaches real system_profiler or brew invocations regardless of test order. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
🔒 Security Analysis ReportSecurity Analysis ReportGenerated: Tue Apr 7 19:24:21 UTC 2026 Bandit Security ScanSafety Check ResultsPip-Audit Results |
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
test_concurrent_operations_workflow: Movedmock.patchoutside threads.mock.patchis not thread-safe — patching the same attribute from 3 threads simultaneously corrupted the save/restore chain, leaving_get_apps_datamocked with Firefox data after the test, contaminatingtest_handle_list_apps_with_export.test_outdated_applications_workflow: Added mocks for_get_installed_applicationsand_get_homebrew_casksat the handler's local scope. The handler calls both before reachingcheck_outdated_apps, so they were making realsystem_profiler/brewsubprocess calls. When a preceding test left the config'sbrew_pathset to/usr/local/bin/brew, the test failed with "Command not found".Both fixes are verified stable across 3 full test suite runs with different random seeds (2338 passed, 16 skipped each time).
Test plan
pytest -qpasses 3× with different random seeds🤖 Generated with Claude Code
Summary by Sourcery
Stabilize flaky end-to-end workflows tests by tightening and correcting handler-level mocking around application data retrieval and concurrent execution.
Bug Fixes:
Tests: