Skip to content

Commit

Permalink
QA: Include gpiod/gpiodevice mocks in auto tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gadgetoid committed Feb 7, 2024
1 parent 841bffa commit dfc1125
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ def cleanup():

@pytest.fixture(scope='function', autouse=False)
def nopath():
path = sys.path
old_path = sys.path
sys.path = [path for path in sys.path if not path.startswith("/usr/lib") and not path.startswith("/opt/hostedtoolcache")]
yield
sys.path = path
sys.path = old_path


@pytest.fixture(scope='function', autouse=False)
Expand All @@ -33,10 +33,12 @@ def GPIO():
gpiod = mock.MagicMock()
gpiodevice = mock.MagicMock()
sys.modules['gpiod'] = gpiod
sys.modules['gpiod.line'] = gpiod
sys.modules['gpiodevice'] = gpiodevice
sys.modules['gpiodevice.platform'] = mock.MagicMock()
yield gpiod, gpiodevice
del sys.modules['gpiod']
del sys.modules['gpiod.line']
del sys.modules['gpiodevice']
del sys.modules['gpiodevice.platform']

Expand Down
4 changes: 2 additions & 2 deletions tests/test_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
@pytest.mark.parametrize('verbose', [True, False])
@pytest.mark.parametrize('inky_colour', ['black', 'red', 'yellow', None])
@pytest.mark.parametrize('inky_type', ['phat', 'what', 'phatssd1608', 'impressions', '7colour', 'whatssd1683'])
def test_auto_fallback(spidev, smbus2, PIL, inky_type, inky_colour, verbose):
def test_auto_fallback(GPIO, spidev, smbus2, PIL, inky_type, inky_colour, verbose):
"""Test auto init of 'phat', 'black'."""
from inky import Inky7Colour, InkyPHAT, InkyPHAT_SSD1608, InkyWHAT, InkyWHAT_SSD1683, auto

Expand Down Expand Up @@ -61,7 +61,7 @@ def test_auto_fallback(spidev, smbus2, PIL, inky_type, inky_colour, verbose):


@pytest.mark.parametrize('inky_display', enumerate(DISPLAY_VARIANT))
def test_auto(spidev, smbus2_eeprom, PIL, inky_display):
def test_auto(GPIO, spidev, smbus2_eeprom, PIL, inky_display):
"""Test auto init of 'phat', 'black'."""
from inky import Inky7Colour, InkyPHAT, InkyPHAT_SSD1608, InkyWHAT, InkyWHAT_SSD1683, auto, eeprom

Expand Down

0 comments on commit dfc1125

Please sign in to comment.