mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
bpo-47167: Allow overriding a future compliance check in asyncio.Task (GH-32197)
This commit is contained in:
parent
ab89ccff3c
commit
d4bb38f82b
6 changed files with 133 additions and 15 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue