summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio/test_tasks.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2022-10-05 06:49:10 (GMT)
committerGitHub <noreply@github.com>2022-10-05 06:49:10 (GMT)
commit8079bef56f2249ecedafe0be5a6d7a120a7f3ac3 (patch)
tree728a3afbab702ee4442a12d620ccd3e390a0a0ed /Lib/test/test_asyncio/test_tasks.py
parentc70c8b69762f720377adaf22f2e5ec6496a7be53 (diff)
downloadcpython-8079bef56f2249ecedafe0be5a6d7a120a7f3ac3.zip
cpython-8079bef56f2249ecedafe0be5a6d7a120a7f3ac3.tar.gz
cpython-8079bef56f2249ecedafe0be5a6d7a120a7f3ac3.tar.bz2
GH-96704: Add {Task,Handle}.get_context(), use it in call_exception_handler() (#96756)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Diffstat (limited to 'Lib/test/test_asyncio/test_tasks.py')
-rw-r--r--Lib/test/test_asyncio/test_tasks.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py
index 04bdf64..2491285 100644
--- a/Lib/test/test_asyncio/test_tasks.py
+++ b/Lib/test/test_asyncio/test_tasks.py
@@ -2482,6 +2482,17 @@ class BaseTaskTests:
finally:
loop.close()
+ def test_get_context(self):
+ loop = asyncio.new_event_loop()
+ coro = coroutine_function()
+ context = contextvars.copy_context()
+ try:
+ task = self.new_task(loop, coro, context=context)
+ loop.run_until_complete(task)
+ self.assertIs(task.get_context(), context)
+ finally:
+ loop.close()
+
def add_subclass_tests(cls):
BaseTask = cls.Task