-
Notifications
You must be signed in to change notification settings - Fork 968
/
Copy pathcolumnize_test.py
79 lines (65 loc) · 1.67 KB
/
columnize_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
from columnize import columnize
def test_columnize_8_in_2():
sequence = 'ABCDEFGH'
expected = [
('A', 'E'),
('B', 'F'),
('C', 'G'),
('D', 'H'),
]
result = columnize(sequence, 2)
assert expected == result
def test_columnize_8_in_4():
sequence = 'ABCDEFGH'
expected = [
('A', 'C', 'E', 'G'),
('B', 'D', 'F', 'H'),
]
result = columnize(sequence, 4)
assert expected == result
def test_columnize_7_in_2():
sequence = 'ABCDEFG'
expected = [
('A', 'E'),
('B', 'F'),
('C', 'G'),
('D',),
]
result = columnize(sequence, 2)
assert expected == result
def test_columnize_8_in_3():
sequence = 'ABCDEFGH'
expected = [
('A', 'D', 'G',),
('B', 'E', 'H',),
('C', 'F'),
]
result = columnize(sequence, 3)
assert expected == result
def test_columnize_8_in_5():
# Not the right number of columns, but the right number of rows.
# This actually looks better, so it's OK!
sequence = 'ABCDEFGH'
expected = [
('A', 'C', 'E', 'G'),
('B', 'D', 'F', 'H'),
]
result = columnize(sequence, 5)
assert expected == result
def test_columnize_7_in_5():
# Not the right number of columns, but the right number of rows.
# This actually looks better, so it's OK!
sequence = 'ABCDEFG'
expected = [
('A', 'C', 'E', 'G'),
('B', 'D', 'F'),
]
result = columnize(sequence, 5)
assert expected == result
def test_columnize_not_enough_items():
sequence = 'AB'
expected = [
('A', 'B'),
]
result = columnize(sequence, 3)
assert expected == result