[Python-Dev] [Python-checkins] cpython: Closes #21256: Printout of keyword args in deterministic order in mock calls. (original) (raw)
Berker Peksağ berker.peksag at gmail.com
Mon Jun 9 11:31:14 CEST 2014
- Previous message: [Python-Dev] Help with the build system and my first patch
- Next message: [Python-Dev] Criticism of execfile() removal in Python3
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Mon, Jun 9, 2014 at 11:16 AM, kushal.das <python-checkins at python.org> wrote:
http://hg.python.org/cpython/rev/8e05e15901a8 changeset: 91102:8e05e15901a8 user: Kushal Das <kushaldas at gmail.com> date: Mon Jun 09 13:45:56 2014 +0530 summary: Closes #21256: Printout of keyword args in deterministic order in mock calls.
Printout of keyword args should be in deterministic order in a mock function call. This will help to write better doctests. files: Lib/unittest/mock.py | 2 +- Lib/unittest/test/testmock/testmock.py | 6 ++++++ Misc/NEWS | 3 +++ 3 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py --- a/Lib/unittest/mock.py +++ b/Lib/unittest/mock.py @@ -1894,7 +1894,7 @@ formattedargs = '' argsstring = ', '.join([repr(arg) for arg in args]) kwargsstring = ', '.join([ - '%s=%r' % (key, value) for key, value in kwargs.items() + '%s=%r' % (key, value) for key, value in sorted(kwargs.items()) ]) if argsstring: formattedargs = argsstring diff --git a/Lib/unittest/test/testmock/testmock.py b/Lib/unittest/test/testmock/testmock.py --- a/Lib/unittest/test/testmock/testmock.py +++ b/Lib/unittest/test/testmock/testmock.py @@ -1206,6 +1206,12 @@ with self.assertRaises(AssertionError): m.hello.assertnotcalled() + #Issue21256 printout of keyword args should be in deterministic order + def testsortedcallsignature(self): + m = Mock() + m.hello(name='hello', daddy='hero') + text = "call(daddy='hero', name='hello')" + self.assertEquals(repr(m.hello.callargs), text)
Should this be assertEqual instead?
--Berker
def testmockaddspec(self): class One(object): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -92,6 +92,9 @@ Library ------- +- Issue #21256: Printout of keyword args should be in deterministic order in + a mock function call. This will help to write better doctests. + - Issue #21677: Fixed chaining nonnormalized exceptions in io close() methods. - Issue #11709: Fix the pydoc.help function to not fail when sys.stdin is not a -- Repository URL: http://hg.python.org/cpython
Python-checkins mailing list Python-checkins at python.org https://mail.python.org/mailman/listinfo/python-checkins
- Previous message: [Python-Dev] Help with the build system and my first patch
- Next message: [Python-Dev] Criticism of execfile() removal in Python3
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]