What steps will reproduce the problem?
Attempt to use mox.Mox.CreateMock() on an object where dir(obj) lists an
attribute but getattr(obj, attr_name) raises AttributeError.
What is the expected output? What do you see instead?
For example, in Python 2.7 type lists __abstractmethods__ as an attribute while
getattr(type, '__abstractmethods__') fails:
>>> mox.Mox().CreateMock(type)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "mox.py", line 284, in CreateMock
new_mock = MockObject(class_to_mock, attrs=attrs)
File "mox.py", line 603, in __init__
attr = getattr(class_to_mock, method)
AttributeError: __abstractmethods__
>>>
A similar situation can arise when using slots:
>>> class ac(object): __slots__ = 'a',
...
>>> mox.Mox().CreateMock(ac())
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "mox.py", line 284, in CreateMock
new_mock = MockObject(class_to_mock, attrs=attrs)
File "mox.py", line 603, in __init__
attr = getattr(class_to_mock, method)
AttributeError: a
>>>
What version of the product are you using? On what operating system?
The latest version of mox from SVN, with Python 2.7.3rc2, built for 32-bit
Linux.
I have attached a patch to ignore such bogus attributes, with two test cases.
Original issue reported on code.google.com by m...@ihavethememo.net on 9 Nov 2012 at 1:20
Original issue reported on code.google.com by
m...@ihavethememo.net
on 9 Nov 2012 at 1:20Attachments: