X-Git-Url: https://zdv2.bktei.com/gitweb/EVA-2020-02-2.git/blobdiff_plain/be4d0fc9022240b5047654523aab877cbaa8a73d..4cbbc360566337406c8bf7b1d3b653d19b41ae4c:/library/tests/conftest.py?ds=sidebyside diff --git a/library/tests/conftest.py b/library/tests/conftest.py index 8a3ffb4..8a5c54c 100644 --- a/library/tests/conftest.py +++ b/library/tests/conftest.py @@ -14,6 +14,23 @@ class SMBusFakeDevice(MockSMBus): self.regs[0x00:0x01] = 0x0f, 0x00 +@pytest.fixture(scope='function', autouse=True) +def cleanup(): + yield None + try: + del sys.modules['enviroplus'] + except KeyError: + pass + try: + del sys.modules['enviroplus.noise'] + except KeyError: + pass + try: + del sys.modules['enviroplus.gas'] + except KeyError: + pass + + @pytest.fixture(scope='function', autouse=False) def GPIO(): """Mock RPi.GPIO module.""" @@ -54,3 +71,20 @@ def atexit(): yield atexit del sys.modules['atexit'] + +@pytest.fixture(scope='function', autouse=False) +def sounddevice(): + """Mock sounddevice module.""" + sounddevice = mock.MagicMock() + sys.modules['sounddevice'] = sounddevice + yield sounddevice + del sys.modules['sounddevice'] + + +@pytest.fixture(scope='function', autouse=False) +def numpy(): + """Mock numpy module.""" + numpy = mock.MagicMock() + sys.modules['numpy'] = numpy + yield numpy + del sys.modules['numpy']