Skip to content

Commit

Permalink
Switch to smbus2.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gadgetoid committed Feb 12, 2024
1 parent 0908bf0 commit b14b2ad
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion icm20948/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def __init__(self, i2c_addr=I2C_ADDR, i2c_bus=None):
self._addr = i2c_addr

if i2c_bus is None:
from smbus import SMBus
from smbus2 import SMBus
self._bus = SMBus(1)
else:
self._bus = i2c_bus
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ classifiers = [
"Topic :: Software Development :: Libraries",
"Topic :: System :: Hardware",
]
dependencies = []
dependencies = [
"smbus2"
]

[project.urls]
GitHub = "https://www.github.com/pimoroni/icm20948-python"
Expand Down
12 changes: 6 additions & 6 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
@pytest.fixture(scope='function', autouse=False)
def smbus():
"""Mock smbus module."""
sys.modules['smbus'] = mock.Mock()
sys.modules['smbus'].SMBus = MockSMBus
sys.modules['smbus2'] = mock.Mock()
sys.modules['smbus2'].SMBus = MockSMBus
yield MockSMBus
del sys.modules['smbus']
del sys.modules['smbus2']


@pytest.fixture(scope='function', autouse=False)
def smbus_fail():
"""Mock smbus module."""
sys.modules['smbus'] = mock.Mock()
yield sys.modules['smbus']
del sys.modules['smbus']
sys.modules['smbus2'] = mock.Mock()
yield sys.modules['smbus2']
del sys.modules['smbus2']

0 comments on commit b14b2ad

Please sign in to comment.