[Python-checkins] cpython (merge 3.4 -> default): Merge

kushal.das python-checkins at python.org
Tue Apr 15 21:53:12 CEST 2014


http://hg.python.org/cpython/rev/ec3ea80758a4
changeset:   90331:ec3ea80758a4
parent:      90329:795d90c7820d
parent:      90330:d471b0d38516
user:        Kushal Das <kushaldas at gmail.com>
date:        Wed Apr 16 01:22:52 2014 +0530
summary:
  Merge

files:
  Lib/unittest/mock.py                   |  2 ++
  Lib/unittest/test/testmock/testmock.py |  4 ++++
  Misc/NEWS                              |  3 +++
  3 files changed, 9 insertions(+), 0 deletions(-)


diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py
--- a/Lib/unittest/mock.py
+++ b/Lib/unittest/mock.py
@@ -2103,6 +2103,8 @@
     elif is_type and instance and not _instance_callable(spec):
         Klass = NonCallableMagicMock
 
+    _name = _kwargs.pop('name', _name)
+
     _new_name = _name
     if _parent is None:
         # for a top level object no _new_name should be set
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
@@ -1182,6 +1182,10 @@
                 func.mock_calls, [call(1, 2), call(3, 4)]
             )
 
+    #Issue21222
+    def test_create_autospec_with_name(self):
+        m = mock.create_autospec(object(), name='sweet_func')
+        self.assertIn('sweet_func', repr(m))
 
     def test_mock_add_spec(self):
         class _One(object):
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -48,6 +48,9 @@
 
 - Issue #21203: Updated fileConfig and dictConfig to remove inconsistencies.
   Thanks to Jure Koren for the patch.
+  
+- Issue #21222: Passing name keyword argument to mock.create_autospec now
+  works.
 
 - Issue #21197: Add lib64 -> lib symlink in venvs on 64-bit non-OS X POSIX.
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list