Skip to content

Commit e3df80e

Browse files
committed
Fixup tests for ADC detect.
1 parent be63866 commit e3df80e

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

library/tests/conftest.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ def __init__(self, i2c_bus):
1414
self.regs[0x00:0x01] = 0x0f, 0x00
1515

1616

17+
class SMBusFakeDeviceNoTimeout(MockSMBus):
18+
def __init__(self, i2c_bus):
19+
MockSMBus.__init__(self, i2c_bus)
20+
self.regs[0x00:0x01] = 0x0f, 0x80
21+
22+
1723
@pytest.fixture(scope='function', autouse=True)
1824
def cleanup():
1925
yield None
@@ -63,6 +69,16 @@ def smbus():
6369
del sys.modules['smbus']
6470

6571

72+
@pytest.fixture(scope='function', autouse=False)
73+
def smbus_notimeout():
74+
"""Mock smbus module."""
75+
smbus = mock.MagicMock()
76+
smbus.SMBus = SMBusFakeDeviceNoTimeout
77+
sys.modules['smbus'] = smbus
78+
yield smbus
79+
del sys.modules['smbus']
80+
81+
6682
@pytest.fixture(scope='function', autouse=False)
6783
def mocksmbus():
6884
"""Mock smbus module."""

library/tests/test_setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def test_gas_unavailable(GPIO, mocksmbus):
1818
gas.read_all()
1919

2020

21-
def test_gas_available(GPIO, mocksmbus):
21+
def test_gas_available(GPIO, smbus_notimeout):
2222
from enviroplus import gas
2323
gas._is_setup = False
2424
assert gas.available() == True

0 commit comments

Comments
 (0)