简体   繁体   中英

How to test aiohttp and peewee-async?

I wanna run 2 asynchronous tests for my database class with aiohttp and peewee-async.

@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

Feed free to star my repo, create issue and ask any questions.

My twitter: @denny_penta

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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