Exemplo n.º 1
0
def test_event_detected_not_configured_for_input():
    with patch("LPi.GPIO.sysfs"):
        GPIO.setmode(GPIO.BOARD)
        GPIO.setup(23, GPIO.OUT)
        with pytest.raises(RuntimeError) as ex:
            GPIO.event_detected(23)
        assert str(ex.value) == "Channel 23 is configured for output"
Exemplo n.º 2
0
def test_event_detected():
    with patch("LPi.GPIO.sysfs"):
        GPIO.setmode(GPIO.BOARD)
        GPIO.setup(23, GPIO.IN)
        with patch("LPi.GPIO.event") as mock:
            mock.edge_detected.return_value = True
            assert GPIO.event_detected(23)