Back to index

python3.2  3.2.2
Public Member Functions | Private Member Functions
lib2to3.tests.test_util.Test_does_tree_import Class Reference

List of all members.

Public Member Functions

def does_tree_import
def try_with
def test_in_function

Private Member Functions

def _find_bind_rec

Detailed Description

Definition at line 106 of file test_util.py.


Member Function Documentation

def lib2to3.tests.test_util.Test_does_tree_import._find_bind_rec (   self,
  name,
  node 
) [private]

Definition at line 107 of file test_util.py.

00107 
00108     def _find_bind_rec(self, name, node):
00109         # Search a tree for a binding -- used to find the starting
00110         # point for these tests.
00111         c = fixer_util.find_binding(name, node)
00112         if c: return c
00113         for child in node.children:
00114             c = self._find_bind_rec(name, child)
00115             if c: return c

Here is the call graph for this function:

Here is the caller graph for this function:

def lib2to3.tests.test_util.Test_does_tree_import.does_tree_import (   self,
  package,
  name,
  string 
)

Definition at line 116 of file test_util.py.

00116 
00117     def does_tree_import(self, package, name, string):
00118         node = parse(string)
00119         # Find the binding of start -- that's what we'll go from
00120         node = self._find_bind_rec('start', node)
00121         return fixer_util.does_tree_import(package, name, node)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 147 of file test_util.py.

00147 
00148     def test_in_function(self):
00149         self.try_with("def foo():\n\tbar.baz()\n\tstart=3")

Here is the call graph for this function:

Definition at line 122 of file test_util.py.

00122 
00123     def try_with(self, string):
00124         failing_tests = (("a", "a", "from a import b"),
00125                          ("a.d", "a", "from a.d import b"),
00126                          ("d.a", "a", "from d.a import b"),
00127                          (None, "a", "import b"),
00128                          (None, "a", "import b, c, d"))
00129         for package, name, import_ in failing_tests:
00130             n = self.does_tree_import(package, name, import_ + "\n" + string)
00131             self.assertFalse(n)
00132             n = self.does_tree_import(package, name, string + "\n" + import_)
00133             self.assertFalse(n)
00134 
00135         passing_tests = (("a", "a", "from a import a"),
00136                          ("x", "a", "from x import a"),
00137                          ("x", "a", "from x import b, c, a, d"),
00138                          ("x.b", "a", "from x.b import a"),
00139                          ("x.b", "a", "from x.b import b, c, a, d"),
00140                          (None, "a", "import a"),
00141                          (None, "a", "import b, c, a, d"))
00142         for package, name, import_ in passing_tests:
00143             n = self.does_tree_import(package, name, import_ + "\n" + string)
00144             self.assertTrue(n)
00145             n = self.does_tree_import(package, name, string + "\n" + import_)
00146             self.assertTrue(n)

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: