diff options
author | Gustavo Niemeyer <gustavo@niemeyer.net> | 2007-11-11 22:18:32 -0200 |
---|---|---|
committer | Gustavo Niemeyer <gustavo@niemeyer.net> | 2007-11-11 22:18:32 -0200 |
commit | a2b71cfd493b5a2011b8c4e8b9d939bd2b186894 (patch) | |
tree | f71eefda6e265a0d59c7aba6d868b90b9880b983 /mocker.py | |
parent | 02c0298f780d8dcb435fad8967de2a956ac78d14 (diff) | |
download | mocker-a2b71cfd493b5a2011b8c4e8b9d939bd2b186894.tar.gz |
Moved "string proxying" logic out of replace() and into proxy().
Diffstat (limited to 'mocker.py')
-rw-r--r-- | mocker.py | 32 |
1 files changed, 16 insertions, 16 deletions
@@ -385,6 +385,22 @@ class MockerBase(object): explicitly requested via the L{passthrough()} method. """ + if isinstance(object, basestring): + if name is None: + name = object + import_stack = object.split(".") + attr_stack = [] + while import_stack: + module_path = ".".join(import_stack) + try: + object = __import__(module_path, {}, {}, [""]) + except ImportError: + attr_stack.insert(0, import_stack.pop()) + continue + else: + for attr in attr_stack: + object = getattr(object, attr) + break if spec is True: spec = object if type is True: @@ -422,22 +438,6 @@ class MockerBase(object): explicitly requested via the L{passthrough()} method. """ - if isinstance(object, basestring): - if name is None: - name = object - import_stack = object.split(".") - attr_stack = [] - while import_stack: - module_path = ".".join(import_stack) - try: - object = __import__(module_path, {}, {}, [""]) - except ImportError: - attr_stack.insert(0, import_stack.pop()) - continue - else: - for attr in attr_stack: - object = getattr(object, attr) - break mock = self.proxy(object, spec, type, name, passthrough) event = self._get_replay_restore_event() event.add_task(ProxyReplacer(mock)) |