def test_persist(): dev = dummy() assert dev.persist is False with patch.object(dev, 'hide') as mock: dev.cleanup() mock.assert_called_once_with() dev = dummy() dev.persist = True with patch.object(dev, 'hide') as mock: dev.cleanup() mock.assert_not_called()
def test_init_no_bus(): with patch.object(smbus2.SMBus, 'open') as mock: i2c(port=2, address=0x71) mock.assert_called_once_with(2)