如何测试 aiohttp 和 peewee-async?

How to test aiohttp and peewee-async?

我想 运行 使用 aiohttp 和 peewee-async 对我的数据库 class 进行 2 个异步测试。

@unittest_run_loop
async def test_create_instance(self):
    instance = await self.model.create_instance({})
    self.assertTrue(isinstance(instance, dict))
    self.assertTrue(instance is not None)

@unittest_run_loop
async def test_retrieve_instance(self):
    instance = await self.model.create_instance({})
    retrieved = await self.model.retrieve_instance(int(instance['id']))
    self.assertTrue(instance == retrieved)

但我只给

peewee.ProgrammingError: close cannot be used while an asynchronous query is underway

感谢您的关注!

我推送到我的 repo 的实际解决方案。
你可以在这里观看:
https://github.com/dennypenta/aiohttp-peewee

免费为我的回购加注星标,创建问题并提出任何问题。

我的推特:@denny_penta