From 790ff9c28633998db55b2a045639e99e9614da4c Mon Sep 17 00:00:00 2001 From: Thomas Juul Dyhr Date: Tue, 7 Apr 2026 20:06:39 +0200 Subject: [PATCH] =?UTF-8?q?test:=20fix=20concurrent=20test=20=E2=80=94=20m?= =?UTF-8?q?ock=20handler's=20local=20import,=20not=20source=20module?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _get_apps_data() uses a by-value import so patching versiontracker.apps.get_applications had no effect in threads; patch _get_apps_data directly instead. Also raise join timeout 10s → 30s as a belt-and-suspenders guard. Co-Authored-By: Claude Sonnet 4.6 --- tests/test_end_to_end_integration.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/test_end_to_end_integration.py b/tests/test_end_to_end_integration.py index 5bc7781..db51d7a 100644 --- a/tests/test_end_to_end_integration.py +++ b/tests/test_end_to_end_integration.py @@ -294,12 +294,15 @@ def test_concurrent_operations_workflow(self, mock_applications, mock_homebrew_c """Test concurrent operations workflow.""" import threading + mock_app_tuples = [("Firefox", "110.0"), ("Google Chrome", "110.0.5481.177"), ("Visual Studio Code", "1.74.0")] results = [] def run_versiontracker(): - with mock.patch("sys.argv", ["versiontracker", "--apps"]): - result = versiontracker_main() - results.append(result) + # Patch the handler's local import (imported by value, so source-module mock doesn't intercept) + with mock.patch("versiontracker.handlers.app_handlers._get_apps_data", return_value=mock_app_tuples): + with mock.patch("sys.argv", ["versiontracker", "--apps"]): + result = versiontracker_main() + results.append(result) # Run multiple instances concurrently threads = [] @@ -310,7 +313,7 @@ def run_versiontracker(): # Wait for all to complete for thread in threads: - thread.join(timeout=10) + thread.join(timeout=30) # All should succeed assert len(results) == 3