|
10 | 10 | from test.support import threading_helper |
11 | 11 | from test.test_importlib import util as test_util |
12 | 12 |
|
13 | | -# Make sure sys.modules[util] is in sync with the import. |
14 | | -# That is needed as other tests may reload util. |
15 | | -sys.modules['importlib.util'] = util |
16 | 13 |
|
17 | 14 | class CollectInit: |
18 | 15 |
|
@@ -195,7 +192,7 @@ def test_lazy_self_referential_modules(self): |
195 | 192 | sys.modules['json'] = module |
196 | 193 | loader.exec_module(module) |
197 | 194 |
|
198 | | - # Trigger load with attribute lookup, ensure expected behavior. |
| 195 | + # Trigger load with attribute lookup, ensure expected behavior |
199 | 196 | test_load = module.loads('{}') |
200 | 197 | self.assertEqual(test_load, {}) |
201 | 198 |
|
@@ -227,26 +224,6 @@ def __delattr__(self, name): |
227 | 224 | with self.assertRaises(AttributeError): |
228 | 225 | del module.CONSTANT |
229 | 226 |
|
230 | | - def test_reload(self): |
231 | | - # Reloading a lazy module that hasn't been materialized is a no-op. |
232 | | - module = self.new_module() |
233 | | - sys.modules[TestingImporter.module_name] = module |
234 | | - |
235 | | - # Change the source code to add a new attribute. |
236 | | - TestingImporter.source_code = 'attr = 42\nnew_attr = 123\n__name__ = {!r}'.format(TestingImporter.mutated_name) |
237 | | - self.assertIsInstance(module, util._LazyModule) |
238 | | - |
239 | | - # Reload the module (should be a no-op since not materialized). |
240 | | - reloaded = importlib.reload(module) |
241 | | - self.assertIs(reloaded, module) |
242 | | - self.assertIsInstance(module, util._LazyModule) |
243 | | - |
244 | | - # Access the new attribute (should trigger materialization, and new_attr should exist). |
245 | | - self.assertEqual(module.attr, 42) |
246 | | - self.assertNotIsInstance(module, util._LazyModule) |
247 | | - self.assertTrue(hasattr(module, 'new_attr')) |
248 | | - self.assertEqual(module.new_attr, 123) |
249 | | - |
250 | 227 |
|
251 | 228 | if __name__ == '__main__': |
252 | 229 | unittest.main() |
0 commit comments