Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add some extra tests for empty bytearray
  • Loading branch information
sergey-miryanov committed May 21, 2025
commit ceba0a3977bcb2656f8d22eb56fd10960fd5cfe3
4 changes: 4 additions & 0 deletions Lib/test/test_capi/test_bytearray.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def test_fromobject(self):
# Test PyByteArray_FromObject()
fromobject = _testlimitedcapi.bytearray_fromobject

self.assertEqual(fromobject(b''), bytearray(b''))
self.assertEqual(fromobject(b'abc'), bytearray(b'abc'))
self.assertEqual(fromobject(bytearray(b'abc')), bytearray(b'abc'))
self.assertEqual(fromobject(ByteArraySubclass(b'abc')), bytearray(b'abc'))
Expand Down Expand Up @@ -115,6 +116,7 @@ def test_concat(self):
self.assertEqual(concat(b'abc', bytearray(b'def')), bytearray(b'abcdef'))
self.assertEqual(concat(bytearray(b'abc'), b''), bytearray(b'abc'))
self.assertEqual(concat(b'', bytearray(b'def')), bytearray(b'def'))
self.assertEqual(concat(bytearray(b''), bytearray(b'')), bytearray(b''))
self.assertEqual(concat(memoryview(b'xabcy')[1:4], b'def'),
bytearray(b'abcdef'))
self.assertEqual(concat(b'abc', memoryview(b'xdefy')[1:4]),
Expand Down Expand Up @@ -150,6 +152,8 @@ def test_resize(self):
self.assertEqual(resize(ba, 0), 0)
self.assertEqual(ba, bytearray())

self.assertEqual(resize(bytearray(b''), 0), 0)

ba = ByteArraySubclass(b'abcdef')
self.assertEqual(resize(ba, 3), 0)
self.assertEqual(ba, bytearray(b'abc'))
Expand Down
Loading