question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Builtin TestCase from python 3.8

See original GitHub issue

First 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:closed
  • Created 3 years ago
  • Comments:26 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
long2icecommented, Nov 15, 2021
1reaction
WisdomPillcommented, Jun 2, 2020

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 like pytest or nose (I do not know, never used them, but in aiohttp they have some).

Read more comments on GitHub >

github_iconTop Results From Across the Web

unittest — Unit testing framework — Python 3.11.1 ...
A test case is the individual unit of testing. It checks for a specific response to a particular set of inputs. unittest provides...
Read more >
What? Why? Next? - aiounittest's documentation!
In the Python 3.8 (release note) and newer consider to use the unittest.IsolatedAsyncioTestCase. Builtin unittest module is now asyncio-featured.
Read more >
Python unittest.TestCase execution order - Stack Overflow
Note: The order in which the various tests will be run is determined by sorting the test method names with respect to the...
Read more >
Usage and Invocations — pytest documentation
You can invoke testing through the Python interpreter from the command line: python -m pytest [...] This is almost equivalent to invoking the...
Read more >
Robot Framework User Guide
Robot Framework is a Python-based, extensible keyword-driven automation ... of test cases or suites, or log it with the BuiltIn keywords Log or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found