33 lines
1.0 KiB
Python
33 lines
1.0 KiB
Python
import sys
|
|
import unittest
|
|
from pathlib import Path
|
|
from unittest import mock
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "src"))
|
|
|
|
from cthulhu import cthulhu_state
|
|
from cthulhu.scripts import default
|
|
|
|
|
|
class DefaultScriptShutdownRegressionTests(unittest.TestCase):
|
|
def test_remove_key_grabs_clears_tracking_without_touching_dead_device(self):
|
|
script = object.__new__(default.Script)
|
|
script.grab_ids = [474, 475]
|
|
script._modifierGrabIds = [("Insert", 99)]
|
|
|
|
with (
|
|
mock.patch.object(cthulhu_state, "device", None),
|
|
mock.patch("cthulhu.scripts.default.cthulhu.removeKeyGrab") as removeKeyGrab,
|
|
mock.patch("cthulhu.scripts.default.input_event_manager.get_manager") as getManager,
|
|
):
|
|
script.removeKeyGrabs()
|
|
|
|
removeKeyGrab.assert_not_called()
|
|
getManager.assert_not_called()
|
|
self.assertEqual(script.grab_ids, [])
|
|
self.assertEqual(script._modifierGrabIds, [])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|