You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Python provides IsolatedAsyncioTestCase to run tests as async def test* methods. however, people often confuse this class with regular unittest.TestCase, and in such case, the test methods being coroutines, they will be called as if they were sync, never to be awaited, and tests will go green with no failures.
We already detect such cases (and others) for TestSlide's DSL tests. Lets update the test runner, so it can also detect such issues when running unittests.
Currently to detect async issues from TestSlide DSL we:
As long as the event loop is ran in debug, we can catch these. We can also add more patching to the event loop to not require debug (and perhaps an upstream patch for that as well). Eg: we could have at the event loop class level callbacks for async issues.
The text was updated successfully, but these errors were encountered:
So, we can make the test runner itself intercept the forgotten await warning, neat.
For the slow execution, we can patch BaseEventLoop._run_once to set self._debug = True only when the method is running, so we can get this log message, without enabling debugging for everything.
fornellas
changed the title
Test Runner: fail on unittest not awaited coroutines
Test Runner: fail on unittest not async issues
Oct 16, 2020
fornellas
changed the title
Test Runner: fail on unittest not async issues
Test Runner: detect async issues for unittest.TestCase
Jan 8, 2021
Python provides IsolatedAsyncioTestCase to run tests as
async def test*
methods. however, people often confuse this class with regularunittest.TestCase
, and in such case, the test methods being coroutines, they will be called as if they were sync, never to be awaited, and tests will go green with no failures.We already detect such cases (and others) for TestSlide's DSL tests. Lets update the test runner, so it can also detect such issues when running unittests.
Currently to detect async issues from TestSlide DSL we:
As long as the event loop is ran in debug, we can catch these. We can also add more patching to the event loop to not require debug (and perhaps an upstream patch for that as well). Eg: we could have at the event loop class level callbacks for async issues.
The text was updated successfully, but these errors were encountered: