Back to index

python3.2  3.2.2
Public Member Functions
importlib.test.import_.test_path.FinderTests Class Reference

List of all members.

Public Member Functions

def test_failure
def test_sys_path
def test_path
def test_path_hooks
def test_path_importer_cache_has_None
def test_path_importer_cache_has_None_continues

Detailed Description

Tests for PathFinder.

Definition at line 14 of file test_path.py.


Member Function Documentation

Definition at line 18 of file test_path.py.

00018 
00019     def test_failure(self):
00020         # Test None returned upon not finding a suitable finder.
00021         module = '<test module>'
00022         with util.import_state():
00023             self.assertTrue(machinery.PathFinder.find_module(module) is None)

Here is the call graph for this function:

Definition at line 35 of file test_path.py.

00035 
00036     def test_path(self):
00037         # Test that 'path' is used when set.
00038         # Implicitly tests that sys.path_importer_cache is used.
00039         module = '<test module>'
00040         path = '<test path>'
00041         importer = util.mock_modules(module)
00042         with util.import_state(path_importer_cache={path: importer}):
00043             loader = machinery.PathFinder.find_module(module, [path])
00044             self.assertTrue(loader is importer)

Here is the call graph for this function:

Definition at line 45 of file test_path.py.

00045 
00046     def test_path_hooks(self):
00047         # Test that sys.path_hooks is used.
00048         # Test that sys.path_importer_cache is set.
00049         module = '<test module>'
00050         path = '<test path>'
00051         importer = util.mock_modules(module)
00052         hook = import_util.mock_path_hook(path, importer=importer)
00053         with util.import_state(path_hooks=[hook]):
00054             loader = machinery.PathFinder.find_module(module, [path])
00055             self.assertTrue(loader is importer)
00056             self.assertTrue(path in sys.path_importer_cache)
00057             self.assertTrue(sys.path_importer_cache[path] is importer)

Here is the call graph for this function:

Definition at line 58 of file test_path.py.

00058 
00059     def test_path_importer_cache_has_None(self):
00060         # Test that if sys.path_importer_cache has None that None is returned.
00061         clear_cache = {path: None for path in sys.path}
00062         with util.import_state(path_importer_cache=clear_cache):
00063             for name in ('asynchat', 'sys', '<test module>'):
00064                 self.assertTrue(machinery.PathFinder.find_module(name) is None)

Here is the call graph for this function:

Definition at line 65 of file test_path.py.

00065 
00066     def test_path_importer_cache_has_None_continues(self):
00067         # Test that having None in sys.path_importer_cache causes the search to
00068         # continue.
00069         path = '<test path>'
00070         module = '<test module>'
00071         importer = util.mock_modules(module)
00072         with util.import_state(path=['1', '2'],
00073                             path_importer_cache={'1': None, '2': importer}):
00074             loader = machinery.PathFinder.find_module(module)
00075             self.assertTrue(loader is importer)
00076 
00077 

Here is the call graph for this function:

Definition at line 24 of file test_path.py.

00024 
00025     def test_sys_path(self):
00026         # Test that sys.path is used when 'path' is None.
00027         # Implicitly tests that sys.path_importer_cache is used.
00028         module = '<test module>'
00029         path = '<test path>'
00030         importer = util.mock_modules(module)
00031         with util.import_state(path_importer_cache={path: importer},
00032                                path=[path]):
00033             loader = machinery.PathFinder.find_module(module)
00034             self.assertTrue(loader is importer)

Here is the call graph for this function:


The documentation for this class was generated from the following file: