summaryrefslogtreecommitdiff
path: root/mocker.py
diff options
context:
space:
mode:
authorGustavo Niemeyer <gustavo@niemeyer.net>2007-11-22 20:01:27 -0200
committerGustavo Niemeyer <gustavo@niemeyer.net>2007-11-22 20:01:27 -0200
commit35d2aaafce5afc718e96cc78656201488c390725 (patch)
tree6848868ad0d36ad9b640afa361f362f24e1bb52a /mocker.py
parent16f6a2b6573857c91d7f232c5fc3c26a1479e45b (diff)
downloadmocker-35d2aaafce5afc718e96cc78656201488c390725.tar.gz
In recording mode, mock.__class__ will now return Mock, and not
record the action. This allows Mocker to be used in interactive environments which inspect the result's type, such as in iPython (reported by Alex Dante).
Diffstat (limited to 'mocker.py')
-rw-r--r--mocker.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/mocker.py b/mocker.py
index e06ae64..c18f204 100644
--- a/mocker.py
+++ b/mocker.py
@@ -965,9 +965,6 @@ class Mock(object):
try:
return self.__mocker__.act(path)
except MatchError, exception:
- if (self.__mocker_type__ is not None and
- kind == "getattr" and args == ("__class__",)):
- return self.__mocker_type__
root_mock = path.root_mock
if (path.root_object is not None and
root_mock.__mocker_passthrough__):
@@ -986,6 +983,10 @@ class Mock(object):
def __getattribute__(self, name):
if name.startswith("__mocker_"):
return super(Mock, self).__getattribute__(name)
+ if name == "__class__":
+ if self.__mocker__.is_recording() or self.__mocker_type__ is None:
+ return type(self)
+ return self.__mocker_type__
return self.__mocker_act__("getattr", (name,))
def __setattr__(self, name, value):