bpo-47167: Allow overriding a future compliance check in asyncio.Task (GH-32197)

This commit is contained in:
Andrew Svetlov 2022-04-01 04:25:15 +03:00 committed by GitHub
parent ab89ccff3c
commit d4bb38f82b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 133 additions and 15 deletions

View file

@ -2383,7 +2383,13 @@ def add_subclass_tests(cls):
return super().add_done_callback(*args, **kwargs)
class Task(CommonFuture, BaseTask):
pass
def __init__(self, *args, **kwargs):
self._check_future_called = 0
super().__init__(*args, **kwargs)
def _check_future(self, future):
self._check_future_called += 1
return super()._check_future(future)
class Future(CommonFuture, BaseFuture):
pass
@ -2409,6 +2415,8 @@ def add_subclass_tests(cls):
dict(fut.calls),
{'add_done_callback': 1})
self.assertEqual(1, task._check_future_called)
# Add patched Task & Future back to the test case
cls.Task = Task
cls.Future = Future