File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff 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 )
1824def 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 )
6783def mocksmbus ():
6884 """Mock smbus module."""
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments