def test_wait_for_edge_not_configured_for_input(): with patch("LPi.GPIO.sysfs"): GPIO.setmode(GPIO.BOARD) GPIO.setup(12, GPIO.OUT) with pytest.raises(RuntimeError) as ex: GPIO.wait_for_edge(12, GPIO.RISING) assert str(ex.value) == "Channel 12 is configured for output"
def test_wait_for_edge_completes(): with patch("LPi.GPIO.sysfs"): GPIO.setmode(GPIO.BOARD) GPIO.setup(12, GPIO.IN) with patch("LPi.GPIO.event") as mock: mock.blocking_wait_for_edge.return_value = 1 assert GPIO.wait_for_edge(12, GPIO.BOTH) == 12 mock.blocking_wait_for_edge.assert_called_with(7, GPIO.BOTH, -1)
def test_wait_for_edge_not_configured(): with pytest.raises(RuntimeError) as ex: GPIO.wait_for_edge(91, GPIO.RISING) assert str(ex.value) == "Channel 91 is not configured"