[Python-checkins] r52580 - sandbox/trunk/import_in_py/test_importer.py
brett.cannon
python-checkins at python.org
Thu Nov 2 00:49:35 CET 2006
Author: brett.cannon
Date: Thu Nov 2 00:49:35 2006
New Revision: 52580
Modified:
sandbox/trunk/import_in_py/test_importer.py
Log:
Add tests for top-level package support for filesystem loaders.
Modified: sandbox/trunk/import_in_py/test_importer.py
==============================================================================
--- sandbox/trunk/import_in_py/test_importer.py (original)
+++ sandbox/trunk/import_in_py/test_importer.py Thu Nov 2 00:49:35 2006
@@ -243,7 +243,10 @@
"""Create a fresh loader per run."""
mock_handler = mock_importer.MockHandler()
self.test_path = "<test path>"
+ self.pkg_path = "<test pkg>"
+ self.pkg_init_path = os.path.join(self.pkg_path, '__init__.test')
self.module_name = "test_module_name"
+ self.pkg_name = "test_pkg"
self.loader = importer.FileSystemLoader(self.test_path,
mock_handler)
@@ -289,8 +292,15 @@
def test_package_init(self):
# Test that instantiating a loader for handling a package works
# properly.
- # XXX
- pass
+ pkg_loader = importer.FileSystemLoader(self.pkg_init_path,
+ mock_importer.MockHandler(),
+ self.pkg_path)
+ module = pkg_loader.load_module(self.pkg_name)
+ self.failUnlessEqual(module.loader, pkg_loader)
+ self.failUnlessEqual(module.path, self.pkg_init_path)
+ self.failUnlessEqual(module.module_name, self.pkg_name)
+ self.failUnless(hasattr(module, '__path__'))
+ self.failUnlessEqual(module.__path__, [self.pkg_path])
class FileSystemLoaderWhiteBoxTests(FileSystemLoaderMockEnv):
More information about the Python-checkins
mailing list