def test_can_use_context_manager_with_pin_already_exported(self): Pin(25).export() self.test_can_automatically_unexport_pin_with_context_manager()
def test_can_use_context_manager_with_pin_exported_by_constructor(self): with exported(Pin(25, Pin.Out)) as p: assert p.is_exported p = Pin(25) assert not p.is_exported
def test_can_automatically_unexport_pin_with_context_manager(self): with exported(Pin(25)) as p: assert p.is_exported p = Pin(25) assert not p.is_exported
def setup_method(self, method): self.pin = Pin(25)
def test_can_export_pin_and_set_direction_on_construction(self): p = Pin(25, Pin.Out) assert p.is_exported assert p.direction == Pin.Out
from quick2wire.gpio import Pin from time import sleep import pytest Pins = [Pin(header_pin_number) for header_pin_number in [11, 12, 13, 15, 16, 18, 22, 7]] def setup_module(): for pin in Pins: pin.export() def teardown_module(): for pin in Pins: if pin.is_exported: pin.unexport() @pytest.mark.loopback def test_gpio_loopback(): assert_outputs_seen_at_corresponding_inputs(Pins[:4], Pins[4:]) assert_outputs_seen_at_corresponding_inputs(Pins[4:], Pins[:4]) def assert_outputs_seen_at_corresponding_inputs(outputs, inputs): for (op, ip) in zip(outputs, inputs): assert_output_seen_at_input(op, ip) def assert_output_seen_at_input(output_pin, input_pin): output_pin.direction = Pin.Out input_pin.direction = Pin.In