Back to index

python3.2  3.2.2
Classes | Functions | Variables
test.test_modulefinder Namespace Reference

Classes

class  ModuleFinderTest

Functions

def open_file
def create_package
def test_package
def test_maybe
def test_maybe_new
def test_absolute_imports
def test_relative_imports
def test_relative_imports_2
def test_relative_imports_3
def test_main

Variables

tuple TEST_DIR = tempfile.mkdtemp()
list TEST_PATH = [TEST_DIR, os.path.dirname(__future__.__file__)]
list maybe_test
list maybe_test_new
list package_test
list absolute_import_test
list relative_import_test
list relative_import_test_2
list relative_import_test_3
tuple modules = set(modules)
 

This wouldn't work in general when executed several times:

opath = sys.path[:] sys.path = TEST_PATH try: import(import_this) except: import traceback; traceback.print_exc() sys.path = opath return
tuple found = set(mf.modules.keys())
tuple more = list(found - modules)
tuple less = list(modules - found)

Function Documentation

Definition at line 205 of file test_modulefinder.py.

00205 
00206 def create_package(source):
00207     ofi = None
00208     try:
00209         for line in source.splitlines():
00210             if line.startswith(" ") or line.startswith("\t"):
00211                 ofi.write(line.strip() + "\n")
00212             else:
00213                 if ofi:
00214                     ofi.close()
00215                 ofi = open_file(os.path.join(TEST_DIR, line.strip()))
00216     finally:
00217         if ofi:
00218             ofi.close()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 199 of file test_modulefinder.py.

00199 
00200 def open_file(path):
00201     ##print "#", os.path.abspath(path)
00202     dirname = os.path.dirname(path)
00203     distutils.dir_util.mkpath(dirname)
00204     return open(path, "w")

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 262 of file test_modulefinder.py.

00262 
00263         def test_absolute_imports(self):
00264             self._do_test(absolute_import_test)

Definition at line 274 of file test_modulefinder.py.

00274 
00275 def test_main():
00276     distutils.log.set_threshold(distutils.log.WARN)
00277     support.run_unittest(ModuleFinderTest)

Here is the call graph for this function:

Definition at line 254 of file test_modulefinder.py.

00254 
00255     def test_maybe(self):
00256         self._do_test(maybe_test)

Here is the call graph for this function:

Definition at line 259 of file test_modulefinder.py.

00259 
00260         def test_maybe_new(self):
00261             self._do_test(maybe_test_new)

Definition at line 251 of file test_modulefinder.py.

00251 
00252     def test_package(self):
00253         self._do_test(package_test)

Definition at line 265 of file test_modulefinder.py.

00265 
00266         def test_relative_imports(self):
00267             self._do_test(relative_import_test)

Definition at line 268 of file test_modulefinder.py.

00268 
00269         def test_relative_imports_2(self):
00270             self._do_test(relative_import_test_2)

Definition at line 271 of file test_modulefinder.py.

00271 
00272         def test_relative_imports_3(self):
00273             self._do_test(relative_import_test_3)


Variable Documentation

Initial value:
00001 [
00002     "a.module",
00003     ["a", "a.module",
00004      "b", "b.x", "b.y", "b.z",
00005      "__future__", "sys", "gc"],
00006     ["blahblah", "z"], [],
00007     """\
00008 mymodule.pya/__init__.pya/module.py                                from __future__ import absolute_import                                import sys # sys                                import blahblah # fails                                import gc # gc                                import b.x # b.x                                from b import y # b.y                                from b.z import * # b.z.*a/gc.pya/sys.py                                import mymodulea/b/__init__.pya/b/x.pya/b/y.pya/b/z.pyb/__init__.py                                import zb/unused.pyb/x.pyb/y.pyb/z.py"""]

Definition at line 79 of file test_modulefinder.py.

tuple test.test_modulefinder.found = set(mf.modules.keys())

Definition at line 238 of file test_modulefinder.py.

Definition at line 240 of file test_modulefinder.py.

