def button_recreation(): # Recreate button pin several times and verify for i in range(5): button_in = Button(INPUT_PIN) button_out = Button(OUTPUT_PIN) button_in.disable() button_out.disable() return _test_output_defaults_with_button()
def wrapper(): # Setup b = Button(INPUT_PIN) o = Output(OUTPUT_PIN, active_low=output_active_low) passed = func(b, o) # Teardown b.disable() o.disable() return passed
def _test_output_defaults_with_button(): b = Button(INPUT_PIN) o = Output(OUTPUT_PIN) # default is active low! o.off() # HIGH time.sleep(MINIMUM_BUTTON_PRESS_PERIOD) released_worked = b.is_released() # Released button is HIGH o.on() # LOW time.sleep(MINIMUM_BUTTON_PRESS_PERIOD) pressed_worked = b.is_pressed() # PRESSED button is LOW b.disable() o.disable() return released_worked and pressed_worked