@@ -1134,6 +1134,14 @@ def add(x, y):
11341134 self .assertRaises (TypeError , self .reduce , add , [0 , 1 ], initial = "" )
11351135 self .assertEqual (self .reduce (42 , "" , initial = "1" ), "1" ) # func is never called with one item
11361136
1137+ def test_reduce_with_kwargs (self ):
1138+ with self .assertRaises (TypeError ):
1139+ self .reduce (function = lambda x , y : (x or 1 ) + y , sequence = [1 , 2 , 3 , 4 , 5 ])
1140+ with self .assertRaises (TypeError ):
1141+ self .reduce (function = lambda x , y : x + y , sequence = [1 , 2 , 3 , 4 , 5 ], initial = 1 )
1142+ with self .assertRaises (TypeError ):
1143+ self .reduce (lambda x , y : x + y , sequence = [1 , 2 , 3 , 4 , 5 ], initial = 1 )
1144+
11371145
11381146@unittest .skipUnless (c_functools , 'requires the C _functools module' )
11391147class TestReduceC (TestReduce , unittest .TestCase ):
@@ -1144,12 +1152,6 @@ class TestReduceC(TestReduce, unittest.TestCase):
11441152class TestReducePy (TestReduce , unittest .TestCase ):
11451153 reduce = staticmethod (py_functools .reduce )
11461154
1147- def test_reduce_with_kwargs (self ):
1148- with self .assertWarns (DeprecationWarning ):
1149- self .reduce (function = lambda x , y : x + y , sequence = [1 , 2 , 3 , 4 , 5 ], initial = 1 )
1150- with self .assertWarns (DeprecationWarning ):
1151- self .reduce (lambda x , y : x + y , sequence = [1 , 2 , 3 , 4 , 5 ], initial = 1 )
1152-
11531155
11541156class TestCmpToKey :
11551157
0 commit comments