From 9f1189485669120cead81157aef7e7487b6a3152 2018-03-10 21:51:46 From: Thomas Kluyver Date: 2018-03-10 21:51:46 Subject: [PATCH] Update test for new transformation API --- diff --git a/IPython/terminal/tests/test_interactivshell.py b/IPython/terminal/tests/test_interactivshell.py index 3b1fd7a..41d838f 100644 --- a/IPython/terminal/tests/test_interactivshell.py +++ b/IPython/terminal/tests/test_interactivshell.py @@ -96,9 +96,7 @@ class InteractiveShellTestCase(unittest.TestCase): @mock_input def test_inputtransformer_syntaxerror(self): ip = get_ipython() - transformer = SyntaxErrorTransformer() - ip.input_splitter.python_line_transforms.append(transformer) - ip.input_transformer_manager.python_line_transforms.append(transformer) + ip.input_transformer_manager.line_transforms.append(syntax_error_transformer) try: #raise Exception @@ -112,8 +110,7 @@ class InteractiveShellTestCase(unittest.TestCase): yield u'print(4*4)' finally: - ip.input_splitter.python_line_transforms.remove(transformer) - ip.input_transformer_manager.python_line_transforms.remove(transformer) + ip.input_transformer_manager.line_transforms.remove(syntax_error_transformer) def test_plain_text_only(self): ip = get_ipython() @@ -146,20 +143,17 @@ class InteractiveShellTestCase(unittest.TestCase): self.assertEqual(data, {'text/plain': repr(obj)}) assert captured.stdout == '' - - -class SyntaxErrorTransformer(InputTransformer): - def push(self, line): +def syntax_error_transformer(lines): + """Transformer that throws SyntaxError if 'syntaxerror' is in the code.""" + for line in lines: pos = line.find('syntaxerror') if pos >= 0: e = SyntaxError('input contains "syntaxerror"') e.text = line e.offset = pos + 1 raise e - return line + return lines - def reset(self): - pass class TerminalMagicsTestCase(unittest.TestCase): def test_paste_magics_blankline(self):