Back to index

python3.2  3.2.2
Public Member Functions
importlib.test.import_.test_meta_path.CallSignature Class Reference

List of all members.

Public Member Functions

def log
def test_no_path
def test_with_path

Detailed Description

If there is no __path__ entry on the parent module, then 'path' is None
[no path]. Otherwise, the value for __path__ is passed in for the 'path'
argument [path set].

Definition at line 37 of file test_meta_path.py.


Member Function Documentation

Definition at line 43 of file test_meta_path.py.

00043 
00044     def log(self, fxn):
00045         log = []
00046         def wrapper(self, *args, **kwargs):
00047             log.append([args, kwargs])
00048             return fxn(*args, **kwargs)
00049         return log, wrapper
00050 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 51 of file test_meta_path.py.

00051 
00052     def test_no_path(self):
00053         # [no path]
00054         mod_name = 'top_level'
00055         assert '.' not in mod_name
00056         with util.mock_modules(mod_name) as importer:
00057             log, wrapped_call = self.log(importer.find_module)
00058             importer.find_module = MethodType(wrapped_call, importer)
00059             with util.import_state(meta_path=[importer]):
00060                 import_util.import_(mod_name)
00061                 assert len(log) == 1
00062                 args = log[0][0]
00063                 kwargs = log[0][1]
00064                 # Assuming all arguments are positional.
00065                 self.assertEqual(len(args), 2)
00066                 self.assertEqual(len(kwargs), 0)
00067                 self.assertEqual(args[0], mod_name)
00068                 self.assertTrue(args[1] is None)

Here is the call graph for this function:

Definition at line 69 of file test_meta_path.py.

00069 
00070     def test_with_path(self):
00071         # [path set]
00072         pkg_name = 'pkg'
00073         mod_name = pkg_name + '.module'
00074         path = [42]
00075         assert '.' in mod_name
00076         with util.mock_modules(pkg_name+'.__init__', mod_name) as importer:
00077             importer.modules[pkg_name].__path__ = path
00078             log, wrapped_call = self.log(importer.find_module)
00079             importer.find_module = MethodType(wrapped_call, importer)
00080             with util.import_state(meta_path=[importer]):
00081                 import_util.import_(mod_name)
00082                 assert len(log) == 2
00083                 args = log[1][0]
00084                 kwargs = log[1][1]
00085                 # Assuming all arguments are positional.
00086                 self.assertTrue(not kwargs)
00087                 self.assertEqual(args[0], mod_name)
00088                 self.assertTrue(args[1] is path)
00089 
00090 

Here is the call graph for this function:


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