diff options
author | Gustavo Niemeyer <gustavo@niemeyer.net> | 2007-11-22 20:01:27 -0200 |
---|---|---|
committer | Gustavo Niemeyer <gustavo@niemeyer.net> | 2007-11-22 20:01:27 -0200 |
commit | 35d2aaafce5afc718e96cc78656201488c390725 (patch) | |
tree | 6848868ad0d36ad9b640afa361f362f24e1bb52a /mocker.py | |
parent | 16f6a2b6573857c91d7f232c5fc3c26a1479e45b (diff) | |
download | mocker-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.py | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -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): |