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