@@ -11,10 +11,10 @@ def test_iterable_of_iterables():
11
11
"Input: an interable of iterables."
12
12
ii = iter (map (lambda x : iter (x ), [range (5 ), range (5 ,0 ,- 1 )]))
13
13
expected = "\n " .join (
14
- [u '- - - - -' ,
15
- u '0 1 2 3 4' ,
16
- u '5 4 3 2 1' ,
17
- u '- - - - -' ])
14
+ ['- - - - -' ,
15
+ '0 1 2 3 4' ,
16
+ '5 4 3 2 1' ,
17
+ '- - - - -' ])
18
18
result = tabulate (ii )
19
19
print ("Expected:\n %s\n " % expected )
20
20
print ("Got:\n %s\n " % result )
@@ -25,10 +25,10 @@ def test_iterable_of_iterables_headers():
25
25
"Input: an interable of iterables with headers."
26
26
ii = iter (map (lambda x : iter (x ), [range (5 ), range (5 ,0 ,- 1 )]))
27
27
expected = "\n " .join (
28
- [u ' a b c d e' ,
29
- u '--- --- --- --- ---' ,
30
- u ' 0 1 2 3 4' ,
31
- u ' 5 4 3 2 1' ])
28
+ [' a b c d e' ,
29
+ '--- --- --- --- ---' ,
30
+ ' 0 1 2 3 4' ,
31
+ ' 5 4 3 2 1' ])
32
32
result = tabulate (ii , "abcde" )
33
33
print ("Expected:\n %s\n " % expected )
34
34
print ("Got:\n %s\n " % result )
@@ -39,10 +39,10 @@ def test_iterable_of_iterables_firstrow():
39
39
"Input: an interable of iterables with the first row as headers"
40
40
ii = iter (map (lambda x : iter (x ), ["abcde" , range (5 ), range (5 ,0 ,- 1 )]))
41
41
expected = "\n " .join (
42
- [u ' a b c d e' ,
43
- u '--- --- --- --- ---' ,
44
- u ' 0 1 2 3 4' ,
45
- u ' 5 4 3 2 1' ])
42
+ [' a b c d e' ,
43
+ '--- --- --- --- ---' ,
44
+ ' 0 1 2 3 4' ,
45
+ ' 5 4 3 2 1' ])
46
46
result = tabulate (ii , "firstrow" )
47
47
print ("Expected:\n %s\n " % expected )
48
48
print ("Got:\n %s\n " % result )
@@ -53,10 +53,10 @@ def test_list_of_lists():
53
53
"Input: a list of lists with headers."
54
54
ll = [["a" ,"one" ,1 ],["b" ,"two" ,None ]]
55
55
expected = "\n " .join ([
56
- u ' string number' ,
57
- u '-- -------- --------' ,
58
- u 'a one 1' ,
59
- u 'b two' ])
56
+ ' string number' ,
57
+ '-- -------- --------' ,
58
+ 'a one 1' ,
59
+ 'b two' ])
60
60
result = tabulate (ll , headers = ["string" ,"number" ])
61
61
print ("Expected:\n %s\n " % expected )
62
62
print ("Got:\n %s\n " % result )
@@ -67,10 +67,10 @@ def test_list_of_lists_firstrow():
67
67
"Input: a list of lists with the first row as headers."
68
68
ll = [["string" ,"number" ],["a" ,"one" ,1 ],["b" ,"two" ,None ]]
69
69
expected = "\n " .join ([
70
- u ' string number' ,
71
- u '-- -------- --------' ,
72
- u 'a one 1' ,
73
- u 'b two' ])
70
+ ' string number' ,
71
+ '-- -------- --------' ,
72
+ 'a one 1' ,
73
+ 'b two' ])
74
74
result = tabulate (ll , headers = "firstrow" )
75
75
print ("Expected:\n %s\n " % expected )
76
76
print ("Got:\n %s\n " % result )
@@ -81,10 +81,10 @@ def test_list_of_lists_keys():
81
81
"Input: a list of lists with column indices as headers."
82
82
ll = [["a" ,"one" ,1 ],["b" ,"two" ,None ]]
83
83
expected = "\n " .join ([
84
- u '0 1 2' ,
85
- u '--- --- ---' ,
86
- u 'a one 1' ,
87
- u 'b two' ])
84
+ '0 1 2' ,
85
+ '--- --- ---' ,
86
+ 'a one 1' ,
87
+ 'b two' ])
88
88
result = tabulate (ll , headers = "keys" )
89
89
print ("Expected:\n %s\n " % expected )
90
90
print ("Got:\n %s\n " % result )
@@ -98,19 +98,19 @@ def test_dict_like():
98
98
# keys' order (hence columns' order) is not deterministic in Python 3
99
99
# => we have to consider both possible results as valid
100
100
expected1 = "\n " .join ([
101
- u ' a b' ,
102
- u '--- ---' ,
103
- u ' 0 101' ,
104
- u ' 1 102' ,
105
- u ' 2 103' ,
106
- u ' 104' ])
101
+ ' a b' ,
102
+ '--- ---' ,
103
+ ' 0 101' ,
104
+ ' 1 102' ,
105
+ ' 2 103' ,
106
+ ' 104' ])
107
107
expected2 = "\n " .join ([
108
- u ' b a' ,
109
- u '--- ---' ,
110
- u '101 0' ,
111
- u '102 1' ,
112
- u '103 2' ,
113
- u '104' ])
108
+ ' b a' ,
109
+ '--- ---' ,
110
+ '101 0' ,
111
+ '102 1' ,
112
+ '103 2' ,
113
+ '104' ])
114
114
result = tabulate (dd , "keys" )
115
115
print ("Keys' order: %s" % dd .keys ())
116
116
print ("Expected 1:\n %s\n " % expected1 )
@@ -125,11 +125,11 @@ def test_numpy_2d():
125
125
import numpy
126
126
na = (numpy .arange (1 ,10 , dtype = numpy .float32 ).reshape ((3 ,3 ))** 3 )* 0.5
127
127
expected = "\n " .join ([
128
- u ' a b c' ,
129
- u '----- ----- -----' ,
130
- u ' 0.5 4 13.5' ,
131
- u ' 32 62.5 108' ,
132
- u '171.5 256 364.5' ])
128
+ ' a b c' ,
129
+ '----- ----- -----' ,
130
+ ' 0.5 4 13.5' ,
131
+ ' 32 62.5 108' ,
132
+ '171.5 256 364.5' ])
133
133
result = tabulate (na , ["a" , "b" , "c" ])
134
134
print ("Expected:\n %s\n " % expected )
135
135
print ("Got:\n %s\n " % result )
@@ -145,10 +145,10 @@ def test_numpy_2d_firstrow():
145
145
import numpy
146
146
na = (numpy .arange (1 ,10 , dtype = numpy .int32 ).reshape ((3 ,3 ))** 3 )
147
147
expected = "\n " .join ([
148
- u ' 1 8 27' ,
149
- u '--- --- ----' ,
150
- u ' 64 125 216' ,
151
- u '343 512 729' ])
148
+ ' 1 8 27' ,
149
+ '--- --- ----' ,
150
+ ' 64 125 216' ,
151
+ '343 512 729' ])
152
152
result = tabulate (na , headers = "firstrow" )
153
153
print ("Expected:\n %s\n " % expected )
154
154
print ("Got:\n %r\n " % result )
@@ -164,11 +164,11 @@ def test_numpy_2d_keys():
164
164
import numpy
165
165
na = (numpy .arange (1 ,10 , dtype = numpy .float32 ).reshape ((3 ,3 ))** 3 )* 0.5
166
166
expected = "\n " .join ([
167
- u ' 0 1 2' ,
168
- u '----- ----- -----' ,
169
- u ' 0.5 4 13.5' ,
170
- u ' 32 62.5 108' ,
171
- u '171.5 256 364.5' ])
167
+ ' 0 1 2' ,
168
+ '----- ----- -----' ,
169
+ ' 0.5 4 13.5' ,
170
+ ' 32 62.5 108' ,
171
+ '171.5 256 364.5' ])
172
172
result = tabulate (na , headers = "keys" )
173
173
print ("Expected:\n %s\n " % expected )
174
174
print ("Got:\n %s\n " % result )
@@ -250,10 +250,10 @@ def test_pandas():
250
250
import pandas
251
251
df = pandas .DataFrame ([["one" ,1 ],["two" ,None ]], index = ["a" ,"b" ])
252
252
expected = "\n " .join ([
253
- u ' string number' ,
254
- u '-- -------- --------' ,
255
- u 'a one 1' ,
256
- u 'b two nan' ])
253
+ ' string number' ,
254
+ '-- -------- --------' ,
255
+ 'a one 1' ,
256
+ 'b two nan' ])
257
257
result = tabulate (df , headers = ["string" , "number" ])
258
258
print ("Expected:\n %s\n " % expected )
259
259
print ("Got:\n %s\n " % result )
@@ -271,9 +271,9 @@ def test_pandas_firstrow():
271
271
columns = ["string" ,"number" ],
272
272
index = ["a" ,"b" ])
273
273
expected = "\n " .join ([
274
- u 'a one 1.0' ,
275
- u '--- ----- -----' ,
276
- u 'b two nan' ])
274
+ 'a one 1.0' ,
275
+ '--- ----- -----' ,
276
+ 'b two nan' ])
277
277
result = tabulate (df , headers = "firstrow" )
278
278
print ("Expected:\n %s\n " % expected )
279
279
print ("Got:\n %s\n " % result )
@@ -291,10 +291,10 @@ def test_pandas_keys():
291
291
columns = ["string" ,"number" ],
292
292
index = ["a" ,"b" ])
293
293
expected = "\n " .join (
294
- [u ' string number' ,
295
- u '-- -------- --------' ,
296
- u 'a one 1' ,
297
- u 'b two nan' ])
294
+ [' string number' ,
295
+ '-- -------- --------' ,
296
+ 'a one 1' ,
297
+ 'b two nan' ])
298
298
result = tabulate (df , headers = "keys" )
299
299
print ("Expected:\n %s\n " % expected )
300
300
print ("Got:\n %s\n " % result )
@@ -309,11 +309,11 @@ def test_list_of_namedtuples():
309
309
from collections import namedtuple
310
310
NT = namedtuple ("NT" , ['foo' , 'bar' ])
311
311
lt = [NT (1 ,2 ), NT (3 ,4 )]
312
- expected = u "\n " .join ([
313
- u '- -' ,
314
- u '1 2' ,
315
- u '3 4' ,
316
- u '- -' ])
312
+ expected = "\n " .join ([
313
+ '- -' ,
314
+ '1 2' ,
315
+ '3 4' ,
316
+ '- -' ])
317
317
result = tabulate (lt )
318
318
print ("Expected:\n %s\n " % expected )
319
319
print ("Got:\n %s\n " % result )
@@ -325,11 +325,11 @@ def test_list_of_namedtuples_keys():
325
325
from collections import namedtuple
326
326
NT = namedtuple ("NT" , ['foo' , 'bar' ])
327
327
lt = [NT (1 ,2 ), NT (3 ,4 )]
328
- expected = u "\n " .join ([
329
- u ' foo bar' ,
330
- u '----- -----' ,
331
- u ' 1 2' ,
332
- u ' 3 4' ])
328
+ expected = "\n " .join ([
329
+ ' foo bar' ,
330
+ '----- -----' ,
331
+ ' 1 2' ,
332
+ ' 3 4' ])
333
333
result = tabulate (lt , headers = "keys" )
334
334
print ("Expected:\n %s\n " % expected )
335
335
print ("Got:\n %s\n " % result )
0 commit comments