-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
Mock create_autospec with name argument fails #65421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
>>> from unittest import mock
>>> def b():
... print("hello")
...
>>> q = mock.create_autospec(b, name="a")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/kdas/code/python/cpython3/Lib/unittest/mock.py", line 2092, in create_autospec
name=_name, **_kwargs)
TypeError: type object got multiple values for keyword argument 'name' The issue was originally reported on mock bug tracker. I am working on a patch for the same. |
Fix for the issue with test case. We are checking name in keyword arguments, if found replace _name with it and delete it from keyword arguments. |
You can use kwargs.pop instead of the two step fetch and delete. For the test, could you add an assert that the name is used. Can you add an extra underscore to the method name, to make it: test_create_autospec_with_name |
New patchset with changes made as suggested. |
Looks good to me, but please change qobj and add a NEWS entry. |
New changeset d471b0d38516 by Kushal Das in branch '3.4': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: