Merge pull request #88 from pimoroni/actions
[EVA-2020-02-2.git] / library / tests / conftest.py
index 8a3ffb44b4f670bab3d5e2fb072f59eef4784b73..8a5c54c5a60f299794035e649bfdbd91db8ca060 100644 (file)
@@ -14,6 +14,23 @@ class SMBusFakeDevice(MockSMBus):
         self.regs[0x00:0x01] = 0x0f, 0x00\r
 \r
 \r
+@pytest.fixture(scope='function', autouse=True)\r
+def cleanup():\r
+    yield None\r
+    try:\r
+        del sys.modules['enviroplus']\r
+    except KeyError:\r
+        pass\r
+    try:\r
+        del sys.modules['enviroplus.noise']\r
+    except KeyError:\r
+        pass\r
+    try:\r
+        del sys.modules['enviroplus.gas']\r
+    except KeyError:\r
+        pass\r
+\r
+\r
 @pytest.fixture(scope='function', autouse=False)\r
 def GPIO():\r
     """Mock RPi.GPIO module."""\r
@@ -54,3 +71,20 @@ def atexit():
     yield atexit\r
     del sys.modules['atexit']\r
 \r
+\r
+@pytest.fixture(scope='function', autouse=False)\r
+def sounddevice():\r
+    """Mock sounddevice module."""\r
+    sounddevice = mock.MagicMock()\r
+    sys.modules['sounddevice'] = sounddevice\r
+    yield sounddevice\r
+    del sys.modules['sounddevice']\r
+\r
+\r
+@pytest.fixture(scope='function', autouse=False)\r
+def numpy():\r
+    """Mock numpy module."""\r
+    numpy = mock.MagicMock()\r
+    sys.modules['numpy'] = numpy\r
+    yield numpy\r
+    del sys.modules['numpy']\r