当前位置: 首页>>代码示例>>Python>>正文


Python MockPin.assert_states_and_times方法代码示例

本文整理汇总了Python中gpiozero.pins.mock.MockPin.assert_states_and_times方法的典型用法代码示例。如果您正苦于以下问题:Python MockPin.assert_states_and_times方法的具体用法?Python MockPin.assert_states_and_times怎么用?Python MockPin.assert_states_and_times使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gpiozero.pins.mock.MockPin的用法示例。


在下文中一共展示了MockPin.assert_states_and_times方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_output_blink_foreground

# 需要导入模块: from gpiozero.pins.mock import MockPin [as 别名]
# 或者: from gpiozero.pins.mock.MockPin import assert_states_and_times [as 别名]
def test_output_blink_foreground():
    pin = MockPin(2)
    device = DigitalOutputDevice(pin)
    device.blink(0.1, 0.1, n=2, background=False)
    pin.assert_states_and_times([
        (0.0, False),
        (0.0, True),
        (0.1, False),
        (0.1, True),
        (0.1, False)
        ])
开发者ID:DeeJay,项目名称:python-gpiozero,代码行数:13,代码来源:test_outputs.py

示例2: test_output_blink_background

# 需要导入模块: from gpiozero.pins.mock import MockPin [as 别名]
# 或者: from gpiozero.pins.mock.MockPin import assert_states_and_times [as 别名]
def test_output_blink_background():
    pin = MockPin(2)
    device = DigitalOutputDevice(pin)
    device.blink(0.1, 0.1, n=2)
    device._blink_thread.join() # naughty, but ensures no arbitrary waits in the test
    pin.assert_states_and_times([
        (0.0, False),
        (0.0, True),
        (0.1, False),
        (0.1, True),
        (0.1, False)
        ])
开发者ID:DeeJay,项目名称:python-gpiozero,代码行数:14,代码来源:test_outputs.py

示例3: test_output_blink_foreground

# 需要导入模块: from gpiozero.pins.mock import MockPin [as 别名]
# 或者: from gpiozero.pins.mock.MockPin import assert_states_and_times [as 别名]
def test_output_blink_foreground():
    pin = MockPin(2)
    with DigitalOutputDevice(pin) as device:
        start = time()
        device.blink(0.1, 0.1, n=2, background=False)
        assert isclose(time() - start, 0.4, abs_tol=0.05)
        pin.assert_states_and_times([
            (0.0, False),
            (0.0, True),
            (0.1, False),
            (0.1, True),
            (0.1, False)
            ])
开发者ID:EdwardBetts,项目名称:python-gpiozero,代码行数:15,代码来源:test_outputs.py

示例4: test_output_blink_background

# 需要导入模块: from gpiozero.pins.mock import MockPin [as 别名]
# 或者: from gpiozero.pins.mock.MockPin import assert_states_and_times [as 别名]
def test_output_blink_background():
    pin = MockPin(2)
    with DigitalOutputDevice(pin) as device:
        start = time()
        device.blink(0.1, 0.1, n=2)
        assert isclose(time() - start, 0, abs_tol=0.05)
        device._blink_thread.join() # naughty, but ensures no arbitrary waits in the test
        assert isclose(time() - start, 0.4, abs_tol=0.05)
        pin.assert_states_and_times([
            (0.0, False),
            (0.0, True),
            (0.1, False),
            (0.1, True),
            (0.1, False)
            ])
开发者ID:EdwardBetts,项目名称:python-gpiozero,代码行数:17,代码来源:test_outputs.py

示例5: test_led_board_blink_foreground

# 需要导入模块: from gpiozero.pins.mock import MockPin [as 别名]
# 或者: from gpiozero.pins.mock.MockPin import assert_states_and_times [as 别名]
def test_led_board_blink_foreground():
    pin1 = MockPin(2)
    pin2 = MockPin(3)
    pin3 = MockPin(4)
    with LEDBoard(pin1, LEDBoard(pin2, pin3)) as board:
        board.blink(0.1, 0.1, n=2, background=False)
        test = [
            (0.0, False),
            (0.0, True),
            (0.1, False),
            (0.1, True),
            (0.1, False)
            ]
        pin1.assert_states_and_times(test)
        pin2.assert_states_and_times(test)
        pin3.assert_states_and_times(test)
开发者ID:ChiangFamily,项目名称:python-gpiozero,代码行数:18,代码来源:test_boards.py

