mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
gh-91896: Improve visibility of ByteString
deprecation warnings (#104294)
This commit is contained in:
parent
a0a98ddb31
commit
f0f5bb3204
5 changed files with 85 additions and 12 deletions
|
@ -11,6 +11,7 @@ from itertools import product, chain, combinations
|
|||
import string
|
||||
import sys
|
||||
from test import support
|
||||
from test.support.import_helper import import_fresh_module
|
||||
import types
|
||||
import unittest
|
||||
|
||||
|
@ -25,7 +26,7 @@ from collections.abc import Sized, Container, Callable, Collection
|
|||
from collections.abc import Set, MutableSet
|
||||
from collections.abc import Mapping, MutableMapping, KeysView, ItemsView, ValuesView
|
||||
from collections.abc import Sequence, MutableSequence
|
||||
from collections.abc import ByteString, Buffer
|
||||
from collections.abc import Buffer
|
||||
|
||||
|
||||
class TestUserObjects(unittest.TestCase):
|
||||
|
@ -1939,6 +1940,8 @@ class TestCollectionABCs(ABCTestCase):
|
|||
nativeseq, seqseq, (letter, start, stop))
|
||||
|
||||
def test_ByteString(self):
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
from collections.abc import ByteString
|
||||
for sample in [bytes, bytearray]:
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
self.assertIsInstance(sample(), ByteString)
|
||||
|
@ -1960,6 +1963,11 @@ class TestCollectionABCs(ABCTestCase):
|
|||
# No metaclass conflict
|
||||
class Z(ByteString, Awaitable): pass
|
||||
|
||||
def test_ByteString_attribute_access(self):
|
||||
collections_abc = import_fresh_module("collections.abc")
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
collections_abc.ByteString
|
||||
|
||||
def test_Buffer(self):
|
||||
for sample in [bytes, bytearray, memoryview]:
|
||||
self.assertIsInstance(sample(b"x"), Buffer)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue