From 0ded1e3c93d51c7c3a379f864aa9c9092841cb60 Mon Sep 17 00:00:00 2001 From: Jatin K Malik Date: Sun, 5 Apr 2026 21:08:21 -0700 Subject: [PATCH] test: mock Notify module in conftest to prevent real notifications (#390) - Add Notify mock to global gi.repository mock in conftest.py - This prevents real desktop notifications during test runs - Clean up unnecessary comments in test_main_args_deps.py --- tests/conftest.py | 1 + tests/test_main_args_deps.py | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index ccd247a..1140f21 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -65,6 +65,7 @@ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..") # precisely because PyGObject was installed and already loaded. _mock_gi = MagicMock() _mock_gi_repository = MagicMock() +_mock_gi_repository.Notify = MagicMock() sys.modules["gi"] = _mock_gi sys.modules["gi.repository"] = _mock_gi_repository diff --git a/tests/test_main_args_deps.py b/tests/test_main_args_deps.py index 4a500ca..e2d67a7 100644 --- a/tests/test_main_args_deps.py +++ b/tests/test_main_args_deps.py @@ -274,12 +274,10 @@ class TestMainFunction(unittest.TestCase): """Test main() when another instance is already running.""" from vocalinux.main import main - # Mock single_instance module since it's imported inside main() mock_single_instance = MagicMock() mock_single_instance.acquire_lock.return_value = False with patch.dict(sys.modules, {"vocalinux.single_instance": mock_single_instance}): - # Should exit with status 1 with pytest.raises(SystemExit) as exc_info: main() assert exc_info.value.code == 1