示例6: test_led_board_blink_background

# 需要导入模块: from gpiozero.pins.mock import MockPin [as 别名]
# 或者: from gpiozero.pins.mock.MockPin import assert_states_and_times [as 别名]
def test_led_board_blink_background():
    pin1 = MockPin(2)
    pin2 = MockPin(3)
    pin3 = MockPin(4)
    with LEDBoard(pin1, LEDBoard(pin2, pin3)) as board:
        board.blink(0.1, 0.1, n=2)
        board._blink_thread.join() # naughty, but ensures no arbitrary waits in the test
        test = [
            (0.0, False),
            (0.0, True),
            (0.1, False),
            (0.1, True),
            (0.1, False)
            ]
        pin1.assert_states_and_times(test)
        pin2.assert_states_and_times(test)
        pin3.assert_states_and_times(test)
开发者ID:ChiangFamily,项目名称:python-gpiozero,代码行数:19,代码来源:test_boards.py

示例7: test_led_board_blink_take_over

# 需要导入模块: from gpiozero.pins.mock import MockPin [as 别名]
# 或者: from gpiozero.pins.mock.MockPin import assert_states_and_times [as 别名]
def test_led_board_blink_take_over():
    pin1 = MockPin(2)
    pin2 = MockPin(3)
    pin3 = MockPin(4)
    with LEDBoard(pin1, LEDBoard(pin2, pin3)) as board:
        board[1].blink(0.1, 0.1, n=2)
        board.blink(0.1, 0.1, n=2) # immediately take over blinking
        board[1]._blink_thread.join()
        board._blink_thread.join()
        test = [
            (0.0, False),
            (0.0, True),
            (0.1, False),
            (0.1, True),
            (0.1, False)
            ]
        pin1.assert_states_and_times(test)
        pin2.assert_states_and_times(test)
        pin3.assert_states_and_times(test)
开发者ID:ChiangFamily,项目名称:python-gpiozero,代码行数:21,代码来源:test_boards.py

示例8: test_led_board_blink_control_all

# 需要导入模块: from gpiozero.pins.mock import MockPin [as 别名]
# 或者: from gpiozero.pins.mock.MockPin import assert_states_and_times [as 别名]
def test_led_board_blink_control_all():
    pin1 = MockPin(2)
    pin2 = MockPin(3)
    pin3 = MockPin(4)
    with LEDBoard(pin1, LEDBoard(pin2, pin3)) as board:
        board.blink(0.1, 0.1, n=2)
        # make sure the blink thread's started
        while not board._blink_leds:
            sleep(0.00001)
        board[0].off() # immediately take over all LEDs
        board[1][0].off()
        board[1][1].off()
        board._blink_thread.join() # blink should terminate here anyway
        test = [
            (0.0, False),
            (0.0, True),
            (0.0, False),
            ]
        pin1.assert_states_and_times(test)
        pin2.assert_states_and_times(test)
        pin3.assert_states_and_times(test)
开发者ID:ChiangFamily,项目名称:python-gpiozero,代码行数:23,代码来源:test_boards.py

示例9: test_led_board_blink_control

# 需要导入模块: from gpiozero.pins.mock import MockPin [as 别名]
# 或者: from gpiozero.pins.mock.MockPin import assert_states_and_times [as 别名]
def test_led_board_blink_control():
    pin1 = MockPin(2)
    pin2 = MockPin(3)
    pin3 = MockPin(4)
    with LEDBoard(pin1, LEDBoard(pin2, pin3)) as board:
        board.blink(0.1, 0.1, n=2)
        # make sure the blink thread's started
        while not board._blink_leds:
            sleep(0.00001)
        board[1][0].off() # immediately take over the second LED
        board._blink_thread.join() # naughty, but ensures no arbitrary waits in the test
        test = [
            (0.0, False),
            (0.0, True),
            (0.1, False),
            (0.1, True),
            (0.1, False)
            ]
        pin1.assert_states_and_times(test)
        pin3.assert_states_and_times(test)
        print(pin2.states)
        pin2.assert_states_and_times([(0.0, False), (0.0, True), (0.0, False)])
开发者ID:ChiangFamily,项目名称:python-gpiozero,代码行数:24,代码来源:test_boards.py


注:本文中的gpiozero.pins.mock.MockPin.assert_states_and_times方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。