(self)
| 64 | self.assertEqual(type(y).__format__(y, ''), 'class') |
| 65 | |
| 66 | def test_ast(self): |
| 67 | # Inspired by http://bugs.python.org/issue24975 |
| 68 | class X: |
| 69 | def __init__(self): |
| 70 | self.called = False |
| 71 | def __call__(self): |
| 72 | self.called = True |
| 73 | return 4 |
| 74 | x = X() |
| 75 | expr = """ |
| 76 | a = 10 |
| 77 | f'{a * x()}'""" |
| 78 | t = ast.parse(expr) |
| 79 | c = compile(t, '', 'exec') |
| 80 | |
| 81 | # Make sure x was not called. |
| 82 | self.assertFalse(x.called) |
| 83 | |
| 84 | # Actually run the code. |
| 85 | exec(c) |
| 86 | |
| 87 | # Make sure x was called. |
| 88 | self.assertTrue(x.called) |
| 89 | |
| 90 | def test_ast_line_numbers(self): |
| 91 | expr = """ |
nothing calls this directly
no test coverage detected