@@ -33,36 +33,36 @@ class DerivedStr(str):
3333 pass
3434
3535
36- NamedTuple = namedtuple (' NamedTuple' , ['x' , 'y' ])
36+ NamedTuple = namedtuple (" NamedTuple" , ["x" , "y" ])
3737
3838
3939class TestToStr (unittest .TestCase ):
4040 def test_new_type_float (self ):
41- self .assertEqual (tostr (0.5 ), ' 0.5' )
41+ self .assertEqual (tostr (0.5 ), " 0.5" )
4242 self .assertIs (tostr .handlers [float ], tostr .handlers [None ])
4343
4444 def test_new_type_int (self ):
45- self .assertEqual (tostr (0 ), '0' )
45+ self .assertEqual (tostr (0 ), "0" )
4646 self .assertIs (tostr .handlers [int ], tostr .handlers [None ])
4747
4848 def test_new_type_str (self ):
49- self .assertEqual (tostr (DerivedStr (1 )), '1' )
49+ self .assertEqual (tostr (DerivedStr (1 )), "1" )
5050 self .assertIs (tostr .handlers [DerivedStr ], tostr .handlers [str ])
5151
5252 def test_new_type_list (self ):
53- self .assertEqual (tostr (DerivedList ([1 , 2 ])), ' [1, 2]' )
53+ self .assertEqual (tostr (DerivedList ([1 , 2 ])), " [1, 2]" )
5454 self .assertIs (tostr .handlers [DerivedList ], tostr .handlers [list ])
5555
5656 def test_new_type_dict (self ):
57- self .assertEqual (tostr (DerivedDict ({1 : 2 })), ' {1: 2}' )
57+ self .assertEqual (tostr (DerivedDict ({1 : 2 })), " {1: 2}" )
5858 self .assertIs (tostr .handlers [DerivedDict ], tostr .handlers [dict ])
5959
6060 def test_new_type_tuple (self ):
61- self .assertEqual (tostr (DerivedTuple ([1 , 2 ])), ' (1, 2)' )
61+ self .assertEqual (tostr (DerivedTuple ([1 , 2 ])), " (1, 2)" )
6262 self .assertIs (tostr .handlers [DerivedTuple ], tostr .handlers [tuple ])
6363
6464 def test_new_type_namedtuple (self ):
65- self .assertEqual (tostr (NamedTuple (1 , 2 )), ' NamedTuple(x=1, y=2)' )
65+ self .assertEqual (tostr (NamedTuple (1 , 2 )), " NamedTuple(x=1, y=2)" )
6666 self .assertIs (tostr .handlers [NamedTuple ], tostr .handlers [None ])
6767
6868
@@ -73,7 +73,7 @@ def test_unicode_table(self):
7373 os = StringIO ()
7474 data = {1 : ("a" , 1 ), (2 , 3 ): ("∧" , 2 )}
7575 tabular_writer (os , "" , data .items (), ["s" , "val" ], lambda k , v : v )
76- ref = u """
76+ ref = """
7777Key : s : val
7878 1 : a : 1
7979(2, 3) : ∧ : 2
@@ -82,9 +82,9 @@ def test_unicode_table(self):
8282
8383 def test_tuple_list_dict (self ):
8484 os = StringIO ()
85- data = {(1 ,): (["a" , 1 ], 1 ), ('2' , 3 ): ({1 : 'a' , 2 : '2' }, '2' )}
85+ data = {(1 ,): (["a" , 1 ], 1 ), ("2" , 3 ): ({1 : "a" , 2 : "2" }, "2" )}
8686 tabular_writer (os , "" , data .items (), ["s" , "val" ], lambda k , v : v )
87- ref = u """
87+ ref = """
8888Key : s : val
8989 (1,) : ['a', 1] : 1
9090('2', 3) : {1: 'a', 2: '2'} : 2
@@ -93,9 +93,9 @@ def test_tuple_list_dict(self):
9393
9494 def test_no_header (self ):
9595 os = StringIO ()
96- data = {(2 ,): (["a" , 1 ], 1 ), (1 , 3 ): ({1 : 'a' , 2 : '2' }, '2' )}
96+ data = {(2 ,): (["a" , 1 ], 1 ), (1 , 3 ): ({1 : "a" , 2 : "2" }, "2" )}
9797 tabular_writer (os , "" , data .items (), [], lambda k , v : v )
98- ref = u """
98+ ref = """
9999{1: 'a', 2: '2'} : 2
100100 ['a', 1] : 1
101101"""
@@ -104,22 +104,22 @@ def test_no_header(self):
104104 def test_no_data (self ):
105105 os = StringIO ()
106106 data = {}
107- tabular_writer (os , "" , data .items (), ['s' , ' val' ], lambda k , v : v )
108- ref = u """
107+ tabular_writer (os , "" , data .items (), ["s" , " val" ], lambda k , v : v )
108+ ref = """
109109Key : s : val
110110"""
111111 self .assertEqual (ref .strip (), os .getvalue ().strip ())
112112
113113 def test_multiline_generator (self ):
114114 os = StringIO ()
115- data = {'a' : 0 , 'b' : 1 , 'c' : 3 }
115+ data = {"a" : 0 , "b" : 1 , "c" : 3 }
116116
117117 def _data_gen (i , j ):
118118 for n in range (j ):
119- yield (n , chr (ord ('a' ) + n ) * j )
119+ yield (n , chr (ord ("a" ) + n ) * j )
120120
121- tabular_writer (os , "" , data .items (), ['i' , 'j' ], _data_gen )
122- ref = u """
121+ tabular_writer (os , "" , data .items (), ["i" , "j" ], _data_gen )
122+ ref = """
123123Key : i : j
124124 a : None : None
125125 b : 0 : a
@@ -150,16 +150,16 @@ def _data_gen(i, j):
150150
151151 def test_multiline_generator_exception (self ):
152152 os = StringIO ()
153- data = {'a' : 0 , 'b' : 1 , 'c' : 3 }
153+ data = {"a" : 0 , "b" : 1 , "c" : 3 }
154154
155155 def _data_gen (i , j ):
156- if i == 'b' :
156+ if i == "b" :
157157 raise ValueError ("invalid" )
158158 for n in range (j ):
159- yield (n , chr (ord ('a' ) + n ) * j )
159+ yield (n , chr (ord ("a" ) + n ) * j )
160160
161- tabular_writer (os , "" , data .items (), ['i' , 'j' ], _data_gen )
162- ref = u """
161+ tabular_writer (os , "" , data .items (), ["i" , "j" ], _data_gen )
162+ ref = """
163163Key : i : j
164164 a : None : None
165165 b : None : None
@@ -171,15 +171,15 @@ def _data_gen(i, j):
171171
172172 def test_data_exception (self ):
173173 os = StringIO ()
174- data = {'a' : 0 , 'b' : 1 , 'c' : 3 }
174+ data = {"a" : 0 , "b" : 1 , "c" : 3 }
175175
176176 def _data_gen (i , j ):
177- if i == 'b' :
177+ if i == "b" :
178178 raise ValueError ("invalid" )
179179 return (j , i * (j + 1 ))
180180
181- tabular_writer (os , "" , data .items (), ['i' , 'j' ], _data_gen )
182- ref = u """
181+ tabular_writer (os , "" , data .items (), ["i" , "j" ], _data_gen )
182+ ref = """
183183Key : i : j
184184 a : 0 : a
185185 b : None : None
@@ -189,19 +189,19 @@ def _data_gen(i, j):
189189
190190 def test_multiline_alignment (self ):
191191 os = StringIO ()
192- data = {'a' : 1 , 'b' : 2 , 'c' : 3 }
192+ data = {"a" : 1 , "b" : 2 , "c" : 3 }
193193
194194 def _data_gen (i , j ):
195195 for n in range (j ):
196- _str = chr (ord ('a' ) + n ) * (j + 1 )
196+ _str = chr (ord ("a" ) + n ) * (j + 1 )
197197 if n % 2 :
198198 _str = list (_str )
199- _str [1 ] = ' '
200- _str = '' .join (_str )
199+ _str [1 ] = " "
200+ _str = "" .join (_str )
201201 yield (n , _str )
202202
203- tabular_writer (os , "" , data .items (), ['i' , 'j' ], _data_gen )
204- ref = u """
203+ tabular_writer (os , "" , data .items (), ["i" , "j" ], _data_gen )
204+ ref = """
205205Key : i : j
206206 a : 0 : aa
207207 b : 0 : aaa
@@ -217,24 +217,24 @@ class TestStreamIndenter(unittest.TestCase):
217217 def test_noprefix (self ):
218218 OUT1 = StringIO ()
219219 OUT2 = StreamIndenter (OUT1 )
220- OUT2 .write (' Hello?\n Hello, world!' )
221- self .assertEqual (' Hello?\n Hello, world!' , OUT2 .getvalue ())
220+ OUT2 .write (" Hello?\n Hello, world!" )
221+ self .assertEqual (" Hello?\n Hello, world!" , OUT2 .getvalue ())
222222
223223 def test_prefix (self ):
224- prefix = ' foo:'
224+ prefix = " foo:"
225225 OUT1 = StringIO ()
226226 OUT2 = StreamIndenter (OUT1 , prefix )
227- OUT2 .write (' Hello?\n Hello, world!' )
228- self .assertEqual (' foo:Hello?\n foo:Hello, world!' , OUT2 .getvalue ())
227+ OUT2 .write (" Hello?\n Hello, world!" )
228+ self .assertEqual (" foo:Hello?\n foo:Hello, world!" , OUT2 .getvalue ())
229229
230230 def test_blank_lines (self ):
231231 OUT1 = StringIO ()
232232 OUT2 = StreamIndenter (OUT1 )
233- OUT2 .write (' Hello?\n \n Text\n \n Hello, world!' )
234- self .assertEqual (' Hello?\n \n Text\n \n Hello, world!' , OUT2 .getvalue ())
233+ OUT2 .write (" Hello?\n \n Text\n \n Hello, world!" )
234+ self .assertEqual (" Hello?\n \n Text\n \n Hello, world!" , OUT2 .getvalue ())
235235
236236 def test_writelines (self ):
237237 OUT1 = StringIO ()
238238 OUT2 = StreamIndenter (OUT1 )
239- OUT2 .writelines ([' Hello?\n ' , ' \n ' , ' Text\n ' , ' \n ' , ' Hello, world!' ])
240- self .assertEqual (' Hello?\n \n Text\n \n Hello, world!' , OUT2 .getvalue ())
239+ OUT2 .writelines ([" Hello?\n " , " \n " , " Text\n " , " \n " , " Hello, world!" ])
240+ self .assertEqual (" Hello?\n \n Text\n \n Hello, world!" , OUT2 .getvalue ())
0 commit comments