summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/unittest/mock.py2
-rw-r--r--Lib/unittest/test/testmock/testmock.py6
-rw-r--r--Misc/NEWS.d/next/Library/2019-06-22-22-00-35.bpo-37212.Zhv-tq.rst2
3 files changed, 6 insertions, 4 deletions
diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py
index 4c76f53..7a4fcf4 100644
--- a/Lib/unittest/mock.py
+++ b/Lib/unittest/mock.py
@@ -2320,7 +2320,7 @@ def _format_call_signature(name, args, kwargs):
formatted_args = ''
args_string = ', '.join([repr(arg) for arg in args])
kwargs_string = ', '.join([
- '%s=%r' % (key, value) for key, value in sorted(kwargs.items())
+ '%s=%r' % (key, value) for key, value in kwargs.items()
])
if args_string:
formatted_args = args_string
diff --git a/Lib/unittest/test/testmock/testmock.py b/Lib/unittest/test/testmock/testmock.py
index d3a1e89..413ee68 100644
--- a/Lib/unittest/test/testmock/testmock.py
+++ b/Lib/unittest/test/testmock/testmock.py
@@ -1563,11 +1563,11 @@ class MockTest(unittest.TestCase):
m.assert_called_once()
self.assertNotIn("Calls:", str(e.exception))
- #Issue21256 printout of keyword args should be in deterministic order
- def test_sorted_call_signature(self):
+ #Issue37212 printout of keyword args now preserves the original order
+ def test_ordered_call_signature(self):
m = Mock()
m.hello(name='hello', daddy='hero')
- text = "call(daddy='hero', name='hello')"
+ text = "call(name='hello', daddy='hero')"
self.assertEqual(repr(m.hello.call_args), text)
#Issue21270 overrides tuple methods for mock.call objects
diff --git a/Misc/NEWS.d/next/Library/2019-06-22-22-00-35.bpo-37212.Zhv-tq.rst b/Misc/NEWS.d/next/Library/2019-06-22-22-00-35.bpo-37212.Zhv-tq.rst
new file mode 100644
index 0000000..520a022
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2019-06-22-22-00-35.bpo-37212.Zhv-tq.rst
@@ -0,0 +1,2 @@
+:func:`unittest.mock.call` now preserves the order of keyword arguments in
+repr output. Patch by Karthikeyan Singaravelan.