2

I have been using unittest.IsolatedAsyncioTestCase to test my async methods. I have been making use of setUpClass, asyncSetUp to create fixture and asyncTearDown to cleanup. This is all working merrily so far :-)

But now I have a new requirement which is to asynchronously create some fixtures once per test class and use it by the test methods throughout.

I am aware setUpClass is run once per test class and setUp is run once per test method.

asyncSetUp is async equivalent of setUp. But I dont seem to find an async equivalent of setUpClass.

So, what is the best way to asynchronously create and cleanup fixtures once per test?

I tried the official unittest doc at https://docs.python.org/3/library/unittest.html#unittest.TestCase.setUpClass, but it only documents about the asyncSetUp.

I am on Python 3.10 and using pytest.

vxxxi
  • 155
  • 1
  • 6

0 Answers0