[Python-checkins] r57209 - sandbox/trunk/import_in_py/tests/test_fs_loader.py

brett.cannon python-checkins at python.org
Mon Aug 20 04:06:18 CEST 2007


Author: brett.cannon
Date: Mon Aug 20 04:06:16 2007
New Revision: 57209

Modified:
   sandbox/trunk/import_in_py/tests/test_fs_loader.py
Log:
Test that only having bytecode is okay.


Modified: sandbox/trunk/import_in_py/tests/test_fs_loader.py
==============================================================================
--- sandbox/trunk/import_in_py/tests/test_fs_loader.py	(original)
+++ sandbox/trunk/import_in_py/tests/test_fs_loader.py	Mon Aug 20 04:06:16 2007
@@ -154,7 +154,20 @@
     def test_only_good_pyc(self):
         # Should be able to load even if only bytecode is available (top-level
         # or package).
-        raise NotImplementedError
+        to_test = [(self.module_name, self.py_path, self.pyc_path, False),
+                   (self.pkg_name, self.pkg_init_path,
+                       os.path.join(self.pkg_path, '__init__' + self.pyc_ext),
+                       True)]
+        for name, source_path, bytecode_path, is_pkg in to_test:
+            py_compile.compile(source_path)
+            os.unlink(source_path)
+            loader = importlib._PyFileLoader(name, bytecode_path, is_pkg)
+            log_call(loader, 'mod_time')
+            log_call(loader, 'get_source')
+            found = loader.load_module(name)
+            self.assert_('mod_time' not in loader._log)
+            self.assert_('get_source' not in loader._log)
+            self.verify_package(found, name)
 
     def test_only_py(self):
         # Having only source should be fine (top-level or package).


More information about the Python-checkins mailing list