@@ -221,35 +221,32 @@ def test_placeholders(self):
221221 # 1 Placeholder
222222 args = (PH , 0 )
223223 p = self .partial (capture , * args )
224- got , empty = p ('x' )
225- self .assertEqual (('x' , 0 ), got )
226- self .assertEqual (empty , {})
224+ actual_args , actual_kwds = p ('x' )
225+ self .assertEqual (actual_args , ('x' , 0 ))
226+ self .assertEqual (actual_kwds , {})
227227 # 2 Placeholders
228228 args = (PH , 0 , PH , 1 )
229229 p = self .partial (capture , * args )
230230 with self .assertRaises (TypeError ):
231231 p ('x' )
232- got , empty = p ('x' , 'y' )
233- expected = ('x' , 0 , 'y' , 1 )
234- self .assertEqual (expected , got )
235- self .assertEqual (empty , {})
232+ actual_args , actual_kwds = p ('x' , 'y' )
233+ self .assertEqual (actual_args , ('x' , 0 , 'y' , 1 ))
234+ self .assertEqual (actual_kwds , {})
236235
237236 def test_placeholders_optimization (self ):
238237 PH = self .module .Placeholder
239238 p = self .partial (capture , PH , 0 )
240239 p2 = self .partial (p , PH , 1 , 2 , 3 )
241- expected = (PH , 0 , 1 , 2 , 3 )
242- self .assertEqual (expected , p2 .args )
240+ self .assertEqual (p2 .args , (PH , 0 , 1 , 2 , 3 ))
243241 p3 = self .partial (p2 , - 1 , 4 )
244- got , empty = p3 (5 )
245- expected = (- 1 , 0 , 1 , 2 , 3 , 4 , 5 )
246- self .assertTrue ( expected == got and empty == {})
242+ actual_args , actual_kwds = p3 (5 )
243+ self . assertEqual ( actual_args , (- 1 , 0 , 1 , 2 , 3 , 4 , 5 ) )
244+ self .assertEqual ( actual_kwds , {})
247245 # inner partial has placeholders and outer partial has no args case
248246 p = self .partial (capture , PH , 0 )
249247 p2 = self .partial (p )
250- expected = (PH , 0 )
251- self .assertEqual (expected , p2 .args )
252- self .assertEqual (((1 , 0 ), {}), p2 (1 ))
248+ self .assertEqual (p2 .args , (PH , 0 ))
249+ self .assertEqual (p2 (1 ), ((1 , 0 ), {}))
253250
254251 def test_construct_placeholder_singleton (self ):
255252 PH = self .module .Placeholder
@@ -364,19 +361,17 @@ def test_setstate(self):
364361 f = self .partial (signature )
365362 f .__setstate__ ((capture , (PH , 1 ), dict (a = 10 ), dict (attr = [])))
366363 self .assertEqual (signature (f ), (capture , (PH , 1 ), dict (a = 10 ), dict (attr = [])))
367- with self .assertRaises (TypeError ) as cm :
368- self .assertEqual (f (), (PH , 1 ), dict (a = 10 ))
369- expected = ("missing positional arguments in 'partial' call; "
370- "expected at least 1, got 0" )
371- self .assertEqual (cm .exception .args [0 ], expected )
364+ msg_regex = ("^missing positional arguments in 'partial' call; "
365+ "expected at least 1, got 0$" )
366+ with self .assertRaisesRegex (TypeError , msg_regex ) as cm :
367+ f ()
372368 self .assertEqual (f (2 ), ((2 , 1 ), dict (a = 10 )))
373369
374370 # Trailing Placeholder error
375371 f = self .partial (signature )
376- with self .assertRaises (TypeError ) as cm :
372+ msg_regex = "^trailing Placeholders are not allowed$"
373+ with self .assertRaisesRegex (TypeError , msg_regex ) as cm :
377374 f .__setstate__ ((capture , (1 , PH ), dict (a = 10 ), dict (attr = [])))
378- expected = "trailing Placeholders are not allowed"
379- self .assertEqual (cm .exception .args [0 ], expected )
380375
381376 def test_setstate_errors (self ):
382377 f = self .partial (signature )
0 commit comments