mirror of
https://github.com/KevinMidboe/python-gpiozero.git
synced 2025-10-29 17:50:37 +00:00
Fix #279 once and for all (ha! ;)
This implements the proposal discussed in the re-opened #279 to add a pin_factory argument at the device level and remove the ability to specify a pin instance to device constructors (they now only accept a pin specification). Note: there's still a couple of bits to tidy up (tests on "real" Pis, and pin_factory.release_all needs refinement) but the test suite is now at least capable of passing on a PC.
This commit is contained in:
@@ -33,7 +33,7 @@ def test_device_non_physical():
|
||||
|
||||
def test_device_init():
|
||||
pin = Device.pin_factory.pin(2)
|
||||
with GPIODevice(pin) as device:
|
||||
with GPIODevice(2) as device:
|
||||
assert not device.closed
|
||||
assert device.pin == pin
|
||||
|
||||
@@ -56,9 +56,9 @@ def test_device_close():
|
||||
|
||||
def test_device_reopen_same_pin():
|
||||
pin = Device.pin_factory.pin(2)
|
||||
with GPIODevice(pin) as device:
|
||||
with GPIODevice(2) as device:
|
||||
pass
|
||||
with GPIODevice(pin) as device2:
|
||||
with GPIODevice(2) as device2:
|
||||
assert not device2.closed
|
||||
assert device2.pin is pin
|
||||
assert device.closed
|
||||
|
||||
Reference in New Issue
Block a user