mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
[3.13] gh-131357: Add some extra tests for empty bytes and bytearray (GH-134458) (#134490)
gh-131357: Add some extra tests for empty bytes and bytearray (GH-134458)
(cherry picked from commit 7309eb60c0)
Co-authored-by: Sergey Miryanov <sergey.miryanov@gmail.com>
This commit is contained in:
parent
55aba16059
commit
044fe0b2e1
2 changed files with 9 additions and 0 deletions
|
|
@ -81,6 +81,7 @@ def test_fromobject(self):
|
|||
# Test PyBytes_FromObject()
|
||||
fromobject = _testlimitedcapi.bytes_fromobject
|
||||
|
||||
self.assertEqual(fromobject(b''), b'')
|
||||
self.assertEqual(fromobject(b'abc'), b'abc')
|
||||
self.assertEqual(fromobject(bytearray(b'abc')), b'abc')
|
||||
self.assertEqual(fromobject(BytesSubclass(b'abc')), b'abc')
|
||||
|
|
@ -138,6 +139,7 @@ def test_repr(self):
|
|||
# Test PyBytes_Repr()
|
||||
bytes_repr = _testlimitedcapi.bytes_repr
|
||||
|
||||
self.assertEqual(bytes_repr(b'', 0), r"""b''""")
|
||||
self.assertEqual(bytes_repr(b'''abc''', 0), r"""b'abc'""")
|
||||
self.assertEqual(bytes_repr(b'''abc''', 1), r"""b'abc'""")
|
||||
self.assertEqual(bytes_repr(b'''a'b"c"d''', 0), r"""b'a\'b"c"d'""")
|
||||
|
|
@ -197,6 +199,7 @@ def test_decodeescape(self):
|
|||
"""Test PyBytes_DecodeEscape()"""
|
||||
decodeescape = _testlimitedcapi.bytes_decodeescape
|
||||
|
||||
self.assertEqual(decodeescape(b''), b'')
|
||||
self.assertEqual(decodeescape(b'abc'), b'abc')
|
||||
self.assertEqual(decodeescape(br'\t\n\r\x0b\x0c\x00\\\'\"'),
|
||||
b'''\t\n\r\v\f\0\\'"''')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue