facebook / facebook/TestSlide

Test Runner: detect async issues for unittest.TestCase

Abierto
#232 1 comentario 0 reacciones 1 asignado Reclamado por @fornellas Ver en GitHub
enhancement Test Runner
Lenguaje dominante
Python
Estrellas
149
Forks
62
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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.

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.