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