mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-46469: Make asyncio generic classes return GenericAlias (GH-30777)
* bpo-46469: Make asyncio generic classes return GenericAlias * 📜🤖 Added by blurb_it. * Update Misc/NEWS.d/next/Library/2022-01-22-05-05-08.bpo-46469.plUab5.rst Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
This commit is contained in:
parent
ab8fe22e5e
commit
ea5b96842e
8 changed files with 28 additions and 26 deletions
|
@ -7,7 +7,7 @@ import sys
|
|||
import threading
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
from types import GenericAlias
|
||||
import asyncio
|
||||
from asyncio import futures
|
||||
from test.test_asyncio import utils as test_utils
|
||||
|
@ -109,6 +109,11 @@ class BaseFutureTests:
|
|||
self.loop = self.new_test_loop()
|
||||
self.addCleanup(self.loop.close)
|
||||
|
||||
def test_generic_alias(self):
|
||||
future = self.cls[str]
|
||||
self.assertEqual(future.__args__, (str,))
|
||||
self.assertIsInstance(future, GenericAlias)
|
||||
|
||||
def test_isfuture(self):
|
||||
class MyFuture:
|
||||
_asyncio_future_blocking = None
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
"""Tests for queues.py"""
|
||||
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
import asyncio
|
||||
from types import GenericAlias
|
||||
from test.test_asyncio import utils as test_utils
|
||||
|
||||
|
||||
|
@ -74,6 +73,11 @@ class QueueBasicTests(_QueueTestBase):
|
|||
def test_str(self):
|
||||
self._test_repr_or_str(str, False)
|
||||
|
||||
def test_generic_alias(self):
|
||||
q = asyncio.Queue[int]
|
||||
self.assertEqual(q.__args__, (int,))
|
||||
self.assertIsInstance(q, GenericAlias)
|
||||
|
||||
def test_empty(self):
|
||||
q = asyncio.Queue()
|
||||
self.assertTrue(q.empty())
|
||||
|
|
|
@ -11,10 +11,10 @@ import re
|
|||
import sys
|
||||
import textwrap
|
||||
import traceback
|
||||
import types
|
||||
import unittest
|
||||
import weakref
|
||||
from unittest import mock
|
||||
from types import GenericAlias
|
||||
|
||||
import asyncio
|
||||
from asyncio import coroutines
|
||||
|
@ -108,6 +108,12 @@ class BaseTaskTests:
|
|||
self.loop.set_task_factory(self.new_task)
|
||||
self.loop.create_future = lambda: self.new_future(self.loop)
|
||||
|
||||
|
||||
def test_generic_alias(self):
|
||||
task = self.__class__.Task[str]
|
||||
self.assertEqual(task.__args__, (str,))
|
||||
self.assertIsInstance(task, GenericAlias)
|
||||
|
||||
def test_task_cancel_message_getter(self):
|
||||
async def coro():
|
||||
pass
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue