Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.13.3
3.13.13
20 changes: 14 additions & 6 deletions tests/test_end_to_end_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,16 +304,23 @@ def test_concurrent_operations_workflow(self, mock_applications, mock_homebrew_c

mock_app_tuples = [("Firefox", "110.0"), ("Google Chrome", "110.0.5481.177"), ("Visual Studio Code", "1.74.0")]
results = []
errors = []

def run_versiontracker():
with mock.patch("sys.argv", ["versiontracker", "--apps"]):
try:
result = versiontracker_main()
results.append(result)
except Exception as exc: # noqa: BLE001
errors.append(exc)

# Patch _get_apps_data once outside threads — mock.patch is not thread-safe;
# patching the same attribute from multiple threads simultaneously corrupts the
# save/restore chain and leaves the mock live after the test exits.
with mock.patch("versiontracker.handlers.app_handlers._get_apps_data", return_value=mock_app_tuples):
# Patch sys.argv and _get_apps_data once outside threads — mock.patch is not
# thread-safe; patching from multiple threads simultaneously corrupts the
# save/restore chain and can expose the real pytest argv to versiontracker_main(),
# causing argparse to reject the test arguments as unrecognized.
with (
mock.patch("sys.argv", ["versiontracker", "--apps"]),
mock.patch("versiontracker.handlers.app_handlers._get_apps_data", return_value=mock_app_tuples),
):
threads = []
for _ in range(3):
thread = threading.Thread(target=run_versiontracker)
Expand All @@ -322,8 +329,9 @@ def run_versiontracker():

for thread in threads:
thread.join(timeout=30)
assert not thread.is_alive(), "Thread timed out after 30 seconds"

# All should succeed
assert not errors, f"Thread(s) raised exceptions: {errors}"
assert len(results) == 3
assert all(result == 0 for result in results)

Expand Down
Loading