From f13afb8dec0f68e3b9d61b5e3962d3a2cbb8f6e5 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 26 Feb 2026 09:34:18 +0000 Subject: [PATCH] Fix infinite loop in profile management test with robust input mocking - Update `src/tests/test_profile_management.py` to use a more robust `input` mock iterator. - Mock returns fallback "y" responses after the initial choice ("3") to break any potential infinite loops in `confirm_action` if mocking fails or module reloading interferes. - Addresses `OSError` and timeout on Windows CI caused by interactive prompt loops. Co-authored-by: PR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> --- src/tests/test_profile_management.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/tests/test_profile_management.py b/src/tests/test_profile_management.py index ab8fd748..465fe7c6 100644 --- a/src/tests/test_profile_management.py +++ b/src/tests/test_profile_management.py @@ -47,11 +47,14 @@ def test_add_and_delete_entry(monkeypatch): utils.password_prompt, "confirm_action", lambda *_a, **_k: True ) - # Use an iterator for input to prevent infinite loops if logic fails - # Expectation: - # 1. "3" for add_new_fingerprint choice - # 2. (confirm_action shouldn't ask input if mocked) - input_values = iter(["3", "3", "3", "3", "3"]) # Buffer for safety + # Robust input mock: + # 1. "3" -> Select "Generate a new seed" + # 2. "y" -> Confirm action (fallback if confirm_action mock missed) + # 3. "y" -> Confirm again (fallback) + # 4. "y" -> Confirm again (fallback) + # 5. "y" -> Confirm again (fallback) + # Using "y" breaks the loop in confirm_action if it gets called. + input_values = iter(["3", "y", "y", "y", "y"]) monkeypatch.setattr("builtins.input", lambda *_a, **_k: next(input_values)) pm.add_new_fingerprint()