Back to index

python3.2  3.2.2
Public Member Functions | Static Public Attributes
test.test_symtable.SymtableTest Class Reference

List of all members.

Public Member Functions

def test_type
def test_optimized
def test_nested
def test_children
def test_lineno
def test_function_info
def test_globals
def test_local
def test_referenced
def test_parameters
def test_symbol_lookup
def test_namespaces
def test_assigned
def test_imported
def test_name
def test_class_info
def test_filename_correct
def test_eval
def test_single
def test_exec

Static Public Attributes

tuple top = symtable.symtable(TEST_CODE, "?", "exec")
tuple Mine = find_block(top, "Mine")
tuple a_method = find_block(Mine, "a_method")
tuple spam = find_block(top, "spam")
tuple internal = find_block(spam, "internal")
tuple foo = find_block(top, "foo")

Detailed Description

Definition at line 43 of file test_symtable.py.


Member Function Documentation

Definition at line 130 of file test_symtable.py.

00130 
00131     def test_assigned(self):
00132         self.assertTrue(self.spam.lookup("x").is_assigned())
00133         self.assertTrue(self.spam.lookup("bar").is_assigned())
00134         self.assertTrue(self.top.lookup("spam").is_assigned())
00135         self.assertTrue(self.Mine.lookup("a_method").is_assigned())
00136         self.assertFalse(self.internal.lookup("x").is_assigned())

Here is the call graph for this function:

Definition at line 72 of file test_symtable.py.

00072 
00073     def test_children(self):
00074         self.assertTrue(self.top.has_children())
00075         self.assertTrue(self.Mine.has_children())
00076         self.assertFalse(self.foo.has_children())

Here is the call graph for this function:

Definition at line 146 of file test_symtable.py.

00146 
00147     def test_class_info(self):
00148         self.assertEqual(self.Mine.get_methods(), ('a_method',))

Here is the call graph for this function:

Definition at line 162 of file test_symtable.py.

00162 
00163     def test_eval(self):
00164         symbols = symtable.symtable("42", "?", "eval")

Definition at line 168 of file test_symtable.py.

00168 
00169     def test_exec(self):
00170         symbols = symtable.symtable("def f(x): return x", "?", "exec")
00171 

Definition at line 149 of file test_symtable.py.

00149 
00150     def test_filename_correct(self):
00151         ### Bug tickler: SyntaxError file name correct whether error raised
00152         ### while parsing or building symbol table.
00153         def checkfilename(brokencode):
00154             try:
00155                 symtable.symtable(brokencode, "spam", "exec")
00156             except SyntaxError as e:
00157                 self.assertEqual(e.filename, "spam")
00158             else:
00159                 self.fail("no SyntaxError for %r" % (brokencode,))
00160         checkfilename("def f(x): foo)(")  # parse-time
00161         checkfilename("def f(x): global x")  # symtable-build-time

Here is the call graph for this function:

Definition at line 81 of file test_symtable.py.

00081 
00082     def test_function_info(self):
00083         func = self.spam
00084         self.assertEqual(func.get_parameters(), ("a", "b", "kw", "var"))
00085         self.assertEqual(func.get_locals(),
00086                          ("a", "b", "internal", "kw", "var", "x"))
00087         self.assertEqual(func.get_globals(), ("bar", "glob"))
00088         self.assertEqual(self.internal.get_frees(), ("x",))

Here is the call graph for this function:

Definition at line 89 of file test_symtable.py.

00089 
00090     def test_globals(self):
00091         self.assertTrue(self.spam.lookup("glob").is_global())
00092         self.assertFalse(self.spam.lookup("glob").is_declared_global())
00093         self.assertTrue(self.spam.lookup("bar").is_global())
00094         self.assertTrue(self.spam.lookup("bar").is_declared_global())
00095         self.assertFalse(self.internal.lookup("x").is_global())
00096         self.assertFalse(self.Mine.lookup("instance_var").is_global())

Here is the call graph for this function:

Definition at line 137 of file test_symtable.py.

00137 
00138     def test_imported(self):
00139         self.assertTrue(self.top.lookup("sys").is_imported())

Here is the call graph for this function:

Definition at line 77 of file test_symtable.py.

