Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
26581e31
Commit
26581e31
authored
Apr 16, 2014
by
Kushal Das
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Closes Issue 21222.
Passing name keyword argument to mock.create_autospec now works.
parent
916ff51e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
0 deletions
+9
-0
Lib/unittest/mock.py
Lib/unittest/mock.py
+2
-0
Lib/unittest/test/testmock/testmock.py
Lib/unittest/test/testmock/testmock.py
+4
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/unittest/mock.py
View file @
26581e31
...
...
@@ -2096,6 +2096,8 @@ def create_autospec(spec, spec_set=False, instance=False, _parent=None,
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
...
...
Lib/unittest/test/testmock/testmock.py
View file @
26581e31
...
...
@@ -1182,6 +1182,10 @@ class MockTest(unittest.TestCase):
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):
...
...
Misc/NEWS
View file @
26581e31
...
...
@@ -37,6 +37,9 @@ Core and Builtins
Library
-------
- 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.
- Issue #17498: Some SMTP servers disconnect after certain errors, violating
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment