diff options
-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 |