Skip to content

Commit

Permalink
reduce lines in test source
Browse files Browse the repository at this point in the history
  • Loading branch information
2bndy5 committed Aug 7, 2024
1 parent def89d8 commit e6464dc
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions tests/test_i2c.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,17 @@ def test_singleton(board_i2c: busio.I2C, busio_i2c: busio.I2C):
assert isinstance(board_i2c.expectations, deque)
assert board_i2c == busio_i2c

board_i2c.expectations.extend(
[
I2CScan([address]),
I2CTransfer(address, bytearray(1), bytearray(1)),
]
)
board_i2c.expectations.append(I2CScan([address]))
board_i2c.expectations.append(I2CTransfer(address, bytearray(1), bytearray(1)))
assert busio_i2c.expectations == board_i2c.expectations

assert busio_i2c.try_lock()
assert not board_i2c.try_lock()
assert address in board_i2c.scan()
busio_i2c.unlock()

buffer = bytearray(1)
assert board_i2c.try_lock()
assert not busio_i2c.try_lock()
board_i2c.writeto_then_readfrom(address, buffer, buffer)
board_i2c.unlock()
busio_i2c.unlock() # for coverage measurement only
Expand Down

0 comments on commit e6464dc

Please sign in to comment.