MCPcopy Index your code
hub / github.com/python/cpython / test_optimization_levels__debug__

Method test_optimization_levels__debug__

Lib/test/test_ast/test_ast.py:154–167  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

152 optimize=optval)
153
154 def test_optimization_levels__debug__(self):
155 cases = [(-1, '__debug__'), (0, '__debug__'), (1, False), (2, False)]
156 for (optval, expected) in cases:
157 with self.subTest(optval=optval, expected=expected):
158 res1 = ast.parse("__debug__", optimize=optval)
159 res2 = ast.parse(ast.parse("__debug__"), optimize=optval)
160 for res in [res1, res2]:
161 self.assertIsInstance(res.body[0], ast.Expr)
162 if isinstance(expected, bool):
163 self.assertIsInstance(res.body[0].value, ast.Constant)
164 self.assertEqual(res.body[0].value.value, expected)
165 else:
166 self.assertIsInstance(res.body[0].value, ast.Name)
167 self.assertEqual(res.body[0].value.id, expected)
168
169 def test_invalid_position_information(self):
170 invalid_linenos = [

Callers

nothing calls this directly

Calls 4

assertIsInstanceMethod · 0.80
subTestMethod · 0.45
parseMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected