簡體   English   中英

如何測試aiohttp和peewee-async?

[英]How to test 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)

但我給

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

感謝您的關注!

我推到倉庫的實際解決方案。
您可以在這里觀看:
https://github.com/dennypenta/aiohttp-peewee

免費訂閱我的倉庫,添加問題並提出任何問題。

我的推特:@denny_penta

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM