Back to index

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

Classes

class  AST_Tests
class  ASTHelpers_Test

Functions

def to_tuple
def test_main
def main

Variables

list exec_tests
list single_tests
list eval_tests
list exec_results
 EVERYTHING BELOW IS GENERATED #####.
list single_results
list eval_results

Function Documentation

Definition at line 493 of file test_ast.py.

00493 
00494 def main():
00495     if __name__ != '__main__':
00496         return
00497     if sys.argv[1:] == ['-g']:
00498         for statements, kind in ((exec_tests, "exec"), (single_tests, "single"),
00499                                  (eval_tests, "eval")):
00500             print(kind+"_results = [")
00501             for s in statements:
00502                 print(repr(to_tuple(compile(s, "?", kind, 0x400)))+",")
00503             print("]")
00504         print("main()")
00505         raise SystemExit
00506     test_main()

Here is the call graph for this function:

Definition at line 490 of file test_ast.py.

00490 
00491 def test_main():
00492     support.run_unittest(AST_Tests, ASTHelpers_Test)

Here is the caller graph for this function:

Definition at line 5 of file test_ast.py.

00005 
00006 def to_tuple(t):
00007     if t is None or isinstance(t, (str, int, complex)):
00008         return t
00009     elif isinstance(t, list):
00010         return [to_tuple(e) for e in t]
00011     result = [t.__class__.__name__]
00012     if hasattr(t, 'lineno') and hasattr(t, 'col_offset'):
00013         result.append((t.lineno, t.col_offset))
00014     if t._fields is None:
00015         return tuple(result)
00016     for f in t._fields:
00017         result.append(to_tuple(getattr(t, f)))
00018     return tuple(result)
00019 
00020 
00021 # These tests are compiled through "exec"
# There should be atleast one test per statement

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Initial value:
00001 [
00002 ('Expression', ('Name', (1, 0), 'None', ('Load',))),
00003 ('Expression', ('BoolOp', (1, 0), ('And',), [('Name', (1, 0), 'a', ('Load',)), ('Name', (1, 6), 'b', ('Load',))])),
00004 ('Expression', ('BinOp', (1, 0), ('Name', (1, 0), 'a', ('Load',)), ('Add',), ('Name', (1, 4), 'b', ('Load',)))),
00005 ('Expression', ('UnaryOp', (1, 0), ('Not',), ('Name', (1, 4), 'v', ('Load',)))),
00006 ('Expression', ('Lambda', (1, 0), ('arguments', [], None, None, [], None, None, [], []), ('Name', (1, 7), 'None', ('Load',)))),
00007 ('Expression', ('Dict', (1, 0), [('Num', (1, 2), 1)], [('Num', (1, 4), 2)])),
00008 ('Expression', ('Dict', (1, 0), [], [])),
00009 ('Expression', ('Set', (1, 0), [('Name', (1, 1), 'None', ('Load',))])),
00010 ('Expression', ('Dict', (1, 0), [('Num', (2, 6), 1)], [('Num', (4, 10), 2)])),
00011 ('Expression', ('ListComp', (1, 1), ('Name', (1, 1), 'a', ('Load',)), [('comprehension', ('Name', (1, 7), 'b', ('Store',)), ('Name', (1, 12), 'c', ('Load',)), [('Name', (1, 17), 'd', ('Load',))])])),
00012 ('Expression', ('GeneratorExp', (1, 1), ('Name', (1, 1), 'a', ('Load',)), [('comprehension', ('Name', (1, 7), 'b', ('Store',)), ('Name', (1, 12), 'c', ('Load',)), [('Name', (1, 17), 'd', ('Load',))])])),
00013 ('Expression', ('Compare', (1, 0), ('Num', (1, 0), 1), [('Lt',), ('Lt',)], [('Num', (1, 4), 2), ('Num', (1, 8), 3)])),
00014 ('Expression', ('Call', (1, 0), ('Name', (1, 0), 'f', ('Load',)), [('Num', (1, 2), 1), ('Num', (1, 4), 2)], [('keyword', 'c', ('Num', (1, 8), 3))], ('Name', (1, 11), 'd', ('Load',)), ('Name', (1, 15), 'e', ('Load',)))),
00015 ('Expression', ('Num', (1, 0), 10)),
00016 ('Expression', ('Str', (1, 0), 'string')),
00017 ('Expression', ('Attribute', (1, 0), ('Name', (1, 0), 'a', ('Load',)), 'b', ('Load',))),
00018 ('Expression', ('Subscript', (1, 0), ('Name', (1, 0), 'a', ('Load',)), ('Slice', ('Name', (1, 2), 'b', ('Load',)), ('Name', (1, 4), 'c', ('Load',)), None), ('Load',))),
00019 ('Expression', ('Name', (1, 0), 'v', ('Load',))),
00020 ('Expression', ('List', (1, 0), [('Num', (1, 1), 1), ('Num', (1, 3), 2), ('Num', (1, 5), 3)], ('Load',))),
00021 ('Expression', ('List', (1, 0), [], ('Load',))),
00022 ('Expression', ('Tuple', (1, 0), [('Num', (1, 0), 1), ('Num', (1, 2), 2), ('Num', (1, 4), 3)], ('Load',))),
00023 ('Expression', ('Tuple', (1, 1), [('Num', (1, 1), 1), ('Num', (1, 3), 2), ('Num', (1, 5), 3)], ('Load',))),
00024 ('Expression', ('Tuple', (1, 0), [], ('Load',))),
00025 ('Expression', ('Call', (1, 0), ('Attribute', (1, 0), ('Attribute', (1, 0), ('Attribute', (1, 0), ('Name', (1, 0), 'a', ('Load',)), 'b', ('Load',)), 'c', ('Load',)), 'd', ('Load',)), [('Subscript', (1, 8), ('Attribute', (1, 8), ('Name', (1, 8), 'a', ('Load',)), 'b', ('Load',)), ('Slice', ('Num', (1, 12), 1), ('Num', (1, 14), 2), None), ('Load',))], [], None, None)),
00026 ]

Definition at line 549 of file test_ast.py.

Definition at line 113 of file test_ast.py.

EVERYTHING BELOW IS GENERATED #####.

Definition at line 508 of file test_ast.py.

Definition at line 22 of file test_ast.py.

Initial value:
00001 [
00002 ('Interactive', [('Expr', (1, 0), ('BinOp', (1, 0), ('Num', (1, 0), 1), ('Add',), ('Num', (1, 2), 2)))]),
00003 ]

Definition at line 546 of file test_ast.py.

Initial value:
00001 [
00002     "1+2"
00003 ]

Definition at line 107 of file test_ast.py.