Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Private Attributes
importlib.test.util.mock_modules Class Reference

List of all members.

Public Member Functions

def __init__
def __getitem__
def find_module
def load_module
def __enter__
def __exit__

Public Attributes

 modules

Private Attributes

 _uncache

Detailed Description

A mock importer/loader.

Definition at line 83 of file util.py.


Constructor & Destructor Documentation

def importlib.test.util.mock_modules.__init__ (   self,
  names 
)

Definition at line 87 of file util.py.

00087 
00088     def __init__(self, *names):
00089         self.modules = {}
00090         for name in names:
00091             if not name.endswith('.__init__'):
00092                 import_name = name
00093             else:
00094                 import_name = name[:-len('.__init__')]
00095             if '.' not in name:
00096                 package = None
00097             elif import_name == name:
00098                 package = name.rsplit('.', 1)[0]
00099             else:
00100                 package = import_name
00101             module = imp.new_module(import_name)
00102             module.__loader__ = self
00103             module.__file__ = '<mock __file__>'
00104             module.__package__ = package
00105             module.attr = name
00106             if import_name != name:
00107                 module.__path__ = ['<mock __path__>']
00108             self.modules[import_name] = module

Here is the caller graph for this function:


Member Function Documentation

Definition at line 125 of file util.py.

00125 
00126     def __enter__(self):
00127         self._uncache = uncache(*self.modules.keys())
00128         self._uncache.__enter__()
00129         return self

def importlib.test.util.mock_modules.__exit__ (   self,
  exc_info 
)

Definition at line 130 of file util.py.

00130 
00131     def __exit__(self, *exc_info):
00132         self._uncache.__exit__(None, None, None)

Here is the caller graph for this function:

Definition at line 109 of file util.py.

00109 
00110     def __getitem__(self, name):
00111         return self.modules[name]

Here is the caller graph for this function:

def importlib.test.util.mock_modules.find_module (   self,
  fullname,
  path = None 
)

Definition at line 112 of file util.py.

00112 
00113     def find_module(self, fullname, path=None):
00114         if fullname not in self.modules:
00115             return None
00116         else:
00117             return self

Here is the caller graph for this function:

def importlib.test.util.mock_modules.load_module (   self,
  fullname 
)

Definition at line 118 of file util.py.

00118 
00119     def load_module(self, fullname):
00120         if fullname not in self.modules:
00121             raise ImportError
00122         else:
00123             sys.modules[fullname] = self.modules[fullname]
00124             return self.modules[fullname]

Here is the caller graph for this function:


Member Data Documentation

Definition at line 126 of file util.py.

Definition at line 88 of file util.py.


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