Back to index

python3.2  3.2.2
Public Member Functions
importlib.test.test_util.SetPackageTests Class Reference

List of all members.

Public Member Functions

def verify
def test_top_level
def test_package
def test_submodule
def test_setting_if_missing
def test_leaving_alone

Detailed Description

Tests for importlib.util.set_package.

Definition at line 63 of file test_util.py.


Member Function Documentation

Definition at line 104 of file test_util.py.

00104 
00105     def test_leaving_alone(self):
00106         # If __package__ is set and not None then leave it alone.
00107         for value in (True, False):
00108             module = imp.new_module('mod')
00109             module.__package__ = value
00110             self.verify(module, value)
00111 

Here is the call graph for this function:

Definition at line 84 of file test_util.py.

00084 
00085     def test_package(self):
00086         # Test setting __package__ for a package.
00087         module = imp.new_module('pkg')
00088         module.__path__ = ['<path>']
00089         module.__package__ = None
00090         self.verify(module, 'pkg')

Here is the call graph for this function:

Definition at line 97 of file test_util.py.

00097 
00098     def test_setting_if_missing(self):
00099         # __package__ should be set if it is missing.
00100         module = imp.new_module('mod')
00101         if hasattr(module, '__package__'):
00102             delattr(module, '__package__')
00103         self.verify(module, '')

Here is the call graph for this function:

Definition at line 91 of file test_util.py.

00091 
00092     def test_submodule(self):
00093         # Test __package__ for a module in a package.
00094         module = imp.new_module('pkg.mod')
00095         module.__package__ = None
00096         self.verify(module, 'pkg')

Here is the call graph for this function:

Definition at line 77 of file test_util.py.

00077 
00078     def test_top_level(self):
00079         # __package__ should be set to the empty string if a top-level module.
00080         # Implicitly tests when package is set to None.
00081         module = imp.new_module('module')
00082         module.__package__ = None
00083         self.verify(module, '')

Here is the call graph for this function:

def importlib.test.test_util.SetPackageTests.verify (   self,
  module,
  expect 
)
Verify the module has the expected value for __package__ after
passing through set_package.

Definition at line 68 of file test_util.py.

00068 
00069     def verify(self, module, expect):
00070         """Verify the module has the expected value for __package__ after
00071         passing through set_package."""
00072         fxn = lambda: module
00073         wrapped = util.set_package(fxn)
00074         wrapped()
00075         self.assertTrue(hasattr(module, '__package__'))
00076         self.assertEqual(expect, module.__package__)

Here is the call graph for this function:

Here is the caller graph for this function:


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