简体   繁体   English

如何测试aiohttp和peewee-async?

[英]How to test aiohttp and peewee-async?

I wanna run 2 asynchronous tests for my database class with aiohttp and peewee-async. 我想使用aiohttp和peewee-async对我的数据库类运行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)

But I give just 但我给

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

Thanks you for your attention! 感谢您的关注!

The actual solution I pushed to my repo. 我推到仓库的实际解决方案。
You can watch it here: 您可以在这里观看:
https://github.com/dennypenta/aiohttp-peewee https://github.com/dennypenta/aiohttp-peewee

Feed free to star my repo, create issue and ask any questions. 免费订阅我的仓库,添加问题并提出任何问题。

My twitter: @denny_penta 我的推特:@denny_penta

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM