Back to index

python3.2  3.2.2
Public Member Functions | Static Public Attributes
test.test_import.RelativeImportTests Class Reference

List of all members.

Public Member Functions

def tearDown
def test_relimport_star
def test_issue3221
def test_absolute_import_without_future

Static Public Attributes

 setUp = tearDown

Detailed Description

Definition at line 438 of file test_import.py.


Member Function Documentation

Definition at line 440 of file test_import.py.

00440 
00441     def tearDown(self):
        unload("test.relimport")

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 478 of file test_import.py.

00478 
00479     def test_absolute_import_without_future(self):
00480         # If explicit relative import syntax is used, then do not try
00481         # to perform an absolute import in the face of failure.
00482         # Issue #7902.
00483         with self.assertRaises(ImportError):
00484             from .os import sep
00485             self.fail("explicit relative import triggered an "
00486                       "implicit absolute import")
00487 

Here is the call graph for this function:

Definition at line 449 of file test_import.py.

00449 
00450     def test_issue3221(self):
00451         # Note for mergers: the 'absolute' tests from the 2.x branch
00452         # are missing in Py3k because implicit relative imports are
00453         # a thing of the past
00454         #
00455         # Regression test for http://bugs.python.org/issue3221.
00456         def check_relative():
00457             exec("from . import relimport", ns)
00458 
00459         # Check relative import OK with __package__ and __name__ correct
00460         ns = dict(__package__='test', __name__='test.notarealmodule')
00461         check_relative()
00462 
00463         # Check relative import OK with only __name__ wrong
00464         ns = dict(__package__='test', __name__='notarealpkg.notarealmodule')
00465         check_relative()
00466 
00467         # Check relative import fails with only __package__ wrong
00468         ns = dict(__package__='foo', __name__='test.notarealmodule')
00469         self.assertRaises(SystemError, check_relative)
00470 
00471         # Check relative import fails with __package__ and __name__ wrong
00472         ns = dict(__package__='foo', __name__='notarealpkg.notarealmodule')
00473         self.assertRaises(SystemError, check_relative)
00474 
00475         # Check relative import fails with package set to a non-string
00476         ns = dict(__package__=object())
00477         self.assertRaises(ValueError, check_relative)

Here is the call graph for this function:

Definition at line 444 of file test_import.py.

00444 
00445     def test_relimport_star(self):
00446         # This will import * from .test_import.
00447         from . import relimport
00448         self.assertTrue(hasattr(relimport, "RelativeImportTests"))

Here is the call graph for this function:


Member Data Documentation

Definition at line 442 of file test_import.py.


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