Test Runner: detect async issues for unittest.TestCase
- 主要语言
- Python
- 星标
- 149
- 派生
- 62
- PR 合并指标
- 30 天内没有已合并 PR
描述
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.
贡献指南
评估
这个 Issue 还没有评估数据。