如何使用python 3.8 unittest IsolatedAsyncioTestCase处理CanceledError
我想问一个关于处理IsolatedAsyncioTestCase中的asyncio.CanceledError的问题,它是为在py3.8上测试asyncio而提供的 给出以下测试用例如何使用python 3.8 unittest IsolatedAsyncioTestCase处理CanceledError,python,python-unittest,python-asyncio,python-3.8,Python,Python Unittest,Python Asyncio,Python 3.8,我想问一个关于处理IsolatedAsyncioTestCase中的asyncio.CanceledError的问题,它是为在py3.8上测试asyncio而提供的 给出以下测试用例 导入单元测试 从unittest导入IsolatedAsyncioTestCase 导入异步 类别测试(IsolatedAsyncioTestCase): def设置(自): 打印('设置') 异步定义异步设置(自): 打印('异步设置') 异步def测试_响应(自): 打印('test\u response')
导入单元测试
从unittest导入IsolatedAsyncioTestCase
导入异步
类别测试(IsolatedAsyncioTestCase):
def设置(自):
打印('设置')
异步定义异步设置(自):
打印('异步设置')
异步def测试_响应(自):
打印('test\u response')
self.addAsyncCleanup(self.on_cleanup)
def拆卸(自):
打印(‘拆卸’)
异步定义异步拆卸(自):
打印('在异步拆卸之前')
fut=asyncio.Future()
未来取消
等待未来
打印('异步拆卸后')
_清理上的异步定义(自):
打印(‘清理’)
如果名称=“\uuuuu main\uuuuuuuu”:
unittest.main()
它被撕碎了
root@1318a3fe59d0:/# python --version
Python 3.8.0
root@1318a3fe59d0:/# python /workspace/b.py
setup
async setup
test_response
before async teardown
....
在深入挖掘错误堆栈(通过按CTRL+C终止进程)和源代码之后,这些是与此错误相关的代码