[Python-checkins] r56979 - sandbox/trunk/import_in_py/tests/test_chained_importer.py
brett.cannon
python-checkins at python.org
Mon Aug 13 09:25:31 CEST 2007
Author: brett.cannon
Date: Mon Aug 13 09:25:31 2007
New Revision: 56979
Modified:
sandbox/trunk/import_in_py/tests/test_chained_importer.py
Log:
Add tests for rejected inappropriate path entries.
Modified: sandbox/trunk/import_in_py/tests/test_chained_importer.py
==============================================================================
--- sandbox/trunk/import_in_py/tests/test_chained_importer.py (original)
+++ sandbox/trunk/import_in_py/tests/test_chained_importer.py Mon Aug 13 09:25:31 2007
@@ -36,7 +36,6 @@
hook = importlib.chaining_fs_path_hook(pass_hook, pass_hook)
self.assertRaises(ImportError, hook, '.')
- # Dependent on implementation details.
def test_order_preservation(self):
# The order of importers to call should be maintained.
succeed1 = mock_importlib.SucceedImporter()
@@ -54,6 +53,23 @@
absolute_path = os.path.abspath('.')
self.assertEquals(os.path.normpath(succeed.path_entries[0]), absolute_path)
+ def test_reject_file(self):
+ # A file should not be accepted.
+ succeed = mock_importlib.SucceedImporter()
+ hook = importlib.chaining_fs_path_hook(succeed)
+ with open(test_support.TESTFN, 'w') as test_file:
+ test_file.write('# For testing chained path hook.')
+ try:
+ self.assertRaises(ImportError, hook, test_support.TESTFN)
+ finally:
+ test_support.unlink(test_support.TESTFN)
+
+ def test_reject_bad_dir(self):
+ # A non-existent directory should be rejected.
+ succeed = mock_importlib.SucceedImporter()
+ hook = importlib.chaining_fs_path_hook(succeed)
+ self.assertRaises(ImportError, hook, '_asdfasdfasdf')
+
class ChainedImporterTests(unittest.TestCase):
More information about the Python-checkins
mailing list