Code

Ticket #13469: t13469.diff

File t13469.diff, 2.8 KB (added by russellm, 4 years ago)

Possible fix for Python2.3 failures

Line 
1diff -r fd56af1f744b tests/regressiontests/utils/module_loading.py
2--- a/tests/regressiontests/utils/module_loading.py     Tue May 04 14:00:30 2010 +0000
3+++ b/tests/regressiontests/utils/module_loading.py     Tue May 04 22:34:26 2010 +0800
4@@ -89,7 +89,7 @@
5         mod.__loader__ = self
6         return mod
7 
8-class CustomLoader(TestCase):
9+class CustomLoader(EggLoader):
10     def setUp(self):
11         self.egg_dir = '%s/eggs' % os.path.dirname(__file__)
12         self.old_path = sys.path
13@@ -99,41 +99,12 @@
14     def tearDown(self):
15         sys.path = self.old_path
16         sys.path_hooks.pop(0)
17+        sys.path_importer_cache.clear()
18 
19-    def test_shallow_loader(self):
20-        "Module existence can be tested with a custom loader"
21-        egg_name = '%s/test_egg.egg' % self.egg_dir
22-        sys.path.append(egg_name)
23-        egg_module = import_module('egg_module')
24-
25-        # An importable child
26-        self.assertTrue(module_has_submodule(egg_module, 'good_module'))
27-        mod = import_module('egg_module.good_module')
28-        self.assertEqual(mod.content, 'Good Module')
29-
30-        # A child that exists, but will generate an import error if loaded
31-        self.assertTrue(module_has_submodule(egg_module, 'bad_module'))
32-        self.assertRaises(ImportError, import_module, 'egg_module.bad_module')
33-
34-        # A child that doesn't exist
35-        self.assertFalse(module_has_submodule(egg_module, 'no_such_module'))
36-        self.assertRaises(ImportError, import_module, 'egg_module.no_such_module')
37-
38-    def test_deep_loader(self):
39-        "Modules existence can be tested deep inside a custom loader"
40-        egg_name = '%s/test_egg.egg' % self.egg_dir
41-        sys.path.append(egg_name)
42-        egg_module = import_module('egg_module.sub1.sub2')
43-
44-        # An importable child
45-        self.assertTrue(module_has_submodule(egg_module, 'good_module'))
46-        mod = import_module('egg_module.sub1.sub2.good_module')
47-        self.assertEqual(mod.content, 'Deep Good Module')
48-
49-        # A child that exists, but will generate an import error if loaded
50-        self.assertTrue(module_has_submodule(egg_module, 'bad_module'))
51-        self.assertRaises(ImportError, import_module, 'egg_module.sub1.sub2.bad_module')
52-
53-        # A child that doesn't exist
54-        self.assertFalse(module_has_submodule(egg_module, 'no_such_module'))
55-        self.assertRaises(ImportError, import_module, 'egg_module.sub1.sub2.no_such_module')
56+        sys.modules.pop('egg_module.sub1.sub2.bad_module', None)
57+        sys.modules.pop('egg_module.sub1.sub2.good_module', None)
58+        sys.modules.pop('egg_module.sub1.sub2', None)
59+        sys.modules.pop('egg_module.sub1', None)
60+        sys.modules.pop('egg_module.bad_module', None)
61+        sys.modules.pop('egg_module.good_module', None)
62+        sys.modules.pop('egg_module', None)