00077 
00078     def test_lineno(self):
00079         self.assertEqual(self.top.get_lineno(), 0)
00080         self.assertEqual(self.spam.get_lineno(), 11)

Here is the call graph for this function:

Definition at line 97 of file test_symtable.py.

00097 
00098     def test_local(self):
00099         self.assertTrue(self.spam.lookup("x").is_local())
00100         self.assertFalse(self.internal.lookup("x").is_local())

Here is the call graph for this function:

Definition at line 140 of file test_symtable.py.

00140 
00141     def test_name(self):
00142         self.assertEqual(self.top.get_name(), "top")
00143         self.assertEqual(self.spam.get_name(), "spam")
00144         self.assertEqual(self.spam.lookup("x").get_name(), "x")
00145         self.assertEqual(self.Mine.get_name(), "Mine")

Here is the call graph for this function:

Definition at line 117 of file test_symtable.py.

00117 
00118     def test_namespaces(self):
00119         self.assertTrue(self.top.lookup("Mine").is_namespace())
00120         self.assertTrue(self.Mine.lookup("a_method").is_namespace())
00121         self.assertTrue(self.top.lookup("spam").is_namespace())
00122         self.assertTrue(self.spam.lookup("internal").is_namespace())
00123         self.assertTrue(self.top.lookup("namespace_test").is_namespace())
00124         self.assertFalse(self.spam.lookup("x").is_namespace())
00125 
00126         self.assertTrue(self.top.lookup("spam").get_namespace() is self.spam)
00127         ns_test = self.top.lookup("namespace_test")
00128         self.assertEqual(len(ns_test.get_namespaces()), 2)
00129         self.assertRaises(ValueError, ns_test.get_namespace)

Here is the call graph for this function:

Definition at line 66 of file test_symtable.py.

00066 
00067     def test_nested(self):
00068         self.assertFalse(self.top.is_nested())
00069         self.assertFalse(self.Mine.is_nested())
00070         self.assertFalse(self.spam.is_nested())
00071         self.assertTrue(self.internal.is_nested())

Here is the call graph for this function:

Definition at line 60 of file test_symtable.py.

00060 
00061     def test_optimized(self):
00062         self.assertFalse(self.top.is_optimized())
00063         self.assertFalse(self.top.has_exec())
00064 
00065         self.assertTrue(self.spam.is_optimized())

Here is the call graph for this function:

Definition at line 106 of file test_symtable.py.

00106 
00107     def test_parameters(self):
00108         for sym in ("a", "var", "kw"):
00109             self.assertTrue(self.spam.lookup(sym).is_parameter())
00110         self.assertFalse(self.spam.lookup("x").is_parameter())

Here is the call graph for this function:

Definition at line 101 of file test_symtable.py.

00101 
00102     def test_referenced(self):
00103         self.assertTrue(self.internal.lookup("x").is_referenced())
00104         self.assertTrue(self.spam.lookup("internal").is_referenced())
00105         self.assertFalse(self.spam.lookup("x").is_referenced())

Here is the call graph for this function:

Definition at line 165 of file test_symtable.py.

00165 
00166     def test_single(self):
00167         symbols = symtable.symtable("42", "?", "single")

Definition at line 111 of file test_symtable.py.

00111 
00112     def test_symbol_lookup(self):
00113         self.assertEqual(len(self.top.get_identifiers()),
00114                          len(self.top.get_symbols()))
00115 
00116         self.assertRaises(KeyError, self.top.lookup, "not_here")

Here is the call graph for this function:

Definition at line 53 of file test_symtable.py.

00053 
00054     def test_type(self):
00055         self.assertEqual(self.top.get_type(), "module")
00056         self.assertEqual(self.Mine.get_type(), "class")
00057         self.assertEqual(self.a_method.get_type(), "function")
00058         self.assertEqual(self.spam.get_type(), "function")
00059         self.assertEqual(self.internal.get_type(), "function")

Here is the call graph for this function:


Member Data Documentation

Definition at line 48 of file test_symtable.py.

Definition at line 51 of file test_symtable.py.

Definition at line 50 of file test_symtable.py.

Definition at line 47 of file test_symtable.py.

Definition at line 49 of file test_symtable.py.

Definition at line 45 of file test_symtable.py.


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