mirror of
https://github.com/KevinMidboe/python-gpiozero.git
synced 2025-10-29 17:50:37 +00:00
Replace Event.wait(0) with Event.is_set()
The functionality is identical, and IMHO the latter is much more readable
This commit is contained in:
@@ -64,20 +64,20 @@ def test_input_event_activated():
|
||||
pin = MockPin(2)
|
||||
with DigitalInputDevice(pin) as device:
|
||||
device.when_activated = lambda: event.set()
|
||||
assert not event.wait(0)
|
||||
assert not event.is_set()
|
||||
pin.drive_high()
|
||||
assert event.wait(0)
|
||||
assert event.is_set()
|
||||
|
||||
def test_input_event_deactivated():
|
||||
event = Event()
|
||||
pin = MockPin(2)
|
||||
with DigitalInputDevice(pin) as device:
|
||||
device.when_deactivated = lambda: event.set()
|
||||
assert not event.wait(0)
|
||||
assert not event.is_set()
|
||||
pin.drive_high()
|
||||
assert not event.wait(0)
|
||||
assert not event.is_set()
|
||||
pin.drive_low()
|
||||
assert event.wait(0)
|
||||
assert event.is_set()
|
||||
|
||||
def test_input_wait_active():
|
||||
pin = MockPin(2)
|
||||
|
||||
@@ -160,15 +160,15 @@ def test_mock_pin_edges():
|
||||
pin.when_changed = changed
|
||||
pin.drive_high()
|
||||
assert pin.state
|
||||
assert fired.wait(0)
|
||||
assert fired.is_set()
|
||||
fired.clear()
|
||||
pin.edges = 'falling'
|
||||
pin.drive_low()
|
||||
assert not pin.state
|
||||
assert fired.wait(0)
|
||||
assert fired.is_set()
|
||||
fired.clear()
|
||||
pin.drive_high()
|
||||
assert pin.state
|
||||
assert not fired.wait(0)
|
||||
assert not fired.is_set()
|
||||
assert pin.edges == 'falling'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user