Beispiel #1
0
def test_pprint_missing_pin():
    header = HeaderInfo(
        'FOO',
        4,
        2,
        {
            1: PinInfo(1, '5V', False, 1, 1),
            2: PinInfo(2, 'GND', False, 1, 2),
            # Pin 3 is deliberately missing
            4: PinInfo(4, 'GPIO1', False, 2, 2),
            5: PinInfo(5, 'GPIO2', False, 3, 1),
            6: PinInfo(6, 'GPIO3', False, 3, 2),
            7: PinInfo(7, '3V3', False, 4, 1),
            8: PinInfo(8, 'GND', False, 4, 2),
        })
    with mock.patch('sys.stdout') as stdout:
        stdout.output = []
        stdout.write = lambda buf: stdout.output.append(buf)
        s = ''.join(stdout.output)
        header.pprint()
        for i in range(1, 9):
            if i == 3:
                assert '(3)' not in s
            else:
                assert '({i:d})'.format(i=i)
def test_pprint_missing_pin():
    header = HeaderInfo('FOO', 4, 2, {
        1: PinInfo(1, '5V',    False, 1, 1),
        2: PinInfo(2, 'GND',   False, 1, 2),
        # Pin 3 is deliberately missing
        4: PinInfo(4, 'GPIO1', False, 2, 2),
        5: PinInfo(5, 'GPIO2', False, 3, 1),
        6: PinInfo(6, 'GPIO3', False, 3, 2),
        7: PinInfo(7, '3V3',   False, 4, 1),
        8: PinInfo(8, 'GND',   False, 4, 2),
        })
    with patch('sys.stdout') as stdout:
        stdout.output = []
        stdout.write = lambda buf: stdout.output.append(buf)
        s = ''.join(stdout.output)
        header.pprint()
        for i in range(1, 9):
            if i == 3:
                assert '(3)' not in s
            else:
                assert ('(%d)' % i)