hey gang -
I'm adding asyncio support to oslo.db. Fairly major block hit, which I can work around, is that testtools / stestr do not seem to have any provision for asyncio present.
An initial attempt working with it gracefully looked like this (using oslotests base, which is the testtoolsTestBase):
import unittest from oslotest import base
class MyTestSuite(unittest.IsolatedAsyncioTestCase, base.BaseTestCase): # ...
but that didn't work because the degree to which testtools modifies the run() method of unittest.TestCase prevents IsolatedAsyncioTestCase from running awaitable test cases.
Next attempt is this, remove testtools / oslotest from the class hierarchy (which is bad, because we lose all of our testtools patterns):
class MyTestSuite(unittest.IsolatedAsyncioTestCase): # ...
this runs, however stestr sends into the test suite a Result object that is not a subclass of unittest.result.TestResult, it's a "subunit.test_results.AutoTimingTestResultDecorator" that does not TestResult in its MRO; unittest shows a warning that there is no addDuration() method on the result object.
final workaround, patch one on, here's my base:
class BaseAsyncioCase(unittest.IsolatedAsyncioTestCase): def run(self, result=None): # work around stestr sending a result object that's not a # unittest.TestResult result.addDuration = lambda test, elapsed: None return super().run(result=result)
now I can run asyncio tests. But only by ditching testtools entirely.
What would be the correct approach to introducing asyncio support in our test suites given our dependency on testtools?