本文整理汇总了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)
])
示例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)
])
示例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)
])
示例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)
])
示例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)
示例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)
示例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)
示例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)
示例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)])