Initial value:
00001 [
00002     "a.module",
00003     ["a", "a.module", "sys",
00004      "b"],
00005     ["c"], ["b.something"],
00006     """\
00007 a/__init__.pya/module.py                                from b import something                                from c import somethingb/__init__.py                                from sys import *"""]

Definition at line 29 of file test_modulefinder.py.

Initial value:
00001 [
00002     "a.module",
00003     ["a", "a.module", "sys",
00004      "b", "__future__"],
00005     ["c"], ["b.something"],
00006     """\
00007 a/__init__.pya/module.py                                from b import something                                from c import somethingb/__init__.py                                from __future__ import absolute_import                                from sys import *"""]

Definition at line 43 of file test_modulefinder.py.

This wouldn't work in general when executed several times:

opath = sys.path[:] sys.path = TEST_PATH try: import(import_this) except: import traceback; traceback.print_exc() sys.path = opath return

Definition at line 237 of file test_modulefinder.py.

Definition at line 239 of file test_modulefinder.py.

Initial value:
00001 [
00002     "a.module",
00003     ["a", "a.b", "a.c", "a.module", "mymodule", "sys"],
00004     ["blahblah", "c"], [],
00005     """\
00006 mymodule.pya/__init__.py                                import blahblah                                from a import b                                import ca/module.py                                import sys                                from a import b as x                                from a.c import sillynamea/b.pya/c.py                                from a.module import x                                import mymodule as sillyname                                from sys import version_info"""]

Definition at line 58 of file test_modulefinder.py.

Initial value:
00001 [
00002     "a.module",
00003     ["__future__",
00004      "a", "a.module",
00005      "a.b", "a.b.y", "a.b.z",
00006      "a.b.c", "a.b.c.moduleC",
00007      "a.b.c.d", "a.b.c.e",
00008      "a.b.x",
00009      "gc"],
00010     [], [],
00011     """\
00012 mymodule.pya/__init__.py                                from .b import y, z # a.b.y, a.b.za/module.py                                from __future__ import absolute_import # __future__                                import gc # gca/gc.pya/sys.pya/b/__init__.py                                from ..b import x # a.b.x                                #from a.b.c import moduleC                                from .c import moduleC # a.b.moduleCa/b/x.pya/b/y.pya/b/z.pya/b/g.pya/b/c/__init__.py                                from ..c import e # a.b.c.ea/b/c/moduleC.py                                from ..c import d # a.b.c.da/b/c/d.pya/b/c/e.pya/b/c/x.py"""]

Definition at line 111 of file test_modulefinder.py.

Initial value:
00001 [
00002     "a.module",
00003     ["a", "a.module",
00004      "a.sys",
00005      "a.b", "a.b.y", "a.b.z",
00006      "a.b.c", "a.b.c.d",
00007      "a.b.c.e",
00008      "a.b.c.moduleC",
00009      "a.b.c.f",
00010      "a.b.x",
00011      "a.another"],
00012     [], [],
00013     """\
00014 mymodule.pya/__init__.py                                from . import sys # a.sysa/another.pya/module.py                                from .b import y, z # a.b.y, a.b.za/gc.pya/sys.pya/b/__init__.py                                from .c import moduleC # a.b.c.moduleC                                from .c import d # a.b.c.da/b/x.pya/b/y.pya/b/z.pya/b/c/__init__.py                                from . import e # a.b.c.ea/b/c/moduleC.py                                #                                from . import f   # a.b.c.f                                from .. import x  # a.b.x                                from ... import another # a.anothera/b/c/d.pya/b/c/e.pya/b/c/f.py"""]

Definition at line 147 of file test_modulefinder.py.

Initial value:
00001 [
00002     "a.module",
00003     ["a", "a.module"],
00004     ["a.bar"],
00005     [],
00006     """\
00007 a/__init__.py                                def foo(): passa/module.py                                from . import foo                                from . import bar"""]

Definition at line 186 of file test_modulefinder.py.

Definition at line 11 of file test_modulefinder.py.

list test.test_modulefinder.TEST_PATH = [TEST_DIR, os.path.dirname(__future__.__file__)]

Definition at line 12 of file test_modulefinder.py.