summaryrefslogtreecommitdiff
path: root/mox.py
diff options
context:
space:
mode:
authorPrzemyslaw Gajda <quermit@gmail.com>2012-04-23 15:59:47 +0200
committerPrzemyslaw Gajda <quermit@gmail.com>2012-04-23 15:59:47 +0200
commit4adacddee307c4f90d8cb49ca69f83176967a4e7 (patch)
tree0750f856006b85b9cf75c0572cb216eeb7b140df /mox.py
parent79375ce4d544a241b6db64e4a266a66fc35e86cb (diff)
downloadpymox-4adacddee307c4f90d8cb49ca69f83176967a4e7.tar.gz
Converted all classes to the new style (inheriting from object) - this is the only option in py3k.
Diffstat (limited to 'mox.py')
-rwxr-xr-xmox.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/mox.py b/mox.py
index cbf73aa..595a133 100755
--- a/mox.py
+++ b/mox.py
@@ -417,7 +417,7 @@ def Reset(*args):
mock._Reset()
-class MockAnything:
+class MockAnything(object):
"""A mock that can be used to mock anything.
This is helpful for mocking classes that do not provide a public interface.
@@ -457,7 +457,16 @@ class MockAnything:
return self.__class__.__dir__.__get__(self, self.__class__)
return self._CreateMockMethod(method_name)
-
+
+ def __str__(self):
+ return self._CreateMockMethod('__str__')()
+
+ def __call__(self, *args, **kwargs):
+ return self._CreateMockMethod('__call__')(*args, **kwargs)
+
+ def __getitem__(self, i):
+ return self._CreateMockMethod('__getitem__')(i)
+
def _CreateMockMethod(self, method_name, method_to_mock=None):
"""Create a new mock method call and return it.
@@ -529,7 +538,7 @@ class MockAnything:
self._replay_mode = False
-class MockObject(MockAnything, object):
+class MockObject(MockAnything):
"""A mock object that simulates the public/protected interface of a class."""
def __init__(self, class_to_mock, attrs=None):