mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2026-10-27 07:52:03 +00:00
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 <[email protected]>
This commit is contained in:
1 parent
e20dfc55e9
commit
f13afb8dec
1 file changed
+8
-5
@@ -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()
|
||||
|
||||
Reference in new issue
Block a user