Skip to content

Commit 5ecf876

Browse files
committed
add tests
1 parent 2476ce4 commit 5ecf876

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Lib/test/test_operator.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,8 @@ def bar(self, f=42):
482482
return f
483483
def baz(*args, **kwds):
484484
return kwds['name'], kwds['self']
485+
def return_arguments(self, *args, **kwds):
486+
return args, kwds
485487
a = A()
486488
f = operator.methodcaller('foo')
487489
self.assertRaises(IndexError, f, a)
@@ -498,6 +500,17 @@ def baz(*args, **kwds):
498500
f = operator.methodcaller('baz', name='spam', self='eggs')
499501
self.assertEqual(f(a), ('spam', 'eggs'))
500502

503+
many_positional_arguments = tuple(range(10))
504+
many_kw_arguments = dict(zip('abcdefghij', range(10)))
505+
f = operator.methodcaller('return_arguments', *many_positional_arguments)
506+
self.assertEqual(f(a), (many_positional_arguments, {}))
507+
508+
f = operator.methodcaller('return_arguments', **many_kw_arguments)
509+
self.assertEqual(f(a), ((), many_kw_arguments))
510+
511+
f = operator.methodcaller('return_arguments', *many_positional_arguments, **many_kw_arguments)
512+
self.assertEqual(f(a), (many_positional_arguments, many_kw_arguments))
513+
501514
def test_inplace(self):
502515
operator = self.module
503516
class C(object):

0 commit comments

Comments
 (0)