##// END OF EJS Templates
Update test for new transformation API
Thomas Kluyver -
Show More
@@ -96,9 +96,7 b' class InteractiveShellTestCase(unittest.TestCase):'
96 96 @mock_input
97 97 def test_inputtransformer_syntaxerror(self):
98 98 ip = get_ipython()
99 transformer = SyntaxErrorTransformer()
100 ip.input_splitter.python_line_transforms.append(transformer)
101 ip.input_transformer_manager.python_line_transforms.append(transformer)
99 ip.input_transformer_manager.line_transforms.append(syntax_error_transformer)
102 100
103 101 try:
104 102 #raise Exception
@@ -112,8 +110,7 b' class InteractiveShellTestCase(unittest.TestCase):'
112 110 yield u'print(4*4)'
113 111
114 112 finally:
115 ip.input_splitter.python_line_transforms.remove(transformer)
116 ip.input_transformer_manager.python_line_transforms.remove(transformer)
113 ip.input_transformer_manager.line_transforms.remove(syntax_error_transformer)
117 114
118 115 def test_plain_text_only(self):
119 116 ip = get_ipython()
@@ -146,20 +143,17 b' class InteractiveShellTestCase(unittest.TestCase):'
146 143 self.assertEqual(data, {'text/plain': repr(obj)})
147 144 assert captured.stdout == ''
148 145
149
150
151 class SyntaxErrorTransformer(InputTransformer):
152 def push(self, line):
146 def syntax_error_transformer(lines):
147 """Transformer that throws SyntaxError if 'syntaxerror' is in the code."""
148 for line in lines:
153 149 pos = line.find('syntaxerror')
154 150 if pos >= 0:
155 151 e = SyntaxError('input contains "syntaxerror"')
156 152 e.text = line
157 153 e.offset = pos + 1
158 154 raise e
159 return line
155 return lines
160 156
161 def reset(self):
162 pass
163 157
164 158 class TerminalMagicsTestCase(unittest.TestCase):
165 159 def test_paste_magics_blankline(self):
General Comments 0
You need to be logged in to leave comments. Login now