facebook / facebook/TestSlide

Test Runner: detect async issues for unittest.TestCase

Ouverte
#232 1 commentaire 0 réactions 1 personne assignée Réclamée par @fornellas Voir sur GitHub
enhancement Test Runner
Langage dominant
Python
Étoiles
149
Forks
62
Métriques de merge des PR
Aucune PR mergée en 30 j

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.

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.