-
Notifications
You must be signed in to change notification settings - Fork 42
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
Port unittests.mock package #11
Comments
Hmm, actually there is a private backport at Lib/test/_mock_backport.py... |
...but it doesn't work very well since it's still missing inspect.signature: >>> import test._mock_backport as mock
>>> class Foo(object): pass
...
>>> mock.MagicMock(Foo)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/naftali/repos/cpython/Lib/test/_mock_backport.py", line 1789, in __init__
_safe_super(MagicMixin, self).__init__(*args, **kw)
File "/Users/naftali/repos/cpython/Lib/test/_mock_backport.py", line 895, in __init__
_spec_state, _new_name, _new_parent, **kwargs
File "/Users/naftali/repos/cpython/Lib/test/_mock_backport.py", line 400, in __init__
self._mock_add_spec(spec, spec_set, _spec_as_instance, _eat_self)
File "/Users/naftali/repos/cpython/Lib/test/_mock_backport.py", line 457, in _mock_add_spec
_spec_as_instance, _eat_self)
File "/Users/naftali/repos/cpython/Lib/test/_mock_backport.py", line 100, in _get_signature_object
return func, inspect.signature(sig_func)
AttributeError: 'module' object has no attribute 'signature'
>>> |
Diffing test._mock_backport and the unittest.mock in 3.5.2 shows that the 2.7 mock looks pretty good. Major substantial differences is a "visited" argument in reset_mock to prevent cycles, looks like a bugfix. |
Needs #14 |
Unnecessary as this exists: https://pypi.python.org/pypi/backports.unittest_mock/1.0 |
No description provided.
The text was updated successfully, but these errors were encountered: