unittest.IsolatedAsyncioTestCase 的并行和顺序运行

问题描述 投票:0回答:0

我有测试用例:

class HttpbinSuit(IsolatedAsyncioTestCase):
    async def asyncSetUp(self):
        self.client = Client("https://httpbin.org/")
    #...

然后主要我想运行它并查看结果,或者生成 allure-report.

suites = {
    "playground": HttpbinSuit,
}

suite = unittest.TestLoader().loadTestsFromTestCase(suites["playground"])
if parallel:
    concurrent_suite = testtools.ConcurrentStreamTestSuite(
        lambda: ((case, None) for case in suite)
    )
    concurrent_suite.run(testtools.StreamResult())
else:
    runner = unittest.TextTestRunner()
    runner.run(suite)

在并行运行的情况下我没有看到任何结果,并且在顺序运行时失败并显示

coroutine was never awaited
。我该如何解决这个问题?

python python-3.x asynchronous python-asyncio python-unittest
© www.soinside.com 2019 - 2024. All rights reserved.