Kaydet (Commit) 99d001ed authored tarafından Tim Peters's avatar Tim Peters

Removed reliance on damaged module object appearing in sys.modules

after a failed import.

This is the last checkin in the "change import failure semantics" series.
üst 08138fdc
...@@ -66,12 +66,11 @@ class TestImport(unittest.TestCase): ...@@ -66,12 +66,11 @@ class TestImport(unittest.TestCase):
try: __import__(self.module_name) try: __import__(self.module_name)
except NameError: pass except NameError: pass
else: raise RuntimeError, 'Failed to induce NameError.' else: raise RuntimeError, 'Failed to induce NameError.'
module = __import__(self.module_name).foo
# ...now change the module so that the NameError doesn't # ...now change the module so that the NameError doesn't
# happen # happen
self.rewrite_file('%s = 1' % var) self.rewrite_file('%s = 1' % var)
reload(module) module = __import__(self.module_name).foo
self.assertEqual(getattr(module, var), 1) self.assertEqual(getattr(module, var), 1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment