Author asottile
Recipients asottile
Date 2016-04-06.20:01:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1459972886.32.0.234738617564.issue26704@psf.upfronthosting.co.za>
In-reply-to
Content
Originally from https://github.com/testing-cabal/mock/issues/350

## Example
```python
from unittest import mock

class C(object):
    def f(self):
        pass

c = C()

with mock.patch.object(c, 'f', autospec=True):
    with mock.patch.object(c, 'f', autospec=True):
        pass
```

## Python3.3

```
$ test.py
$
```

## Python3.4 / 3.5 / 3.6 (From gitbhub.com/python/cpython@fa3fc6d7)

```
Traceback (most recent call last):
  File "test.py", line 10, in <module>
    with mock.patch.object(c, 'f', autospec=True):
  File "/home/asottile/workspace/cpython/Lib/unittest/mock.py", line 1320, in __enter__
    _name=self.attribute, **kwargs)
  File "/home/asottile/workspace/cpython/Lib/unittest/mock.py", line 2220, in create_autospec
    _check_signature(original, new, skipfirst=skipfirst)
  File "/home/asottile/workspace/cpython/Lib/unittest/mock.py", line 112, in _check_signature
    _copy_func_details(func, checksig)
  File "/home/asottile/workspace/cpython/Lib/unittest/mock.py", line 117, in _copy_func_details
    funcopy.__name__ = func.__name__
  File "/home/asottile/workspace/cpython/Lib/unittest/mock.py", line 578, in __getattr__
    raise AttributeError("Mock object has no attribute %r" % name)
AttributeError: Mock object has no attribute '__name__'
```
History
Date User Action Args
2016-04-06 20:01:26asottilesetrecipients: + asottile
2016-04-06 20:01:26asottilesetmessageid: <1459972886.32.0.234738617564.issue26704@psf.upfronthosting.co.za>
2016-04-06 20:01:26asottilelinkissue26704 messages
2016-04-06 20:01:25asottilecreate