def wrapper():
            # Setup
            i = Input(INPUT_PIN)
            o = Output(OUTPUT_PIN, active_low=output_active_low)

            passed = func(i, o)

            # Teardown
            i.disable()
            o.disable()

            return passed
        def wrapper():
            # Setup
            i = Input(INPUT_PIN)
            o = Output(OUTPUT_PIN, active_low=output_active_low)

            passed = func(i, o)

            # Teardown
            i.disable()
            o.disable()

            return passed
        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 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_input():
    i = Input(INPUT_PIN)
    o = Output(OUTPUT_PIN) # default is active low!

    o.off() # HIGH
    time.sleep(MINIMUM_INPUT_PERIOD)
    high_worked = i.is_on()
    o.on() # LOW
    time.sleep(MINIMUM_INPUT_PERIOD)
    low_worked = i.is_off()

    i.disable()
    o.disable()
    return high_worked and low_worked
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
def _test_output_defaults_with_input():
    i = Input(INPUT_PIN)
    o = Output(OUTPUT_PIN)  # default is active low!

    o.off()  # HIGH
    time.sleep(MINIMUM_INPUT_PERIOD)
    high_worked = i.is_on()
    o.on()  # LOW
    time.sleep(MINIMUM_INPUT_PERIOD)
    low_worked = i.is_off()

    i.disable()
    o.disable()
    return high_worked and low_worked
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
def input_pull_test(pull, stayed_on, stayed_off, configure=False):
    for n in range(5):
        if configure:
            i = Input(INPUT_PIN)
            i.configure(pull=pull)
        else:
            i = Input(INPUT_PIN, pull=pull)
        o = Output(OUTPUT_PIN, active_low=False)
        o.on()
        o.disable()
        actually_stayed_on = i.is_on()
        o = Output(OUTPUT_PIN, active_low=False)
        o.off()
        o.disable()
        actually_stayed_off = i.is_off()
        i.disable()
        if stayed_on == actually_stayed_on and stayed_off == actually_stayed_off:
            return True
        time.sleep(0.5)
        print("FAILED, RETRYING...")
    print("TOO MANY RETRIES!")
    return False
def input_pull_test(pull, stayed_on, stayed_off, configure=False):
    for n in range(5):
        if configure:
            i = Input(INPUT_PIN)
            i.configure(pull=pull)
        else:
            i = Input(INPUT_PIN, pull=pull)
        o = Output(OUTPUT_PIN, active_low=False)
        o.on()
        o.disable()
        actually_stayed_on = i.is_on()
        o = Output(OUTPUT_PIN, active_low=False)
        o.off()
        o.disable()
        actually_stayed_off = i.is_off()
        i.disable()
        if stayed_on == actually_stayed_on and stayed_off == actually_stayed_off:
            return True
        time.sleep(0.5)
        print("FAILED, RETRYING...")
    print("TOO MANY RETRIES!")
    return False