facebook / facebook/TestSlide

Test Runner: detect async issues for unittest.TestCase

Open
#232 1 comment 0 reactions 1 assignee Claimed by @fornellas View on GitHub
enhancement Test Runner
Dominant language
Python
Stars
149
Forks
62
PR merge metrics
No merged PRs in 30d

Description

Python provides [IsolatedAsyncioTestCase](https://docs.python.org/3/library/unittest.html#unittest.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](https://testslide.readthedocs.io/en/master/testslide_dsl/async_support/index.html#not-awaited-coroutine) 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:

- Run the event loop with debug.
- [Intercept](https://github.com/facebookincubator/TestSlide/blob/master/testslide/__init__.py#L305) log & warnings.

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.