Builtin TestCase from python 3.8
See original GitHub issueFirst and foremost, congrats, I really like this library and looking forward to contribute and follow the path of its evolution. I embraced this library mostly because it is async and it resembles django so it was very easy to get started with.
Is your feature request related to a problem? Please describe. I am using tortoise with python 3.8, as of python 3.8 asyncio unittesting is possible without asynctest. https://docs.python.org/3/library/unittest.html#unittest.IsolatedAsyncioTestCase
There are also AsyncMock and patch supports async methods.
Describe the solution you’d like
I would like not to include asynctest when using python3.8 and above.
Describe alternatives you’ve considered I have considered no other alternatives, but I am open to consider other alternatives.
Additional context
I have been using a work around by copying some code from IsolatedTestCase
async def asyncSetUp(self) -> None:
config = generate_config(db_url='sqlite://:memory:', app_modules={'models': ['lib.models']})
await Tortoise.init(config, _create_db=True)
await Tortoise.generate_schemas(safe=False)
self._connections = Tortoise._connections.copy()
async def asyncTearDown(self) -> None:
Tortoise._connections = self._connections.copy()
await Tortoise._drop_databases()
Tortoise.apps = {}
Tortoise._connections = {}
Tortoise._inited = False
I am open to open a PR with the fixes.
Another question, why the testing modules are in contrib?
Testing is vital to every piece of software, is testing not fully supported or you are planning to change the api?
Issue Analytics
- State:
- Created 3 years ago
- Comments:26 (11 by maintainers)

Top Related StackOverflow Question
see https://github.com/tortoise/tortoise-orm/pull/977
Okay then I will have a try at creating a TestCase in
tortoise.test_case, since there might be other testing frameworks that would need some kind of util likepytestornose(I do not know, never used them, but inaiohttpthey have some).