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
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user