コード例 #1
0
def test_add_event_detect_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.add_event_detect(23, GPIO.FALLING)
        assert str(ex.value) == "Channel 23 is configured for output"
コード例 #2
0
def test_add_event_detect():
    with patch("LPi.GPIO.sysfs"):
        GPIO.setmode(GPIO.BOARD)
        GPIO.setup(23, GPIO.IN)
        with patch("LPi.GPIO.event") as mock:
            GPIO.add_event_detect(23, GPIO.BOTH)
            mock.add_edge_detect.assert_called_with(14, GPIO.BOTH, None)