mirror of
https://github.com/python/cpython.git
synced 2025-10-15 03:10:29 +00:00
bpo-32633: Fix some warnings in test_asyncio.test_tasks (#5280)
This commit is contained in:
parent
83c8675edb
commit
6934831e43
1 changed files with 8 additions and 2 deletions
|
@ -2342,7 +2342,8 @@ class SetMethodsTest:
|
||||||
await asyncio.sleep(0.1, loop=self.loop)
|
await asyncio.sleep(0.1, loop=self.loop)
|
||||||
return 10
|
return 10
|
||||||
|
|
||||||
task = self.new_task(self.loop, foo())
|
coro = foo()
|
||||||
|
task = self.new_task(self.loop, coro)
|
||||||
Future.set_result(task, 'spam')
|
Future.set_result(task, 'spam')
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
|
@ -2355,6 +2356,8 @@ class SetMethodsTest:
|
||||||
r'step\(\): already done'):
|
r'step\(\): already done'):
|
||||||
raise exc
|
raise exc
|
||||||
|
|
||||||
|
coro.close()
|
||||||
|
|
||||||
def test_set_exception_causes_invalid_state(self):
|
def test_set_exception_causes_invalid_state(self):
|
||||||
class MyExc(Exception):
|
class MyExc(Exception):
|
||||||
pass
|
pass
|
||||||
|
@ -2366,7 +2369,8 @@ class SetMethodsTest:
|
||||||
await asyncio.sleep(0.1, loop=self.loop)
|
await asyncio.sleep(0.1, loop=self.loop)
|
||||||
return 10
|
return 10
|
||||||
|
|
||||||
task = self.new_task(self.loop, foo())
|
coro = foo()
|
||||||
|
task = self.new_task(self.loop, coro)
|
||||||
Future.set_exception(task, MyExc())
|
Future.set_exception(task, MyExc())
|
||||||
|
|
||||||
with self.assertRaises(MyExc):
|
with self.assertRaises(MyExc):
|
||||||
|
@ -2378,6 +2382,8 @@ class SetMethodsTest:
|
||||||
r'step\(\): already done'):
|
r'step\(\): already done'):
|
||||||
raise exc
|
raise exc
|
||||||
|
|
||||||
|
coro.close()
|
||||||
|
|
||||||
|
|
||||||
@unittest.skipUnless(hasattr(futures, '_CFuture') and
|
@unittest.skipUnless(hasattr(futures, '_CFuture') and
|
||||||
hasattr(tasks, '_CTask'),
|
hasattr(tasks, '_CTask'),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue