Revision: 74
Author: smiddlek
Date: Mon Nov 12 10:59:51 2012
Log: Patch for Issue 51, contributed by
ma...@ihavethememo.net
http://code.google.com/p/pymox/source/detail?r=74
Modified:
/trunk/mox.py
/trunk/mox_test.py
=======================================
--- /trunk/mox.py Tue May 1 14:27:35 2012
+++ /trunk/mox.py Mon Nov 12 10:59:51 2012
@@ -600,7 +600,10 @@
pass
for method in dir(class_to_mock):
- attr = getattr(class_to_mock, method)
+ try:
+ attr = getattr(class_to_mock, method)
+ except AttributeError:
+ continue
if callable(attr):
self._known_methods.add(method)
elif not (type(attr) is property):
@@ -2062,7 +2065,11 @@
for base in bases:
for attr_name in dir(base):
if attr_name not in d:
- d[attr_name] = getattr(base, attr_name)
+ try:
+ attr_value = getattr(base, attr_name)
+ except AttributeValue:
+ continue
+ d[attr_name] = attr_value
for func_name, func in d.items():
if func_name.startswith('test') and callable(func):
=======================================
--- /trunk/mox_test.py Tue May 1 13:43:51 2012
+++ /trunk/mox_test.py Mon Nov 12 10:59:51 2012
@@ -1253,7 +1253,18 @@
def testCreateObject(self):
"""Mox should create a mock object."""
- mock_obj = self.mox.CreateMock(TestClass)
+ self.mox.CreateMock(TestClass)
+
+ def testCreateMockOfType(self):
+ self.mox.CreateMock(type)
+
+ def testCreateMockWithBogusAttr(self):
+
+ class BogusAttrClass(object):
+ __slots__ = 'no_such_attr',
+
+ foo = BogusAttrClass()
+ self.mox.CreateMock(foo)
def testVerifyObjectWithCompleteReplay(self):
"""Mox should replay and verify all objects it created."""
@@ -1664,7 +1675,8 @@
self.assertEquals('foo', actual)
def testStubOutMethod_Unbound_Subclass_Comparator(self):
-
self.mox.StubOutWithMock(mox_test_helper.TestClassFromAnotherModule, 'Value')
+ self.mox.StubOutWithMock(mox_test_helper.TestClassFromAnotherModule,
+ 'Value')
mox_test_helper.TestClassFromAnotherModule.Value(
mox.IsA(mox_test_helper.ChildClassFromAnotherModule)).AndReturn('foo')
self.mox.ReplayAll()