Exemple #1
0
def test_custom_object():
    class mapper(object):
        def __getitem__(self, value):
            return value + 4

    set_custom_pin_mappings(mapper())
    assert custom(1) == 5
    assert custom(2) == 6
    assert custom(3) == 7
Exemple #2
0
def setmode(mode):
    """
    You must call this method prior to using all other calls.

    :param mode: the mode, one of :py:attr:`GPIO.BOARD`, :py:attr:`GPIO.BCM`,
        :py:attr:`GPIO.SUNXI`, or a `dict` or `object` representing a custom
        pin mapping.
    """
    if hasattr(mode, '__getitem__'):
        set_custom_pin_mappings(mode)
        mode = CUSTOM

    assert mode in [BCM, BOARD, SUNXI, CUSTOM]
    global _mode
    _mode = mode
Exemple #3
0
def test_custom_dict():
    set_custom_pin_mappings({1: 2, 2: 3, 3: 4})
    assert custom(1) == 2
    assert custom(2) == 3
    assert custom(3) == 4