Transformer that throws SyntaxError if 'syntaxerror' is in the code.
(lines)
| 167 | assert captured.stdout == '' |
| 168 | |
| 169 | def syntax_error_transformer(lines): |
| 170 | """Transformer that throws SyntaxError if 'syntaxerror' is in the code.""" |
| 171 | for line in lines: |
| 172 | pos = line.find('syntaxerror') |
| 173 | if pos >= 0: |
| 174 | e = SyntaxError('input contains "syntaxerror"') |
| 175 | e.text = line |
| 176 | e.offset = pos + 1 |
| 177 | raise e |
| 178 | return lines |
| 179 | |
| 180 | |
| 181 | class TerminalMagicsTestCase(unittest.TestCase): |