You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Calling a mock object in IPython 2.0.0 under Python 3.4.0 raises an AttributeError.
$ ipython
Python 3.4.0 |Continuum Analytics, Inc.| (default, Mar 17 2014, 16:13:08)
Type "copyright", "credits" or "license" for more information.
IPython 2.0.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: from unittest import mock
In [2]: m = mock.Mock()
In [3]: m()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-3-7e5925b669a0> in <module>()
----> 1 m()
/home/nick/anaconda/envs/test2/lib/python3.4/site-packages/IPython/core/displayhook.py in __call__(self, result)
241 if result is not None and not self.quiet():
242 # If _ipython_display_ is defined, use that to display this object.
--> 243 display_method = _safe_get_formatter_method(result, '_ipython_display_')
244 if display_method is not None:
245 try:
/home/nick/anaconda/envs/test2/lib/python3.4/site-packages/IPython/core/formatters.py in _safe_get_formatter_method(obj, name)
87 method = pretty._safe_getattr(obj, name, None)
88 # formatter methods must be bound
---> 89 if _valid_formatter(method):
90 return method
91
/home/nick/anaconda/envs/test2/lib/python3.4/site-packages/IPython/core/formatters.py in _valid_formatter(f)
76 # anything that works with zero args should be okay
77 try:
---> 78 inspect.getcallargs(f)
79 except TypeError:
80 return False
/home/nick/anaconda/envs/test2/lib/python3.4/inspect.py in getcallargs(*func_and_positional, **named)
1165 spec = getfullargspec(func)
1166 args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, ann = spec
-> 1167 f_name = func.__name__
1168 arg2value = {}
1169
/home/nick/anaconda/envs/test2/lib/python3.4/unittest/mock.py in __getattr__(self, name)
557 raise AttributeError("Mock object has no attribute %r" % name)
558 elif _is_magic(name):
--> 559 raise AttributeError(name)
560
561 result = self._mock_children.get(name)
AttributeError: __name__
This behavior is not seen under Python 3.3:
$ ipython
Python 3.3.5 |Continuum Analytics, Inc.| (default, Mar 10 2014, 11:19:39)
Type "copyright", "credits" or "license" for more information.
IPython 2.0.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: from unittest import mock
In [2]: m = mock.Mock()
In [3]: m()
Out[3]: <Mock name='mock()' id='3049469612'>
The text was updated successfully, but these errors were encountered:
ghost
changed the title
calling mock object in IPython 2.0.0 under Python 3.4.0 raises AttributeError
calling mock object in IPython 2.0.0 under Python 3.4.0 raises AttributeError
May 8, 2014
Calling a
mock
object in IPython 2.0.0 under Python 3.4.0 raises anAttributeError
.This behavior is not seen under Python 3.3:
The text was updated successfully, but these errors were encountered: