jsatt / mock

Automatically exported from code.google.com/p/mock
BSD 2-Clause "Simplified" License
0 stars 0 forks source link

Cannot autospec mock builtins.print in python3.4 #234

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
This code works prior to 3.4:

import builtins import mock

with mock.patch.object(builtins, 'print', autospec=True): print('hai')


In 3.4:

$ python test.py Traceback (most recent call last): File "test.py", line 4, in with mock.patch.object(builtins, 'print', autospec=True): File "/tmp/venv34/lib/python3.4/site-packages/mock.py", line 1349, in enter _name=self.attribute, kwargs) File "/tmp/venv34/lib/python3.4/site-packages/mock.py", line 2193, in create_autospec _check_signature(spec, mock, is_type, instance) File "/tmp/venv34/lib/python3.4/site-packages/mock.py", line 213, in _check_signature _copy_func_details(func, checksig) File "/tmp/venv34/lib/python3.4/site-packages/mock.py", line 221, in _copy_func_details funcopy.module = func.module AttributeError: 'method-wrapper' object has no attribute 'module**'

Original issue reported on code.google.com by asott...@yelp.com on 7 Jul 2014 at 11:23