Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1)

Side by Side Diff: Lib/test/test_ast.py

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/test/support.py ('k') | Lib/test/test_bz2.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 import sys, unittest 1 import sys, unittest
2 from test import support 2 from test import support
3 import ast 3 import ast
4 4
5 def to_tuple(t): 5 def to_tuple(t):
6 if t is None or isinstance(t, (str, int, complex)): 6 if t is None or isinstance(t, (str, int, complex)):
7 return t 7 return t
8 elif isinstance(t, list): 8 elif isinstance(t, list):
9 return [to_tuple(e) for e in t] 9 return [to_tuple(e) for e in t]
10 result = [t.__class__.__name__] 10 result = [t.__class__.__name__]
11 if hasattr(t, 'lineno') and hasattr(t, 'col_offset'): 11 if hasattr(t, 'lineno') and hasattr(t, 'col_offset'):
12 result.append((t.lineno, t.col_offset)) 12 result.append((t.lineno, t.col_offset))
13 if t._fields is None: 13 if t._fields is None:
14 return tuple(result) 14 return tuple(result)
15 for f in t._fields: 15 for f in t._fields:
16 result.append(to_tuple(getattr(t, f))) 16 result.append(to_tuple(getattr(t, f)))
17 return tuple(result) 17 return tuple(result)
18 18
19 19
20 # These tests are compiled through "exec" 20 # These tests are compiled through "exec"
21 # There should be atleast one test per statement 21 # There should be atleast one test per statement
22 exec_tests = [ 22 exec_tests = [
23 # None
24 "None",
25 # FunctionDef 23 # FunctionDef
26 "def f(): pass", 24 "def f(): pass",
27 # FunctionDef with arg
28 "def f(a): pass",
29 # FunctionDef with arg and default value
30 "def f(a=0): pass",
31 # FunctionDef with varargs
32 "def f(*args): pass",
33 # FunctionDef with kwargs
34 "def f(**kwargs): pass",
35 # FunctionDef with all kind of args
36 "def f(a, b=1, c=None, d=[], e={}, *args, **kwargs): pass",
37 # ClassDef 25 # ClassDef
38 "class C:pass", 26 "class C:pass",
39 # ClassDef, new style class
40 "class C(object): pass",
41 # Return 27 # Return
42 "def f():return 1", 28 "def f():return 1",
43 # Delete 29 # Delete
44 "del v", 30 "del v",
45 # Assign 31 # Assign
46 "v = 1", 32 "v = 1",
47 # AugAssign 33 # AugAssign
48 "v += 1", 34 "v += 1",
49 # For 35 # For
50 "for v in v:pass", 36 "for v in v:pass",
(...skipping 23 matching lines...) Expand all
74 # Pass, 60 # Pass,
75 "pass", 61 "pass",
76 # Break 62 # Break
77 "break", 63 "break",
78 # Continue 64 # Continue
79 "continue", 65 "continue",
80 # for statements with naked tuples (see http://bugs.python.org/issue6704) 66 # for statements with naked tuples (see http://bugs.python.org/issue6704)
81 "for a,b in c: pass", 67 "for a,b in c: pass",
82 "[(a,b) for a,b in c]", 68 "[(a,b) for a,b in c]",
83 "((a,b) for a,b in c)", 69 "((a,b) for a,b in c)",
84 "((a,b) for (a,b) in c)",
85 # Multiline generator expression (test for .lineno & .col_offset)
86 """(
87 (
88 Aa
89 ,
90 Bb
91 )
92 for
93 Aa
94 ,
95 Bb in Cc
96 )""",
97 # dictcomp
98 "{a : b for w in x for m in p if g}",
99 # dictcomp with naked tuple
100 "{a : b for v,w in x}",
101 # setcomp
102 "{r for l in x if g}",
103 # setcomp with naked tuple
104 "{r for l,m in x}",
105 ] 70 ]
106 71
107 # These are compiled through "single" 72 # These are compiled through "single"
108 # because of overlap with "eval", it just tests what 73 # because of overlap with "eval", it just tests what
109 # can't be tested with "eval" 74 # can't be tested with "eval"
110 single_tests = [ 75 single_tests = [
111 "1+2" 76 "1+2"
112 ] 77 ]
113 78
114 # These are compiled through "eval" 79 # These are compiled through "eval"
115 # It should test all expressions 80 # It should test all expressions
116 eval_tests = [ 81 eval_tests = [
117 # None
118 "None",
119 # BoolOp 82 # BoolOp
120 "a and b", 83 "a and b",
121 # BinOp 84 # BinOp
122 "a + b", 85 "a + b",
123 # UnaryOp 86 # UnaryOp
124 "not v", 87 "not v",
125 # Lambda 88 # Lambda
126 "lambda:None", 89 "lambda:None",
127 # Dict 90 # Dict
128 "{ 1:2 }", 91 "{ 1:2 }",
129 # Empty dict
130 "{}",
131 # Set
132 "{None,}",
133 # Multiline dict (test for .lineno & .col_offset)
134 """{
135 1
136 :
137 2
138 }""",
139 # ListComp 92 # ListComp
140 "[a for b in c if d]", 93 "[a for b in c if d]",
141 # GeneratorExp 94 # GeneratorExp
142 "(a for b in c if d)", 95 "(a for b in c if d)",
143 # Yield - yield expressions can't work outside a function 96 # Yield - yield expressions can't work outside a function
144 # 97 #
145 # Compare 98 # Compare
146 "1 < 2 < 3", 99 "1 < 2 < 3",
147 # Call 100 # Call
148 "f(1,2,c=3,*d,**e)", 101 "f(1,2,c=3,*d,**e)",
149 # Num 102 # Num
150 "10", 103 "10",
151 # Str 104 # Str
152 "'string'", 105 "'string'",
153 # Attribute 106 # Attribute
154 "a.b", 107 "a.b",
155 # Subscript 108 # Subscript
156 "a[b:c]", 109 "a[b:c]",
157 # Name 110 # Name
158 "v", 111 "v",
159 # List 112 # List
160 "[1,2,3]", 113 "[1,2,3]",
161 # Empty list
162 "[]",
163 # Tuple 114 # Tuple
164 "1,2,3", 115 "1,2,3",
165 # Tuple
166 "(1,2,3)",
167 # Empty tuple
168 "()",
169 # Combination 116 # Combination
170 "a.b.c.d(a.b[1:2])", 117 "a.b.c.d(a.b[1:2])",
171 118
172 ] 119 ]
173 120
174 # TODO: expr_context, slice, boolop, operator, unaryop, cmpop, comprehension 121 # TODO: expr_context, slice, boolop, operator, unaryop, cmpop, comprehension
175 # excepthandler, arguments, keywords, alias 122 # excepthandler, arguments, keywords, alias
176 123
177 class AST_Tests(unittest.TestCase): 124 class AST_Tests(unittest.TestCase):
178 125
179 def _assertTrueorder(self, ast_node, parent_pos): 126 def _assertTrueorder(self, ast_node, parent_pos):
180 if not isinstance(ast_node, ast.AST) or ast_node._fields is None: 127 if not isinstance(ast_node, ast.AST) or ast_node._fields is None:
181 return 128 return
182 if isinstance(ast_node, (ast.expr, ast.stmt, ast.excepthandler)): 129 if isinstance(ast_node, (ast.expr, ast.stmt, ast.excepthandler)):
183 node_pos = (ast_node.lineno, ast_node.col_offset) 130 node_pos = (ast_node.lineno, ast_node.col_offset)
184 self.assertTrue(node_pos >= parent_pos) 131 self.assertTrue(node_pos >= parent_pos)
185 parent_pos = (ast_node.lineno, ast_node.col_offset) 132 parent_pos = (ast_node.lineno, ast_node.col_offset)
186 for name in ast_node._fields: 133 for name in ast_node._fields:
187 value = getattr(ast_node, name) 134 value = getattr(ast_node, name)
188 if isinstance(value, list): 135 if isinstance(value, list):
189 for child in value: 136 for child in value:
190 self._assertTrueorder(child, parent_pos) 137 self._assertTrueorder(child, parent_pos)
191 elif value is not None: 138 elif value is not None:
192 self._assertTrueorder(value, parent_pos) 139 self._assertTrueorder(value, parent_pos)
193
194 def test_AST_objects(self):
195 x = ast.AST()
196 self.assertEqual(x._fields, ())
197
198 with self.assertRaises(AttributeError):
199 x.vararg
200
201 with self.assertRaises(AttributeError):
202 x.foobar = 21
203
204 with self.assertRaises(AttributeError):
205 ast.AST(lineno=2)
206
207 with self.assertRaises(TypeError):
208 # "_ast.AST constructor takes 0 positional arguments"
209 ast.AST(2)
210 140
211 def test_snippets(self): 141 def test_snippets(self):
212 for input, output, kind in ((exec_tests, exec_results, "exec"), 142 for input, output, kind in ((exec_tests, exec_results, "exec"),
213 (single_tests, single_results, "single"), 143 (single_tests, single_results, "single"),
214 (eval_tests, eval_results, "eval")): 144 (eval_tests, eval_results, "eval")):
215 for i, o in zip(input, output): 145 for i, o in zip(input, output):
216 ast_tree = compile(i, "?", kind, ast.PyCF_ONLY_AST) 146 ast_tree = compile(i, "?", kind, ast.PyCF_ONLY_AST)
217 self.assertEqual(to_tuple(ast_tree), o) 147 self.assertEqual(to_tuple(ast_tree), o)
218 self._assertTrueorder(ast_tree, (0, 0)) 148 self._assertTrueorder(ast_tree, (0, 0))
219 149
220 def test_slice(self): 150 def test_slice(self):
221 slc = ast.parse("x[::]").body[0].value.slice 151 slc = ast.parse("x[::]").body[0].value.slice
222 self.assertIsNone(slc.upper) 152 self.assertIsNone(slc.upper)
223 self.assertIsNone(slc.lower) 153 self.assertIsNone(slc.lower)
224 self.assertIsNone(slc.step) 154 self.assertIsNone(slc.step)
225 155
226 def test_from_import(self): 156 def test_from_import(self):
227 im = ast.parse("from . import y").body[0] 157 im = ast.parse("from . import y").body[0]
228 self.assertIsNone(im.module) 158 self.assertIsNone(im.module)
229 159
230 def test_base_classes(self): 160 def test_base_classes(self):
231 self.assertTrue(issubclass(ast.For, ast.stmt)) 161 self.assertTrue(issubclass(ast.For, ast.stmt))
232 self.assertTrue(issubclass(ast.Name, ast.expr)) 162 self.assertTrue(issubclass(ast.Name, ast.expr))
233 self.assertTrue(issubclass(ast.stmt, ast.AST)) 163 self.assertTrue(issubclass(ast.stmt, ast.AST))
234 self.assertTrue(issubclass(ast.expr, ast.AST)) 164 self.assertTrue(issubclass(ast.expr, ast.AST))
235 self.assertTrue(issubclass(ast.comprehension, ast.AST)) 165 self.assertTrue(issubclass(ast.comprehension, ast.AST))
236 self.assertTrue(issubclass(ast.Gt, ast.AST)) 166 self.assertTrue(issubclass(ast.Gt, ast.AST))
237 167
238 def test_field_attr_existence(self):
239 for name, item in ast.__dict__.items():
240 if isinstance(item, type) and name != 'AST' and name[0].isupper():
241 x = item()
242 if isinstance(x, ast.AST):
243 self.assertEqual(type(x._fields), tuple)
244
245 def test_arguments(self):
246 x = ast.arguments()
247 self.assertEqual(x._fields, ('args', 'vararg', 'varargannotation',
248 'kwonlyargs', 'kwarg', 'kwargannotation',
249 'defaults', 'kw_defaults'))
250
251 with self.assertRaises(AttributeError):
252 x.vararg
253
254 x = ast.arguments(*range(1, 9))
255 self.assertEqual(x.vararg, 2)
256
257 def test_field_attr_writable(self):
258 x = ast.Num()
259 # We can assign to _fields
260 x._fields = 666
261 self.assertEqual(x._fields, 666)
262
263 def test_classattrs(self):
264 x = ast.Num()
265 self.assertEqual(x._fields, ('n',))
266
267 with self.assertRaises(AttributeError):
268 x.n
269
270 x = ast.Num(42)
271 self.assertEqual(x.n, 42)
272
273 with self.assertRaises(AttributeError):
274 x.lineno
275
276 with self.assertRaises(AttributeError):
277 x.foobar
278
279 x = ast.Num(lineno=2)
280 self.assertEqual(x.lineno, 2)
281
282 x = ast.Num(42, lineno=0)
283 self.assertEqual(x.lineno, 0)
284 self.assertEqual(x._fields, ('n',))
285 self.assertEqual(x.n, 42)
286
287 self.assertRaises(TypeError, ast.Num, 1, 2)
288 self.assertRaises(TypeError, ast.Num, 1, 2, lineno=0)
289
290 def test_module(self):
291 body = [ast.Num(42)]
292 x = ast.Module(body)
293 self.assertEqual(x.body, body)
294
295 def test_nodeclasses(self): 168 def test_nodeclasses(self):
296 # Zero arguments constructor explicitely allowed
297 x = ast.BinOp()
298 self.assertEqual(x._fields, ('left', 'op', 'right'))
299
300 # Random attribute allowed too
301 x.foobarbaz = 5
302 self.assertEqual(x.foobarbaz, 5)
303
304 n1 = ast.Num(1)
305 n3 = ast.Num(3)
306 addop = ast.Add()
307 x = ast.BinOp(n1, addop, n3)
308 self.assertEqual(x.left, n1)
309 self.assertEqual(x.op, addop)
310 self.assertEqual(x.right, n3)
311
312 x = ast.BinOp(1, 2, 3)
313 self.assertEqual(x.left, 1)
314 self.assertEqual(x.op, 2)
315 self.assertEqual(x.right, 3)
316
317 x = ast.BinOp(1, 2, 3, lineno=0) 169 x = ast.BinOp(1, 2, 3, lineno=0)
318 self.assertEqual(x.left, 1) 170 self.assertEqual(x.left, 1)
319 self.assertEqual(x.op, 2) 171 self.assertEqual(x.op, 2)
320 self.assertEqual(x.right, 3) 172 self.assertEqual(x.right, 3)
321 self.assertEqual(x.lineno, 0) 173 self.assertEqual(x.lineno, 0)
322 174
323 # node raises exception when not given enough arguments 175 # node raises exception when not given enough arguments
324 self.assertRaises(TypeError, ast.BinOp, 1, 2) 176 self.assertRaises(TypeError, ast.BinOp, 1, 2)
325 # node raises exception when given too many arguments
326 self.assertRaises(TypeError, ast.BinOp, 1, 2, 3, 4)
327 # node raises exception when not given enough arguments
328 self.assertRaises(TypeError, ast.BinOp, 1, 2, lineno=0)
329 # node raises exception when given too many arguments
330 self.assertRaises(TypeError, ast.BinOp, 1, 2, 3, 4, lineno=0)
331 177
332 # can set attributes through kwargs too 178 # can set attributes through kwargs too
333 x = ast.BinOp(left=1, op=2, right=3, lineno=0) 179 x = ast.BinOp(left=1, op=2, right=3, lineno=0)
334 self.assertEqual(x.left, 1) 180 self.assertEqual(x.left, 1)
335 self.assertEqual(x.op, 2) 181 self.assertEqual(x.op, 2)
336 self.assertEqual(x.right, 3) 182 self.assertEqual(x.right, 3)
337 self.assertEqual(x.lineno, 0) 183 self.assertEqual(x.lineno, 0)
338 184
339 # Random kwargs also allowed
340 x = ast.BinOp(1, 2, 3, foobarbaz=42)
341 self.assertEqual(x.foobarbaz, 42)
342
343 def test_no_fields(self):
344 # this used to fail because Sub._fields was None 185 # this used to fail because Sub._fields was None
345 x = ast.Sub() 186 x = ast.Sub()
346 self.assertEqual(x._fields, ())
347 187
348 def test_pickling(self): 188 def test_pickling(self):
349 import pickle 189 import pickle
350 mods = [pickle] 190 mods = [pickle]
351 try: 191 try:
352 import cPickle 192 import cPickle
353 mods.append(cPickle) 193 mods.append(cPickle)
354 except ImportError: 194 except ImportError:
355 pass 195 pass
356 protocols = [0, 1, 2] 196 protocols = [0, 1, 2]
357 for mod in mods: 197 for mod in mods:
358 for protocol in protocols: 198 for protocol in protocols:
359 for ast in (compile(i, "?", "exec", 0x400) for i in exec_tests): 199 for ast in (compile(i, "?", "exec", 0x400) for i in exec_tests):
360 ast2 = mod.loads(mod.dumps(ast, protocol)) 200 ast2 = mod.loads(mod.dumps(ast, protocol))
361 self.assertEqual(to_tuple(ast2), to_tuple(ast)) 201 self.assertEqual(to_tuple(ast2), to_tuple(ast))
362 202
363 def test_invalid_sum(self): 203 def test_invalid_sum(self):
364 pos = dict(lineno=2, col_offset=3) 204 pos = dict(lineno=2, col_offset=3)
365 m = ast.Module([ast.Expr(ast.expr(**pos), **pos)]) 205 m = ast.Module([ast.Expr(ast.expr(**pos), **pos)])
366 with self.assertRaises(TypeError) as cm: 206 with self.assertRaises(TypeError) as cm:
367 compile(m, "<test>", "exec") 207 compile(m, "<test>", "exec")
368 self.assertIn("but got <_ast.expr", str(cm.exception)) 208 self.assertIn("but got <_ast.expr", str(cm.exception))
369
370 def test_invalid_identitifer(self):
371 m = ast.Module([ast.Expr(ast.Name(42, ast.Load()))])
372 ast.fix_missing_locations(m)
373 with self.assertRaises(TypeError) as cm:
374 compile(m, "<test>", "exec")
375 self.assertIn("identifier must be of type str", str(cm.exception))
376
377 def test_invalid_string(self):
378 m = ast.Module([ast.Expr(ast.Str(42))])
379 ast.fix_missing_locations(m)
380 with self.assertRaises(TypeError) as cm:
381 compile(m, "<test>", "exec")
382 self.assertIn("string must be of type str", str(cm.exception))
383 209
384 210
385 class ASTHelpers_Test(unittest.TestCase): 211 class ASTHelpers_Test(unittest.TestCase):
386 212
387 def test_parse(self): 213 def test_parse(self):
388 a = ast.parse('foo(1 + 1)') 214 a = ast.parse('foo(1 + 1)')
389 b = compile('foo(1 + 1)', '<unknown>', 'exec', ast.PyCF_ONLY_AST) 215 b = compile('foo(1 + 1)', '<unknown>', 'exec', ast.PyCF_ONLY_AST)
390 self.assertEqual(ast.dump(a), ast.dump(b)) 216 self.assertEqual(ast.dump(a), ast.dump(b))
391 217
392 def test_dump(self): 218 def test_dump(self):
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 print(kind+"_results = [") 328 print(kind+"_results = [")
503 for s in statements: 329 for s in statements:
504 print(repr(to_tuple(compile(s, "?", kind, 0x400)))+",") 330 print(repr(to_tuple(compile(s, "?", kind, 0x400)))+",")
505 print("]") 331 print("]")
506 print("main()") 332 print("main()")
507 raise SystemExit 333 raise SystemExit
508 test_main() 334 test_main()
509 335
510 #### EVERYTHING BELOW IS GENERATED ##### 336 #### EVERYTHING BELOW IS GENERATED #####
511 exec_results = [ 337 exec_results = [
512 ('Module', [('Expr', (1, 0), ('Name', (1, 0), 'None', ('Load',)))]),
513 ('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [], None, None, [], None, None, [], []), [('Pass', (1, 9))], [], None)]), 338 ('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [], None, None, [], None, None, [], []), [('Pass', (1, 9))], [], None)]),
514 ('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [('arg', 'a', None)], Non e, None, [], None, None, [], []), [('Pass', (1, 10))], [], None)]),
515 ('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [('arg', 'a', None)], Non e, None, [], None, None, [('Num', (1, 8), 0)], []), [('Pass', (1, 12))], [], Non e)]),
516 ('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [], 'args', None, [], Non e, None, [], []), [('Pass', (1, 14))], [], None)]),
517 ('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [], None, None, [], 'kwar gs', None, [], []), [('Pass', (1, 17))], [], None)]),
518 ('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [('arg', 'a', None), ('ar g', 'b', None), ('arg', 'c', None), ('arg', 'd', None), ('arg', 'e', None)], 'ar gs', None, [], 'kwargs', None, [('Num', (1, 11), 1), ('Name', (1, 16), 'None', ( 'Load',)), ('List', (1, 24), [], ('Load',)), ('Dict', (1, 30), [], [])], []), [( 'Pass', (1, 52))], [], None)]),
519 ('Module', [('ClassDef', (1, 0), 'C', [], [], None, None, [('Pass', (1, 8))], [] )]), 339 ('Module', [('ClassDef', (1, 0), 'C', [], [], None, None, [('Pass', (1, 8))], [] )]),
520 ('Module', [('ClassDef', (1, 0), 'C', [('Name', (1, 8), 'object', ('Load',))], [ ], None, None, [('Pass', (1, 17))], [])]),
521 ('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [], None, None, [], None, None, [], []), [('Return', (1, 8), ('Num', (1, 15), 1))], [], None)]), 340 ('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [], None, None, [], None, None, [], []), [('Return', (1, 8), ('Num', (1, 15), 1))], [], None)]),
522 ('Module', [('Delete', (1, 0), [('Name', (1, 4), 'v', ('Del',))])]), 341 ('Module', [('Delete', (1, 0), [('Name', (1, 4), 'v', ('Del',))])]),
523 ('Module', [('Assign', (1, 0), [('Name', (1, 0), 'v', ('Store',))], ('Num', (1, 4), 1))]), 342 ('Module', [('Assign', (1, 0), [('Name', (1, 0), 'v', ('Store',))], ('Num', (1, 4), 1))]),
524 ('Module', [('AugAssign', (1, 0), ('Name', (1, 0), 'v', ('Store',)), ('Add',), ( 'Num', (1, 5), 1))]), 343 ('Module', [('AugAssign', (1, 0), ('Name', (1, 0), 'v', ('Store',)), ('Add',), ( 'Num', (1, 5), 1))]),
525 ('Module', [('For', (1, 0), ('Name', (1, 4), 'v', ('Store',)), ('Name', (1, 9), 'v', ('Load',)), [('Pass', (1, 11))], [])]), 344 ('Module', [('For', (1, 0), ('Name', (1, 4), 'v', ('Store',)), ('Name', (1, 9), 'v', ('Load',)), [('Pass', (1, 11))], [])]),
526 ('Module', [('While', (1, 0), ('Name', (1, 6), 'v', ('Load',)), [('Pass', (1, 8) )], [])]), 345 ('Module', [('While', (1, 0), ('Name', (1, 6), 'v', ('Load',)), [('Pass', (1, 8) )], [])]),
527 ('Module', [('If', (1, 0), ('Name', (1, 3), 'v', ('Load',)), [('Pass', (1, 5))], [])]), 346 ('Module', [('If', (1, 0), ('Name', (1, 3), 'v', ('Load',)), [('Pass', (1, 5))], [])]),
528 ('Module', [('With', (1, 0), [('withitem', ('Name', (1, 5), 'x', ('Load',)), ('N ame', (1, 10), 'y', ('Store',)))], [('Pass', (1, 13))])]), 347 ('Module', [('With', (1, 0), [('withitem', ('Name', (1, 5), 'x', ('Load',)), ('N ame', (1, 10), 'y', ('Store',)))], [('Pass', (1, 13))])]),
529 ('Module', [('With', (1, 0), [('withitem', ('Name', (1, 5), 'x', ('Load',)), ('N ame', (1, 10), 'y', ('Store',))), ('withitem', ('Name', (1, 13), 'z', ('Load',)) , ('Name', (1, 18), 'q', ('Store',)))], [('Pass', (1, 21))])]), 348 ('Module', [('With', (1, 0), [('withitem', ('Name', (1, 5), 'x', ('Load',)), ('N ame', (1, 10), 'y', ('Store',))), ('withitem', ('Name', (1, 13), 'z', ('Load',)) , ('Name', (1, 18), 'q', ('Store',)))], [('Pass', (1, 21))])]),
530 ('Module', [('Raise', (1, 0), ('Call', (1, 6), ('Name', (1, 6), 'Exception', ('L oad',)), [('Str', (1, 16), 'string')], [], None, None), None)]), 349 ('Module', [('Raise', (1, 0), ('Call', (1, 6), ('Name', (1, 6), 'Exception', ('L oad',)), [('Str', (1, 16), 'string')], [], None, None), None)]),
531 ('Module', [('Try', (1, 0), [('Pass', (2, 2))], [('ExceptHandler', (3, 0), ('Nam e', (3, 7), 'Exception', ('Load',)), None, [('Pass', (4, 2))])], [], [])]), 350 ('Module', [('Try', (1, 0), [('Pass', (2, 2))], [('ExceptHandler', (3, 0), ('Nam e', (3, 7), 'Exception', ('Load',)), None, [('Pass', (4, 2))])], [], [])]),
532 ('Module', [('Try', (1, 0), [('Pass', (2, 2))], [], [], [('Pass', (4, 2))])]), 351 ('Module', [('Try', (1, 0), [('Pass', (2, 2))], [], [], [('Pass', (4, 2))])]),
533 ('Module', [('Assert', (1, 0), ('Name', (1, 7), 'v', ('Load',)), None)]), 352 ('Module', [('Assert', (1, 0), ('Name', (1, 7), 'v', ('Load',)), None)]),
534 ('Module', [('Import', (1, 0), [('alias', 'sys', None)])]), 353 ('Module', [('Import', (1, 0), [('alias', 'sys', None)])]),
535 ('Module', [('ImportFrom', (1, 0), 'sys', [('alias', 'v', None)], 0)]), 354 ('Module', [('ImportFrom', (1, 0), 'sys', [('alias', 'v', None)], 0)]),
536 ('Module', [('Global', (1, 0), ['v'])]), 355 ('Module', [('Global', (1, 0), ['v'])]),
537 ('Module', [('Expr', (1, 0), ('Num', (1, 0), 1))]), 356 ('Module', [('Expr', (1, 0), ('Num', (1, 0), 1))]),
538 ('Module', [('Pass', (1, 0))]), 357 ('Module', [('Pass', (1, 0))]),
539 ('Module', [('Break', (1, 0))]), 358 ('Module', [('Break', (1, 0))]),
540 ('Module', [('Continue', (1, 0))]), 359 ('Module', [('Continue', (1, 0))]),
541 ('Module', [('For', (1, 0), ('Tuple', (1, 4), [('Name', (1, 4), 'a', ('Store',)) , ('Name', (1, 6), 'b', ('Store',))], ('Store',)), ('Name', (1, 11), 'c', ('Load ',)), [('Pass', (1, 14))], [])]), 360 ('Module', [('For', (1, 0), ('Tuple', (1, 4), [('Name', (1, 4), 'a', ('Store',)) , ('Name', (1, 6), 'b', ('Store',))], ('Store',)), ('Name', (1, 11), 'c', ('Load ',)), [('Pass', (1, 14))], [])]),
542 ('Module', [('Expr', (1, 0), ('ListComp', (1, 1), ('Tuple', (1, 2), [('Name', (1 , 2), 'a', ('Load',)), ('Name', (1, 4), 'b', ('Load',))], ('Load',)), [('compreh ension', ('Tuple', (1, 11), [('Name', (1, 11), 'a', ('Store',)), ('Name', (1, 13 ), 'b', ('Store',))], ('Store',)), ('Name', (1, 18), 'c', ('Load',)), [])]))]), 361 ('Module', [('Expr', (1, 0), ('ListComp', (1, 1), ('Tuple', (1, 2), [('Name', (1 , 2), 'a', ('Load',)), ('Name', (1, 4), 'b', ('Load',))], ('Load',)), [('compreh ension', ('Tuple', (1, 11), [('Name', (1, 11), 'a', ('Store',)), ('Name', (1, 13 ), 'b', ('Store',))], ('Store',)), ('Name', (1, 18), 'c', ('Load',)), [])]))]),
543 ('Module', [('Expr', (1, 0), ('GeneratorExp', (1, 1), ('Tuple', (1, 2), [('Name' , (1, 2), 'a', ('Load',)), ('Name', (1, 4), 'b', ('Load',))], ('Load',)), [('com prehension', ('Tuple', (1, 11), [('Name', (1, 11), 'a', ('Store',)), ('Name', (1 , 13), 'b', ('Store',))], ('Store',)), ('Name', (1, 18), 'c', ('Load',)), [])])) ]), 362 ('Module', [('Expr', (1, 0), ('GeneratorExp', (1, 1), ('Tuple', (1, 2), [('Name' , (1, 2), 'a', ('Load',)), ('Name', (1, 4), 'b', ('Load',))], ('Load',)), [('com prehension', ('Tuple', (1, 11), [('Name', (1, 11), 'a', ('Store',)), ('Name', (1 , 13), 'b', ('Store',))], ('Store',)), ('Name', (1, 18), 'c', ('Load',)), [])])) ]),
544 ('Module', [('Expr', (1, 0), ('GeneratorExp', (1, 1), ('Tuple', (1, 2), [('Name' , (1, 2), 'a', ('Load',)), ('Name', (1, 4), 'b', ('Load',))], ('Load',)), [('com prehension', ('Tuple', (1, 12), [('Name', (1, 12), 'a', ('Store',)), ('Name', (1 , 14), 'b', ('Store',))], ('Store',)), ('Name', (1, 20), 'c', ('Load',)), [])])) ]),
545 ('Module', [('Expr', (1, 0), ('GeneratorExp', (2, 4), ('Tuple', (3, 4), [('Name' , (3, 4), 'Aa', ('Load',)), ('Name', (5, 7), 'Bb', ('Load',))], ('Load',)), [('c omprehension', ('Tuple', (8, 4), [('Name', (8, 4), 'Aa', ('Store',)), ('Name', ( 10, 4), 'Bb', ('Store',))], ('Store',)), ('Name', (10, 10), 'Cc', ('Load',)), [] )]))]),
546 ('Module', [('Expr', (1, 0), ('DictComp', (1, 1), ('Name', (1, 1), 'a', ('Load', )), ('Name', (1, 5), 'b', ('Load',)), [('comprehension', ('Name', (1, 11), 'w', ('Store',)), ('Name', (1, 16), 'x', ('Load',)), []), ('comprehension', ('Name', (1, 22), 'm', ('Store',)), ('Name', (1, 27), 'p', ('Load',)), [('Name', (1, 32), 'g', ('Load',))])]))]),
547 ('Module', [('Expr', (1, 0), ('DictComp', (1, 1), ('Name', (1, 1), 'a', ('Load', )), ('Name', (1, 5), 'b', ('Load',)), [('comprehension', ('Tuple', (1, 11), [('N ame', (1, 11), 'v', ('Store',)), ('Name', (1, 13), 'w', ('Store',))], ('Store',) ), ('Name', (1, 18), 'x', ('Load',)), [])]))]),
548 ('Module', [('Expr', (1, 0), ('SetComp', (1, 1), ('Name', (1, 1), 'r', ('Load',) ), [('comprehension', ('Name', (1, 7), 'l', ('Store',)), ('Name', (1, 12), 'x', ('Load',)), [('Name', (1, 17), 'g', ('Load',))])]))]),
549 ('Module', [('Expr', (1, 0), ('SetComp', (1, 1), ('Name', (1, 1), 'r', ('Load',) ), [('comprehension', ('Tuple', (1, 7), [('Name', (1, 7), 'l', ('Store',)), ('Na me', (1, 9), 'm', ('Store',))], ('Store',)), ('Name', (1, 14), 'x', ('Load',)), [])]))]),
550 ] 363 ]
551 single_results = [ 364 single_results = [
552 ('Interactive', [('Expr', (1, 0), ('BinOp', (1, 0), ('Num', (1, 0), 1), ('Add',) , ('Num', (1, 2), 2)))]), 365 ('Interactive', [('Expr', (1, 0), ('BinOp', (1, 0), ('Num', (1, 0), 1), ('Add',) , ('Num', (1, 2), 2)))]),
553 ] 366 ]
554 eval_results = [ 367 eval_results = [
555 ('Expression', ('Name', (1, 0), 'None', ('Load',))),
556 ('Expression', ('BoolOp', (1, 0), ('And',), [('Name', (1, 0), 'a', ('Load',)), ( 'Name', (1, 6), 'b', ('Load',))])), 368 ('Expression', ('BoolOp', (1, 0), ('And',), [('Name', (1, 0), 'a', ('Load',)), ( 'Name', (1, 6), 'b', ('Load',))])),
557 ('Expression', ('BinOp', (1, 0), ('Name', (1, 0), 'a', ('Load',)), ('Add',), ('N ame', (1, 4), 'b', ('Load',)))), 369 ('Expression', ('BinOp', (1, 0), ('Name', (1, 0), 'a', ('Load',)), ('Add',), ('N ame', (1, 4), 'b', ('Load',)))),
558 ('Expression', ('UnaryOp', (1, 0), ('Not',), ('Name', (1, 4), 'v', ('Load',)))), 370 ('Expression', ('UnaryOp', (1, 0), ('Not',), ('Name', (1, 4), 'v', ('Load',)))),
559 ('Expression', ('Lambda', (1, 0), ('arguments', [], None, None, [], None, None, [], []), ('Name', (1, 7), 'None', ('Load',)))), 371 ('Expression', ('Lambda', (1, 0), ('arguments', [], None, None, [], None, None, [], []), ('Name', (1, 7), 'None', ('Load',)))),
560 ('Expression', ('Dict', (1, 0), [('Num', (1, 2), 1)], [('Num', (1, 4), 2)])), 372 ('Expression', ('Dict', (1, 0), [('Num', (1, 2), 1)], [('Num', (1, 4), 2)])),
561 ('Expression', ('Dict', (1, 0), [], [])),
562 ('Expression', ('Set', (1, 0), [('Name', (1, 1), 'None', ('Load',))])),
563 ('Expression', ('Dict', (1, 0), [('Num', (2, 6), 1)], [('Num', (4, 10), 2)])),
564 ('Expression', ('ListComp', (1, 1), ('Name', (1, 1), 'a', ('Load',)), [('compreh ension', ('Name', (1, 7), 'b', ('Store',)), ('Name', (1, 12), 'c', ('Load',)), [ ('Name', (1, 17), 'd', ('Load',))])])), 373 ('Expression', ('ListComp', (1, 1), ('Name', (1, 1), 'a', ('Load',)), [('compreh ension', ('Name', (1, 7), 'b', ('Store',)), ('Name', (1, 12), 'c', ('Load',)), [ ('Name', (1, 17), 'd', ('Load',))])])),
565 ('Expression', ('GeneratorExp', (1, 1), ('Name', (1, 1), 'a', ('Load',)), [('com prehension', ('Name', (1, 7), 'b', ('Store',)), ('Name', (1, 12), 'c', ('Load',) ), [('Name', (1, 17), 'd', ('Load',))])])), 374 ('Expression', ('GeneratorExp', (1, 1), ('Name', (1, 1), 'a', ('Load',)), [('com prehension', ('Name', (1, 7), 'b', ('Store',)), ('Name', (1, 12), 'c', ('Load',) ), [('Name', (1, 17), 'd', ('Load',))])])),
566 ('Expression', ('Compare', (1, 0), ('Num', (1, 0), 1), [('Lt',), ('Lt',)], [('Nu m', (1, 4), 2), ('Num', (1, 8), 3)])), 375 ('Expression', ('Compare', (1, 0), ('Num', (1, 0), 1), [('Lt',), ('Lt',)], [('Nu m', (1, 4), 2), ('Num', (1, 8), 3)])),
567 ('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',)))), 376 ('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',)))),
568 ('Expression', ('Num', (1, 0), 10)), 377 ('Expression', ('Num', (1, 0), 10)),
569 ('Expression', ('Str', (1, 0), 'string')), 378 ('Expression', ('Str', (1, 0), 'string')),
570 ('Expression', ('Attribute', (1, 0), ('Name', (1, 0), 'a', ('Load',)), 'b', ('Lo ad',))), 379 ('Expression', ('Attribute', (1, 0), ('Name', (1, 0), 'a', ('Load',)), 'b', ('Lo ad',))),
571 ('Expression', ('Subscript', (1, 0), ('Name', (1, 0), 'a', ('Load',)), ('Slice', ('Name', (1, 2), 'b', ('Load',)), ('Name', (1, 4), 'c', ('Load',)), None), ('Lo ad',))), 380 ('Expression', ('Subscript', (1, 0), ('Name', (1, 0), 'a', ('Load',)), ('Slice', ('Name', (1, 2), 'b', ('Load',)), ('Name', (1, 4), 'c', ('Load',)), None), ('Lo ad',))),
572 ('Expression', ('Name', (1, 0), 'v', ('Load',))), 381 ('Expression', ('Name', (1, 0), 'v', ('Load',))),
573 ('Expression', ('List', (1, 0), [('Num', (1, 1), 1), ('Num', (1, 3), 2), ('Num', (1, 5), 3)], ('Load',))), 382 ('Expression', ('List', (1, 0), [('Num', (1, 1), 1), ('Num', (1, 3), 2), ('Num', (1, 5), 3)], ('Load',))),
574 ('Expression', ('List', (1, 0), [], ('Load',))),
575 ('Expression', ('Tuple', (1, 0), [('Num', (1, 0), 1), ('Num', (1, 2), 2), ('Num' , (1, 4), 3)], ('Load',))), 383 ('Expression', ('Tuple', (1, 0), [('Num', (1, 0), 1), ('Num', (1, 2), 2), ('Num' , (1, 4), 3)], ('Load',))),
576 ('Expression', ('Tuple', (1, 1), [('Num', (1, 1), 1), ('Num', (1, 3), 2), ('Num' , (1, 5), 3)], ('Load',))),
577 ('Expression', ('Tuple', (1, 0), [], ('Load',))),
578 ('Expression', ('Call', (1, 0), ('Attribute', (1, 0), ('Attribute', (1, 0), ('At tribute', (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)), 384 ('Expression', ('Call', (1, 0), ('Attribute', (1, 0), ('Attribute', (1, 0), ('At tribute', (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)),
579 ] 385 ]
580 main() 386 main()
OLDNEW
« no previous file with comments | « Lib/test/support.py ('k') | Lib/test/test_bz2.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+