diff options
author | Gustavo Niemeyer <gustavo@niemeyer.net> | 2010-06-20 12:06:45 -0300 |
---|---|---|
committer | Gustavo Niemeyer <gustavo@niemeyer.net> | 2010-06-20 12:06:45 -0300 |
commit | d8e15110fc3077683a264448a4ddedb59685b372 (patch) | |
tree | e36e92293ef4479d37f9dba47073afcbb1453507 | |
parent | a7565b37e0c07b7914bdbc41ec632778841f5bfa (diff) | |
download | mocker-d8e15110fc3077683a264448a4ddedb59685b372.tar.gz |
Applied change suggested by David Glick to avoid reimporting modules (#529675).
-rw-r--r-- | NEWS | 5 | ||||
-rw-r--r-- | mocker.py | 3 |
2 files changed, 6 insertions, 2 deletions
@@ -9,7 +9,10 @@ tries to use __length_hint__ in some cases. - __nonzero__ should necessarily return a boolean value, so transform Mock - results into True. + results into True (#380024). + +- Applied change suggested by David Glick to avoid reimporting modules + (#529675). - When setting the temporary __mocker_mock__ attribute, use Mocker.patch() so that by the end of the mocking it's properly removed (by Thomas Herve). @@ -599,13 +599,14 @@ class MockerBase(object): while import_stack: module_path = ".".join(import_stack) try: - object = __import__(module_path, {}, {}, [""]) + __import__(module_path) except ImportError: attr_stack.insert(0, import_stack.pop()) if not import_stack: raise continue else: + object = sys.modules[module_path] for attr in attr_stack: object = getattr(object, attr) break |