(self)
| 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 = [ |
nothing calls this directly
no test coverage detected