Commit b74a0803 authored by Mathieu Bridon's avatar Mathieu Bridon

tests: Introduce MockCanberra

This will be useful to test that we are "emitting sounds" on certain
parent 0620296e
......@@ -98,6 +98,15 @@ class MockProperty:
class MockCanberra:
def __init__(self):
self._mock_played_events = []
def play(self, playId, *args):
if "dialog-error" in args:
# -- Monkey patch the environment with the mock classes ----------------------
from gi.repository import IBus
sys.modules["gi.repository.IBus"].Bus = MockBus
......@@ -106,6 +115,14 @@ sys.modules["gi.repository.IBus"].LookupTable = MockLookupTable
sys.modules["gi.repository.IBus"].Property = MockProperty
sys.modules["gi.repository.IBus"].PropList = MockPropList
import pycanberra
sys.modules["pycanberra"].Canberra = MockCanberra
except ImportError:
# Fall back on the bundled version, until upstream ports to Python 3:
sys.modules["src.pycanberra"].Canberra = MockCanberra
# -- Load and run our unit tests ---------------------------------------------
loader = unittest.TestLoader()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment