FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[3.13] gh-131357: Add a set of asserts to test.test_capi.test_bytearray (GH-131554) by miss-islington · Pull Request #131601 · python/cpython · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
7 changes: 5 additions & 2 deletions Lib/test/test_capi/test_bytearray.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class CAPITest(unittest.TestCase):
def test_check(self):
# Test PyByteArray_Check()
check = _testlimitedcapi.bytearray_check
self.assertTrue(check(bytearray(b'')))
self.assertTrue(check(bytearray(b'abc')))
self.assertFalse(check(b'abc'))
self.assertTrue(check(ByteArraySubclass(b'abc')))
Expand All @@ -33,6 +34,7 @@ def test_check(self):
def test_checkexact(self):
# Test PyByteArray_CheckExact()
check = _testlimitedcapi.bytearray_checkexact
self.assertTrue(check(bytearray(b'')))
self.assertTrue(check(bytearray(b'abc')))
self.assertFalse(check(b'abc'))
self.assertFalse(check(ByteArraySubclass(b'abc')))
Expand Down Expand Up @@ -78,7 +80,7 @@ def test_fromobject(self):
def test_size(self):
# Test PyByteArray_Size()
size = _testlimitedcapi.bytearray_size

self.assertEqual(size(bytearray(b'')), 0)
self.assertEqual(size(bytearray(b'abc')), 3)
self.assertEqual(size(ByteArraySubclass(b'abc')), 3)

Expand All @@ -89,7 +91,7 @@ def test_size(self):
def test_asstring(self):
"""Test PyByteArray_AsString()"""
asstring = _testlimitedcapi.bytearray_asstring

self.assertEqual(asstring(bytearray(b''), 1), b'\0')
self.assertEqual(asstring(bytearray(b'abc'), 4), b'abc\0')
self.assertEqual(asstring(ByteArraySubclass(b'abc'), 4), b'abc\0')
self.assertEqual(asstring(bytearray(b'abc\0def'), 8), b'abc\0def\0')
Expand All @@ -105,6 +107,7 @@ def test_concat(self):
ba = bytearray(b'abc')
self.assertEqual(concat(ba, b'def'), bytearray(b'abcdef'))
self.assertEqual(ba, b'abc')
self.assertEqual(concat(ba, ba), bytearray(b'abcabc'))

self.assertEqual(concat(b'abc', b'def'), bytearray(b'abcdef'))
self.assertEqual(concat(b'a\0b', b'c\0d'), bytearray(b'a\0bc\0d'))
Expand Down

Back | FazBrowse Home | New Git URL