Show More
@@ -10,8 +10,7 b' from textwrap import dedent, indent' | |||||
10 | from unittest import TestCase |
|
10 | from unittest import TestCase | |
11 |
|
11 | |||
12 | ip = get_ipython() |
|
12 | ip = get_ipython() | |
13 | iprc = lambda x: ip.run_cell(dedent(x)) |
|
13 | iprc = lambda x: ip.run_cell(dedent(x)).raise_error() | |
14 | iprc_err = lambda x: iprc(x).raise_error() |
|
|||
15 |
|
14 | |||
16 | if sys.version_info > (3, 5): |
|
15 | if sys.version_info > (3, 5): | |
17 | from IPython.core.async_helpers import _should_be_async |
|
16 | from IPython.core.async_helpers import _should_be_async | |
@@ -142,14 +141,14 b' if sys.version_info > (3, 5):' | |||||
142 | for test_name, test_case in tl_err_test_cases: |
|
141 | for test_name, test_case in tl_err_test_cases: | |
143 | # This example should work if 'pass' is used as the value |
|
142 | # This example should work if 'pass' is used as the value | |
144 | with self.subTest((test_name, 'pass')): |
|
143 | with self.subTest((test_name, 'pass')): | |
145 |
iprc |
|
144 | iprc(test_case.format(val='pass')) | |
146 |
|
145 | |||
147 | # It should fail with all the values |
|
146 | # It should fail with all the values | |
148 | for val in vals: |
|
147 | for val in vals: | |
149 | with self.subTest((test_name, val)): |
|
148 | with self.subTest((test_name, val)): | |
150 | msg = "Syntax error not raised for %s, %s" % (test_name, val) |
|
149 | msg = "Syntax error not raised for %s, %s" % (test_name, val) | |
151 | with self.assertRaises(SyntaxError, msg=msg): |
|
150 | with self.assertRaises(SyntaxError, msg=msg): | |
152 |
iprc |
|
151 | iprc(test_case.format(val=val)) | |
153 |
|
152 | |||
154 | def test_in_func_no_error(self): |
|
153 | def test_in_func_no_error(self): | |
155 | # Test that the implementation of top-level return/yield |
|
154 | # Test that the implementation of top-level return/yield | |
@@ -197,7 +196,7 b' if sys.version_info > (3, 5):' | |||||
197 |
|
196 | |||
198 | for val in vals: |
|
197 | for val in vals: | |
199 | with self.subTest((test_name, context_name, val)): |
|
198 | with self.subTest((test_name, context_name, val)): | |
200 |
iprc |
|
199 | iprc(nested_case.format(val=val)) | |
201 |
|
200 | |||
202 | # These tests should still raise a SyntaxError |
|
201 | # These tests should still raise a SyntaxError | |
203 | for test_name, test_case in failure_tests: |
|
202 | for test_name, test_case in failure_tests: | |
@@ -206,32 +205,30 b' if sys.version_info > (3, 5):' | |||||
206 | for val in vals: |
|
205 | for val in vals: | |
207 | with self.subTest((test_name, context_name, val)): |
|
206 | with self.subTest((test_name, context_name, val)): | |
208 | with self.assertRaises(SyntaxError): |
|
207 | with self.assertRaises(SyntaxError): | |
209 |
iprc |
|
208 | iprc(nested_case.format(val=val)) | |
210 |
|
209 | |||
211 |
|
210 | |||
212 | def test_execute(self): |
|
211 | def test_execute(self): | |
213 | iprc( |
|
212 | iprc(""" | |
214 | """ |
|
|||
215 | import asyncio |
|
213 | import asyncio | |
216 | await asyncio.sleep(0.001) |
|
214 | await asyncio.sleep(0.001) | |
217 |
|
|
215 | """ | |
218 | ) |
|
216 | ) | |
219 |
|
217 | |||
220 | def test_autoawait(self): |
|
218 | def test_autoawait(self): | |
221 |
ip |
|
219 | iprc("%autoawait False") | |
222 |
ip |
|
220 | iprc("%autoawait True") | |
223 | iprc( |
|
221 | iprc(""" | |
224 | """ |
|
222 | from asyncio import sleep | |
225 |
|
|
223 | await sleep(0.1) | |
226 | await.sleep(0.1) |
|
|||
227 |
|
|
224 | """ | |
228 | ) |
|
225 | ) | |
229 |
|
226 | |||
230 | def test_autoawait_curio(self): |
|
227 | def test_autoawait_curio(self): | |
231 |
ip |
|
228 | iprc("%autoawait curio") | |
232 |
|
229 | |||
233 | def test_autoawait_trio(self): |
|
230 | def test_autoawait_trio(self): | |
234 |
ip |
|
231 | iprc("%autoawait trio") | |
235 |
|
232 | |||
236 | def tearDown(self): |
|
233 | def tearDown(self): | |
237 | ip.loop_runner = "asyncio" |
|
234 | ip.loop_runner = "asyncio" |
General Comments 0
You need to be logged in to leave comments.
Login now