Issue #19681: Test the repr of partial with more than one keyword argument.
This commit is contained in:
commit
90caf017ee
|
@ -155,9 +155,9 @@ class TestPartialC(TestPartial, unittest.TestCase):
|
||||||
def test_repr(self):
|
def test_repr(self):
|
||||||
args = (object(), object())
|
args = (object(), object())
|
||||||
args_repr = ', '.join(repr(a) for a in args)
|
args_repr = ', '.join(repr(a) for a in args)
|
||||||
#kwargs = {'a': object(), 'b': object()}
|
kwargs = {'a': object(), 'b': object()}
|
||||||
kwargs = {'a': object()}
|
kwargs_reprs = ['a={a!r}, b={b!r}'.format_map(kwargs),
|
||||||
kwargs_repr = ', '.join("%s=%r" % (k, v) for k, v in kwargs.items())
|
'b={b!r}, a={a!r}'.format_map(kwargs)]
|
||||||
if self.partial is c_functools.partial:
|
if self.partial is c_functools.partial:
|
||||||
name = 'functools.partial'
|
name = 'functools.partial'
|
||||||
else:
|
else:
|
||||||
|
@ -172,12 +172,14 @@ class TestPartialC(TestPartial, unittest.TestCase):
|
||||||
repr(f))
|
repr(f))
|
||||||
|
|
||||||
f = self.partial(capture, **kwargs)
|
f = self.partial(capture, **kwargs)
|
||||||
self.assertEqual('{}({!r}, {})'.format(name, capture, kwargs_repr),
|
self.assertIn(repr(f),
|
||||||
repr(f))
|
['{}({!r}, {})'.format(name, capture, kwargs_repr)
|
||||||
|
for kwargs_repr in kwargs_reprs])
|
||||||
|
|
||||||
f = self.partial(capture, *args, **kwargs)
|
f = self.partial(capture, *args, **kwargs)
|
||||||
self.assertEqual('{}({!r}, {}, {})'.format(name, capture, args_repr, kwargs_repr),
|
self.assertIn(repr(f),
|
||||||
repr(f))
|
['{}({!r}, {}, {})'.format(name, capture, args_repr, kwargs_repr)
|
||||||
|
for kwargs_repr in kwargs_reprs])
|
||||||
|
|
||||||
def test_pickle(self):
|
def test_pickle(self):
|
||||||
f = self.partial(signature, 'asdf', bar=True)
|
f = self.partial(signature, 'asdf', bar=True)
|
||||||
|
|
Loading…
Reference in New Issue