mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-91896: Deprecate collections.abc.ByteString (#102096)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
This commit is contained in:
parent
2ba931ff72
commit
09b7695f12
6 changed files with 48 additions and 7 deletions
|
@ -1940,14 +1940,25 @@ class TestCollectionABCs(ABCTestCase):
|
|||
|
||||
def test_ByteString(self):
|
||||
for sample in [bytes, bytearray]:
|
||||
self.assertIsInstance(sample(), ByteString)
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
self.assertIsInstance(sample(), ByteString)
|
||||
self.assertTrue(issubclass(sample, ByteString))
|
||||
for sample in [str, list, tuple]:
|
||||
self.assertNotIsInstance(sample(), ByteString)
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
self.assertNotIsInstance(sample(), ByteString)
|
||||
self.assertFalse(issubclass(sample, ByteString))
|
||||
self.assertNotIsInstance(memoryview(b""), ByteString)
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
self.assertNotIsInstance(memoryview(b""), ByteString)
|
||||
self.assertFalse(issubclass(memoryview, ByteString))
|
||||
self.validate_abstract_methods(ByteString, '__getitem__', '__len__')
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
self.validate_abstract_methods(ByteString, '__getitem__', '__len__')
|
||||
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
class X(ByteString): pass
|
||||
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
# No metaclass conflict
|
||||
class Z(ByteString, Awaitable): pass
|
||||
|
||||
def test_Buffer(self):
|
||||
for sample in [bytes, bytearray, memoryview]:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue