Back to index

python3.2  3.2.2
Public Member Functions
importlib.test.import_.test___package__.Setting__package__ Class Reference

List of all members.

Public Member Functions

def test_top_level
def test_package
def test_submodule

Detailed Description

Because __package__ is a new feature, it is not always set by a loader.
Import will set it as needed to help with the transition to relying on
__package__.

For a top-level module, __package__ is set to None [top-level]. For a
package __name__ is used for __package__ [package]. For submodules the
value is __name__.rsplit('.', 1)[0] [submodule].

Definition at line 75 of file test___package__.py.


Member Function Documentation

Definition at line 96 of file test___package__.py.

00096 
00097     def test_package(self):
00098         with util.mock_modules('pkg.__init__') as mock:
00099             with util.import_state(meta_path=[mock]):
00100                 del mock['pkg'].__package__
00101                 module = import_util.import_('pkg')
00102                 self.assertEqual(module.__package__, 'pkg')

Here is the call graph for this function:

Definition at line 104 of file test___package__.py.

00104 
00105     def test_submodule(self):
00106         with util.mock_modules('pkg.__init__', 'pkg.mod') as mock:
00107             with util.import_state(meta_path=[mock]):
00108                 del mock['pkg.mod'].__package__
00109                 pkg = import_util.import_('pkg.mod')
00110                 module = getattr(pkg, 'mod')
00111                 self.assertEqual(module.__package__, 'pkg')
00112 

Here is the call graph for this function:

Definition at line 88 of file test___package__.py.

00088 
00089     def test_top_level(self):
00090         with util.mock_modules('top_level') as mock:
00091             with util.import_state(meta_path=[mock]):
00092                 del mock['top_level'].__package__
00093                 module = import_util.import_('top_level')
00094                 self.assertEqual(module.__package__, '')

Here is the call graph for this function:


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