facebook / facebook/TestSlide

Test Runner: detect async issues for unittest.TestCase

Aperta
#232 1 commento 0 reazioni 1 assegnatario Rivendicata da @fornellas Vedi su GitHub
enhancement Test Runner
Lingua principale
Python
Stelle
149
Fork
62
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.