##// END OF EJS Templates
Prototype async REPL using IPython, take III...
Prototype async REPL using IPython, take III This is a squash and a rebase of a large number of commits from Min and I. For simplicity of managing it, history has been reduced to a single commit, but more historical versions can be found, in particular in PR 11155, or commit aedb5d6d3a441dcdb7180ac9b5cc03f91329117b to be more exact.

File last commit:

r24463:6f33fcd4
r24463:6f33fcd4
Show More
test_async_helpers.py
52 lines | 1.3 KiB | text/x-python | PythonLexer
/ IPython / core / tests / test_async_helpers.py
"""
Test for async helpers.
Should only trigger on python 3.5+ or will have syntax errors.
"""
import sys
import nose.tools as nt
from textwrap import dedent
from unittest import TestCase
ip = get_ipython()
iprc = lambda x: ip.run_cell(dedent(x))
if sys.version_info > (3,5):
from IPython.core.async_helpers import _should_be_async
class AsyncTest(TestCase):
def test_should_be_async(self):
nt.assert_false(_should_be_async("False"))
nt.assert_true(_should_be_async("await bar()"))
nt.assert_true(_should_be_async("x = await bar()"))
nt.assert_false(_should_be_async(dedent("""
async def awaitable():
pass
""")))
def test_execute(self):
iprc("""
import asyncio
await asyncio.sleep(0.001)
""")
def test_autoawait(self):
ip.run_cell('%autoawait False')
ip.run_cell('%autoawait True')
iprc('''
from asyncio import sleep
await.sleep(0.1)
''')
def test_autoawait_curio(self):
ip.run_cell('%autoawait curio')
def test_autoawait_trio(self):
ip.run_cell('%autoawait trio')
def tearDown(self):
ip.loop_runner = 'asyncio'