forked from pimoroni/fanshim-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
60 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,55 @@ | ||
"""Test configuration. | ||
These allow the mocking of various Python modules | ||
that might otherwise have runtime side-effects. | ||
""" | ||
import sys | ||
import mock | ||
import pytest | ||
|
||
|
||
@pytest.fixture(scope='function', autouse=False) | ||
def GPIO(): | ||
"""Mock RPi.GPIO module.""" | ||
GPIO = mock.MagicMock() | ||
# Fudge for Python < 37 (possibly earlier) | ||
sys.modules['RPi'] = mock.Mock() | ||
sys.modules['RPi'].GPIO = GPIO | ||
sys.modules['RPi.GPIO'] = GPIO | ||
yield GPIO | ||
del sys.modules['RPi'] | ||
del sys.modules['RPi.GPIO'] | ||
|
||
|
||
@pytest.fixture(scope='function', autouse=False) | ||
def plasma(): | ||
"""Mock plasma module.""" | ||
plasma = mock.MagicMock() | ||
sys.modules['plasma'] = plasma | ||
yield plasma | ||
del sys.modules['plasma'] | ||
|
||
|
||
@pytest.fixture(scope='function', autouse=False) | ||
def spidev(): | ||
"""Mock spidev module.""" | ||
spidev = mock.MagicMock() | ||
sys.modules['spidev'] = spidev | ||
yield spidev | ||
del sys.modules['spidev'] | ||
|
||
|
||
@pytest.fixture(scope='function', autouse=False) | ||
def atexit(): | ||
"""Mock atexit module.""" | ||
atexit = mock.MagicMock() | ||
sys.modules['atexit'] = atexit | ||
yield atexit | ||
del sys.modules['atexit'] | ||
|
||
"""Test configuration. | ||
These allow the mocking of various Python modules | ||
that might otherwise have runtime side-effects. | ||
""" | ||
import sys | ||
import mock | ||
import pytest | ||
|
||
|
||
@pytest.fixture(scope='function', autouse=False) | ||
def FanShim(): | ||
import fanshim | ||
yield fanshim.FanShim | ||
del sys.modules['fanshim'] | ||
|
||
|
||
@pytest.fixture(scope='function', autouse=False) | ||
def GPIO(): | ||
"""Mock RPi.GPIO module.""" | ||
GPIO = mock.MagicMock() | ||
# Fudge for Python < 37 (possibly earlier) | ||
sys.modules['RPi'] = mock.Mock() | ||
sys.modules['RPi'].GPIO = GPIO | ||
sys.modules['RPi.GPIO'] = GPIO | ||
yield GPIO | ||
del sys.modules['RPi'] | ||
del sys.modules['RPi.GPIO'] | ||
|
||
|
||
@pytest.fixture(scope='function', autouse=False) | ||
def apa102(): | ||
"""Mock APA102 module.""" | ||
apa102 = mock.MagicMock() | ||
sys.modules['apa102'] = apa102 | ||
yield apa102 | ||
del sys.modules['apa102'] | ||
|
||
|
||
@pytest.fixture(scope='function', autouse=False) | ||
def spidev(): | ||
"""Mock spidev module.""" | ||
spidev = mock.MagicMock() | ||
sys.modules['spidev'] = spidev | ||
yield spidev | ||
del sys.modules['spidev'] | ||
|
||
|
||
@pytest.fixture(scope='function', autouse=False) | ||
def atexit(): | ||
"""Mock atexit module.""" | ||
atexit = mock.MagicMock() | ||
sys.modules['atexit'] = atexit | ||
yield atexit | ||
del sys.modules['atexit'] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters