From 97bcc0ac78277a1f515dd9d45800f13092d944f1 Mon Sep 17 00:00:00 2001 From: Justin Bollinger Date: Wed, 22 Apr 2026 17:27:15 -0400 Subject: [PATCH] test: isolate notify state between tests hate_crack.main calls notify.init() at import time with whatever config.json is resolved from the developer's environment (often ~/.hate_crack/config.json). If that file has notify_enabled: true, the per-attack prompt in attacks.py fires input() during tests and trips pytest's capture fd, failing unrelated tests. Add an autouse conftest fixture that clears notify module state before and after every test so the suite is hermetic regardless of local config. Notify-specific tests already use their own clear_state_for_tests() fixture; this change covers the rest. Co-Authored-By: Claude Opus 4.7 (1M context) --- tests/conftest.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index 33c4af9..22eb2bc 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -20,3 +20,25 @@ def load_hate_crack_module(monkeypatch): @pytest.fixture def hc_module(monkeypatch): return load_hate_crack_module(monkeypatch) + + +@pytest.fixture(autouse=True) +def _isolate_notify_state(): + """Reset notify module state between tests. + + ``hate_crack.main`` calls ``notify.init()`` at import time with whatever + ``config.json`` is resolved from the user's environment (e.g. + ``~/.hate_crack/config.json``). If that config has + ``notify_enabled: true``, the per-attack prompt in ``attacks.py`` fires + ``input()`` during tests and blows up capture. Forcing the notify + package back to its disabled-by-default state before every test keeps + the suite hermetic regardless of the developer's local config. + """ + try: + from hate_crack import notify + except ImportError: + yield + return + notify.clear_state_for_tests() + yield + notify.clear_state_for_tests()