From 0fadf169d96b72557bee7182c7d5f49b5c4f4589 Mon Sep 17 00:00:00 2001 From: Dane Finlay Date: Tue, 23 Apr 2019 01:58:33 +1000 Subject: [PATCH] Fix two issues with dragonfly's mocked actions - Make each mocked action refer to a class instead. - Replace mock_dyn_str_action with a mocked Mouse class, as that action is the only DynStrActionBase sub-class left that isn't implemented for other platforms. --- dragonfly/os_dependent_mock.py | 35 +++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/dragonfly/os_dependent_mock.py b/dragonfly/os_dependent_mock.py index 8e146709..828f898f 100755 --- a/dragonfly/os_dependent_mock.py +++ b/dragonfly/os_dependent_mock.py @@ -20,26 +20,32 @@ Heavily modified to allow more dragonfly functionality to work regardless of operating system. """ + from .actions import ActionBase, DynStrActionBase -# Mock ActionBase and DynStrActionBase classes +class MockBase(object): + def __init__(self, *args, **kwargs): + pass + -def mock_action(*args, **kwargs): - return ActionBase() +class MockAction(ActionBase): + """ Mock class for dragonfly actions. """ + def __init__(self, *args, **kwargs): + ActionBase.__init__(self) -def mock_dyn_str_action(*args, **kwargs): - return DynStrActionBase(*args, **kwargs) +class Mouse(DynStrActionBase): + """ Mock Mouse action class. """ + def __init__(self, spec=None, static=False): + DynStrActionBase.__init__(self, spec, static) -Paste = mock_dyn_str_action -Mouse = mock_dyn_str_action -WaitWindow = mock_action -FocusWindow = mock_action -StartApp = mock_action -BringApp = mock_action -PlaySound = mock_action +WaitWindow = MockAction +FocusWindow = MockAction +StartApp = MockAction +BringApp = MockAction +PlaySound = MockAction class _WindowInfo(object): @@ -54,11 +60,6 @@ def get_foreground(): return _WindowInfo -class MockBase(object): - def __init__(self, *args, **kwargs): - pass - - class HardwareInput(MockBase): pass