OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

How unit test asyncio.run function with pytest?

  • Thread starter Thread starter Lutaaya Huzaifah Idris
  • Start date Start date
L

Lutaaya Huzaifah Idris

Guest
Suppose I have an async celery task below;

Code:
@celery.task
def clean_db():
    """Auto clean db"""
    asyncio.run(fetch_and_clean_db())

And I want to use pytest to test the fetch_and_clean_db is called once the task clean_db is called ?

How best can I test this with pytest ?
<p>Suppose I have an async celery task below;</p>
<pre><code>@celery.task
def clean_db():
"""Auto clean db"""
asyncio.run(fetch_and_clean_db())
</code></pre>
<p>And I want to use pytest to test the fetch_and_clean_db is called once the task clean_db is called ?</p>
<p>How best can I test this with pytest ?</p>
 

Latest posts

B
Replies
0
Views
1
Blundering Ecologist
B
Top