[Python-checkins] cpython (merge 3.4 -> default): Issue #19681: Test the repr of partial with more than one keyword argument.

serhiy.storchaka python-checkins at python.org
Sun Feb 15 15:22:50 CET 2015


https://hg.python.org/cpython/rev/6f80e8bcb5ad
changeset: 94634:6f80e8bcb5ad
parent: 94632:8c9121993eb5
parent: 94633:138c2afd9f1f
user: Serhiy Storchaka <storchaka at gmail.com>
date: Sun Feb 15 16:22:11 2015 +0200
summary:
 Issue #19681: Test the repr of partial with more than one keyword argument.
files:
 Lib/test/test_functools.py | 16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py
--- a/Lib/test/test_functools.py
+++ b/Lib/test/test_functools.py
@@ -155,9 +155,9 @@
 def test_repr(self):
 args = (object(), object())
 args_repr = ', '.join(repr(a) for a in args)
- #kwargs = {'a': object(), 'b': object()}
- kwargs = {'a': object()}
- kwargs_repr = ', '.join("%s=%r" % (k, v) for k, v in kwargs.items())
+ kwargs = {'a': object(), 'b': object()}
+ kwargs_reprs = ['a={a!r}, b={b!r}'.format_map(kwargs),
+ 'b={b!r}, a={a!r}'.format_map(kwargs)]
 if self.partial is c_functools.partial:
 name = 'functools.partial'
 else:
@@ -172,12 +172,14 @@
 repr(f))
 
 f = self.partial(capture, **kwargs)
- self.assertEqual('{}({!r}, {})'.format(name, capture, kwargs_repr),
- repr(f))
+ self.assertIn(repr(f),
+ ['{}({!r}, {})'.format(name, capture, kwargs_repr)
+ for kwargs_repr in kwargs_reprs])
 
 f = self.partial(capture, *args, **kwargs)
- self.assertEqual('{}({!r}, {}, {})'.format(name, capture, args_repr, kwargs_repr),
- repr(f))
+ self.assertIn(repr(f),
+ ['{}({!r}, {}, {})'.format(name, capture, args_repr, kwargs_repr)
+ for kwargs_repr in kwargs_reprs])
 
 def test_pickle(self):
 f = self.partial(signature, 'asdf', bar=True)
-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /