Back to index

python3.2  3.2.2
Public Member Functions
importlib.test.frozen.test_loader.InspectLoaderTests Class Reference

List of all members.

Public Member Functions

def test_get_code
def test_get_source
def test_is_package
def test_failure

Detailed Description

Tests for the InspectLoader methods for FrozenImporter.

Definition at line 64 of file test_loader.py.


Member Function Documentation

Definition at line 91 of file test_loader.py.

00091 
00092     def test_failure(self):
00093         # Raise ImportError for modules that are not frozen.
00094         for meth_name in ('get_code', 'get_source', 'is_package'):
00095             method = getattr(machinery.FrozenImporter, meth_name)
00096             with self.assertRaises(ImportError):
00097                 method('importlib')
00098 

Here is the call graph for this function:

Definition at line 68 of file test_loader.py.

00068 
00069     def test_get_code(self):
00070         # Make sure that the code object is good.
00071         name = '__hello__'
00072         with captured_stdout() as stdout:
00073             code = machinery.FrozenImporter.get_code(name)
00074             mod = imp.new_module(name)
00075             exec(code, mod.__dict__)
00076             self.assertTrue(hasattr(mod, 'initialized'))
00077             self.assertEqual(stdout.getvalue(), 'Hello world!\n')

Here is the call graph for this function:

Definition at line 78 of file test_loader.py.

00078 
00079     def test_get_source(self):
00080         # Should always return None.
00081         result = machinery.FrozenImporter.get_source('__hello__')
00082         self.assertTrue(result is None)

Here is the call graph for this function:

Definition at line 83 of file test_loader.py.

00083 
00084     def test_is_package(self):
00085         # Should be able to tell what is a package.
00086         test_for = (('__hello__', False), ('__phello__', True),
00087                     ('__phello__.spam', False))
00088         for name, is_package in test_for:
00089             result = machinery.FrozenImporter.is_package(name)
00090             self.assertTrue(bool(result) == is_package)

Here is the call graph for this function:


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