Adjust logging for tests

This commit is contained in:
thePR0M3TH3AN
2025-07-01 15:16:01 -04:00
parent 74df5f654c
commit d7ea493663
6 changed files with 42 additions and 17 deletions

7
src/tests/conftest.py Normal file
View File

@@ -0,0 +1,7 @@
import logging
import pytest
@pytest.fixture(autouse=True)
def mute_logging():
logging.getLogger().setLevel(logging.WARNING)

View File

@@ -2,6 +2,7 @@ import builtins
from itertools import cycle
import pytest
import logging
from utils import password_prompt
@@ -15,10 +16,12 @@ def test_prompt_new_password(monkeypatch):
assert result == "goodpass"
def test_prompt_new_password_retry(monkeypatch):
def test_prompt_new_password_retry(monkeypatch, caplog):
seq = iter(["pass1", "pass2", "passgood", "passgood"])
monkeypatch.setattr(password_prompt.getpass, "getpass", lambda prompt: next(seq))
caplog.set_level(logging.WARNING)
result = password_prompt.prompt_new_password()
assert "User entered a password shorter" in caplog.text
assert result == "passgood"