mock: Skip AttributeError on autospec=True
Currently, when you use django (djangotoolbox in my case), dir() on model
description will give you fields, but when you try to do getattr() on those
fields, you will get AttributeError.
I propose to skip AttributeErrors like this. What do you think?
======================================================================
ERROR: test_should_put_recognized_products_to_receipt
(shwp.consumer.tests.bl.ocr_test.TestPutSucceededOcrResultIntoReceipt)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/kost/.virtualenvs/shp/local/lib/python2.7/site-packages/mock-0.9.0alpha1-py2.7.egg/mock.py", line 1216, in patched
arg = patching.__enter__()
File "/home/kost/.virtualenvs/shp/local/lib/python2.7/site-packages/mock-0.9.0alpha1-py2.7.egg/mock.py", line 1336, in __enter__
_name=self.attribute, **kwargs)
File "/home/kost/.virtualenvs/shp/local/lib/python2.7/site-packages/mock-0.9.0alpha1-py2.7.egg/mock.py", line 2178, in create_autospec
_name='()', _parent=mock)
File "/home/kost/.virtualenvs/shp/local/lib/python2.7/site-packages/mock-0.9.0alpha1-py2.7.egg/mock.py", line 2197, in create_autospec
original = getattr(spec, entry)
File "/home/kost/.virtualenvs/shp/local/lib/python2.7/site-packages/djangotoolbox/fields.py", line 21, in __get__
raise AttributeError('Can only be accessed via an instance.')
AttributeError: Can only be accessed via an instance.
Original issue reported on code.google.com by k...@k-bx.com on 4 Apr 2012 at 9:26
Attachments:
About this issue
- Original URL
- State: closed
- Created 12 years ago
- Comments: 16