##// END OF EJS Templates
Test that using wrong runner/coroutine pair does not crash....
Matthias Bussonnier -
Show More
@@ -2829,7 +2829,14 b' class InteractiveShell(SingletonConfigurable):'
2829 return interactivity
2829 return interactivity
2830
2830
2831 if interactivity == 'async':
2831 if interactivity == 'async':
2832 try:
2832 return self.loop_runner(coro)
2833 return self.loop_runner(coro)
2834 except Exception as e:
2835 info = ExecutionInfo(raw_cell, store_history, silent, shell_futures)
2836 result = ExecutionResult(info)
2837 result.error_in_exec = e
2838 self.showtraceback(running_compiled_code=True)
2839 return result
2833 return _pseudo_sync_runner(coro)
2840 return _pseudo_sync_runner(coro)
2834
2841
2835 @asyncio.coroutine
2842 @asyncio.coroutine
@@ -13,6 +13,7 b' from IPython.testing.decorators import skip_without'
13
13
14 ip = get_ipython()
14 ip = get_ipython()
15 iprc = lambda x: ip.run_cell(dedent(x)).raise_error()
15 iprc = lambda x: ip.run_cell(dedent(x)).raise_error()
16 iprc_nr = lambda x: ip.run_cell(dedent(x))
16
17
17 if sys.version_info > (3, 5):
18 if sys.version_info > (3, 5):
18 from IPython.core.async_helpers import _should_be_async
19 from IPython.core.async_helpers import _should_be_async
@@ -251,5 +252,26 b' if sys.version_info > (3, 5):'
251 def test_autoawait_trio(self):
252 def test_autoawait_trio(self):
252 iprc("%autoawait trio")
253 iprc("%autoawait trio")
253
254
255 @skip_without('trio')
256 def test_autoawait_trio_wrong_sleep(self):
257 iprc("%autoawait trio")
258 res = iprc_nr("""
259 import asyncio
260 await asyncio.sleep(0)
261 """)
262 with nt.assert_raises(TypeError):
263 res.raise_error()
264
265 @skip_without('trio')
266 def test_autoawait_asyncio_wrong_sleep(self):
267 iprc("%autoawait asyncio")
268 res = iprc_nr("""
269 import trio
270 await trio.sleep(0)
271 """)
272 with nt.assert_raises(RuntimeError):
273 res.raise_error()
274
275
254 def tearDown(self):
276 def tearDown(self):
255 ip.loop_runner = "asyncio"
277 ip.loop_runner = "asyncio"
General Comments 0
You need to be logged in to leave comments. Login now