@@ -22,35 +22,35 @@ class CopyRegTest(unittest.TestCase):
2222 def test_constructor_neg (self ):
2323 'https://github.com/IronLanguages/main/issues/443'
2424 class KOld : pass
25-
25+
2626 self .assertRaises (TypeError , copyreg .constructor , KOld )
2727
28-
28+
2929 def test_constructor (self ):
3030 #the argument can be callable
3131 copyreg .constructor (testclass )
32-
32+
3333 #the argument can not be callable
3434 self .assertRaises (TypeError ,copyreg .constructor ,0 )
3535 self .assertRaises (TypeError ,copyreg .constructor ,"Hello" )
3636 self .assertRaises (TypeError ,copyreg .constructor ,True )
3737
3838
3939 def test__newobj__ (self ):
40-
40+
4141 #the second argument is omitted
4242 result = None
4343 result = copyreg .__newobj__ (object )
4444 self .assertTrue (result != None ,
4545 "The method __newobj__ did not return an object" )
46-
46+
4747 #the second argument is an int object
4848 result = None
4949 a = 1
5050 result = copyreg .__newobj__ (int ,a )
5151 self .assertTrue (result != None ,
5252 "The method __newobj__ did not return an object" )
53-
53+
5454 #the method accept multiple arguments
5555 reseult = None
5656 class customtype (object ):
@@ -121,27 +121,27 @@ def test_extension_registry(self):
121121 code = result [key ]
122122 self .assertTrue (code == 123 ,
123123 "The _extension_registry attribute did not return the correct value" )
124-
124+
125125 copyreg .add_extension ('1' ,'2' ,999 )
126126 result = copyreg ._extension_registry
127127 code = result [('1' ,'2' )]
128128 self .assertTrue (code == 999 ,
129129 "The _extension_registry attribute did not return the correct value" )
130-
130+
131131 #general test, try to set the attribute then to get it
132132 myvalue = 3885
133133 copyreg ._extension_registry ["key" ] = myvalue
134134 result = copyreg ._extension_registry ["key" ]
135135 self .assertTrue (result == myvalue ,
136136 "The set or the get of the attribute failed" )
137-
137+
138138 def test_inverted_registry (self ):
139139 copyreg .add_extension ('obj1' ,'obj2' ,64 )
140140 #get
141141 result = copyreg ._inverted_registry [64 ]
142142 self .assertTrue (result == ('obj1' ,'obj2' ),
143143 "The _inverted_registry attribute did not return the correct value" )
144-
144+
145145 #set
146146 value = ('newmodule' ,'newobj' )
147147 copyreg ._inverted_registry [10001 ] = value
@@ -158,7 +158,7 @@ def test_extension_cache(self):
158158 result = copyreg ._extension_cache ['cache1' ]
159159 self .assertTrue (result == value ,
160160 "The get and set of the attribute failed" )
161-
161+
162162 value = rand .getrandbits (16 )
163163 copyreg ._extension_cache ['cache2' ] = value
164164 result = copyreg ._extension_cache ['cache2' ]
@@ -171,18 +171,18 @@ def test_extension_cache(self):
171171 result = copyreg ._extension_cache ['cache1' ]
172172 self .assertTrue (result == value2 ,
173173 "The get and set of the attribute failed" )
174-
174+
175175 if 'cache1' not in copyreg ._extension_cache or 'cache2' not in copyreg ._extension_cache :
176176 Fail ("Set of the attribute failed" )
177-
177+
178178 copyreg .clear_extension_cache ()
179179 if 'cache1' in copyreg ._extension_cache or 'cache2' in copyreg ._extension_cache :
180180 Fail ("The method clear_extension_cache did not work correctly " )
181181
182182 def test_reconstructor (self ):
183183 reconstructor_copy = copyreg ._reconstructor
184184 try :
185- obj = copyreg ._reconstructor (object , object , None )
185+ obj = copyreg ._reconstructor (object , object , None )
186186 self .assertTrue (type (obj ) is object )
187187
188188 #set,get, the value is a random int
@@ -192,82 +192,81 @@ def test_reconstructor(self):
192192 result = copyreg ._reconstructor
193193 self .assertTrue (result == value ,
194194 "set or get of the attribute failed!" )
195-
195+
196196 #the value is a string
197197 value2 = "value2"
198198 copyreg ._reconstructor = value2
199199 result = copyreg ._reconstructor
200200 self .assertTrue (result == value2 ,
201201 "set or get of the attribute failed!" )
202-
202+
203203 #the value is a custom type object
204204 value3 = testclass ()
205205 copyreg ._reconstructor = value3
206206 result = copyreg ._reconstructor
207207 self .assertTrue (result == value3 ,
208208 "set or get of the attribute failed!" )
209- finally :
209+ finally :
210210 copyreg ._reconstructor = reconstructor_copy
211-
211+
212212
213213 def test_pickle (self ):
214214 def testfun ():
215215 return testclass ()
216-
216+
217217 # type is a custom type
218218 copyreg .pickle (type (testclass ), testfun )
219-
219+
220220 #type is a system type
221221 systype = type (random .Random ())
222222 copyreg .pickle (systype ,random .Random .random )
223-
223+
224224 #function is not callable
225225 func = "hello"
226226 self .assertRaises (TypeError ,copyreg .pickle ,testclass ,func )
227227 func = 1
228228 self .assertRaises (TypeError ,copyreg .pickle ,testclass ,func )
229229 func = random .Random ()
230230 self .assertRaises (TypeError ,copyreg .pickle ,testclass ,func )
231-
231+
232232 def test_dispatch_table (self ):
233233 result = copyreg .dispatch_table
234234 #CodePlex Work Item 8522
235235 #self.assertEqual(5,len(result))
236-
236+
237237 temp = {
238238 "abc" :"abc123" ,
239239 "def" :"def123" ,
240240 "ghi" :"ghi123"
241241 }
242242 copyreg .dispatch_table = temp
243243 self .assertEqual (temp ,copyreg .dispatch_table )
244-
244+
245245 temp = {
246246 1 :"abc123" ,
247247 2 :"def123" ,
248248 3 :"ghi123"
249249 }
250250 copyreg .dispatch_table = temp
251251 self .assertEqual (temp ,copyreg .dispatch_table )
252-
252+
253253 temp = {
254254 1 :123 ,
255255 8 :789 ,
256256 16 :45465
257257 }
258258 copyreg .dispatch_table = temp
259259 self .assertEqual (temp ,copyreg .dispatch_table )
260-
260+
261261 #set dispathc_table as empty
262262 temp = {}
263263 copyreg .dispatch_table = temp
264264 self .assertEqual (temp ,copyreg .dispatch_table )
265265
266266 def test_pickle_complex (self ):
267267 #http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=21908
268- #if not is_cli:
269268 self .assertEqual (copyreg .pickle_complex (1 ), (complex , (1 , 0 )))
270-
269+
271270 #negative tests
272271 self .assertRaises (AttributeError ,copyreg .pickle_complex ,"myargu" )
273272 obj2 = myCustom2 ()
0 commit comments