mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2026-10-28 08:22:03 +00:00
Fix infinite loop in profile management test
- Mock `utils.password_prompt.confirm_action` explicitly in `src/tests/test_profile_management.py` to prevent infinite recursion during `manager_module` reload. - Use an iterator for `builtins.input` mock to prevent infinite loops if logic fails. - Fixes CI timeout and crash on Windows caused by `confirm_action` repeatedly asking for input. Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
1 parent
d8720e83f5
commit
d6794bf892
1 file changed
+10
-1
@@ -10,6 +10,7 @@ sys.path.append(str(Path(__file__).resolve().parents[1]))
|
||||
|
||||
|
||||
from utils.fingerprint_manager import FingerprintManager
|
||||
import utils.password_prompt
|
||||
import constants
|
||||
import seedpass.core.manager as manager_module
|
||||
from seedpass.core.vault import Vault
|
||||
@@ -40,8 +41,16 @@ def test_add_and_delete_entry(monkeypatch):
|
||||
monkeypatch.setattr(
|
||||
manager_module.PasswordManager, "generate_bip85_seed", lambda self: seed
|
||||
)
|
||||
# Mock confirm_action in both locations to be safe against reload issues
|
||||
monkeypatch.setattr(manager_module, "confirm_action", lambda *_a, **_k: True)
|
||||
monkeypatch.setattr("builtins.input", lambda *_a, **_k: "3")
|
||||
monkeypatch.setattr(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
|
||||
monkeypatch.setattr("builtins.input", lambda *_a, **_k: next(input_values))
|
||||
|
||||
pm.add_new_fingerprint()
|
||||
|
||||
|
||||
Reference in new issue
Block a user