summaryrefslogtreecommitdiffstats
path: root/Lib/unittest/async_case.py
Commit message (Collapse)AuthorAgeFilesLines
* bpo-44911: Fixed IsolatedAsyncioTestCase from throwing an exception on ↵Miss Islington (bot)2021-08-161-1/+1
| | | | | | | leaked tasks (GH-27765) (cherry picked from commit 2cb1a6806c0cefab0c3a40fdd428a89a4392570e) Co-authored-by: Bar Harel <bar.harel@biocatch.com>
* bpo-39101: Fixes BaseException hang in IsolatedAsyncioTestCase. (GH-22654)Lisa Roach2020-10-261-2/+2
|
* bpo-36373: Fix deprecation warnings (GH-15889)Andrew Svetlov2019-09-111-4/+6
| | | https://bugs.python.org/issue36373
* bpo-32972: Async test case (GH-13386)Andrew Svetlov2019-05-291-0/+158
Add explicit `asyncSetUp` and `asyncTearDown` methods. The rest is the same as for #13228 `AsyncTestCase` create a loop instance for every test for the sake of test isolation. Sometimes a loop shared between all tests can speed up tests execution time a lot but it requires control of closed resources after every test finish. Basically, it requires nested supervisors support that was discussed with @1st1 many times. Sorry, asyncio supervisors have no chance to land on Python 3.8. The PR intentionally does not provide API for changing the used event loop or getting the test loop: use `asyncio.set_event_loop_policy()` and `asyncio.get_event_loop()` instead. The PR adds four overridable methods to base `unittest.TestCase` class: ``` def _callSetUp(self): self.setUp() def _callTestMethod(self, method): method() def _callTearDown(self): self.tearDown() def _callCleanup(self, function, /, *args, **kwargs): function(*args, **kwargs) ``` It allows using asyncio facilities with minimal influence on the unittest code. The last but not least: the PR respects contextvars. The context variable installed by `asyncSetUp` is available on test, `tearDown` and a coroutine scheduled by `addCleanup`. https://bugs.python.org/issue32972