Skip to content

Commit 2c0935c

Browse files
test: Update ShareableList tests to reflect actual byte lengths
Updated format string assertions and test data to match the new behavior where strings are stored with their actual UTF-8 byte length instead of being padded to 8 bytes minimum.
1 parent 254230f commit 2c0935c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Lib/test/_test_multiprocessing.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4757,7 +4757,7 @@ def test_shared_memory_ShareableList_basics(self):
47574757
self.assertEqual(current_format, sl._get_packing_format(0))
47584758

47594759
# Verify attributes are readable.
4760-
self.assertEqual(sl.format, '8s5sdqxxxxxx?xxxxxxxx?q')
4760+
self.assertEqual(sl.format, '5s5sdqxxxxxx?xxxxxxxx?q')
47614761

47624762
# Exercise len().
47634763
self.assertEqual(len(sl), 7)
@@ -4785,17 +4785,17 @@ def test_shared_memory_ShareableList_basics(self):
47854785
self.assertEqual(sl[3], 42)
47864786
sl[4] = 'some' # Change type at a given position.
47874787
self.assertEqual(sl[4], 'some')
4788-
self.assertEqual(sl.format, '8s5sdq8sxxxxxxx?q')
4788+
self.assertEqual(sl.format, '5s5sdq4sxxxxxxx?q')
47894789
with self.assertRaisesRegex(ValueError,
47904790
"exceeds available storage"):
47914791
sl[4] = 'far too many'
47924792
self.assertEqual(sl[4], 'some')
4793-
sl[0] = 'encodés' # Exactly 8 bytes of UTF-8 data
4794-
self.assertEqual(sl[0], 'encodés')
4793+
sl[0] = 'hello' # Exactly 5 bytes of UTF-8 data
4794+
self.assertEqual(sl[0], 'hello')
47954795
self.assertEqual(sl[1], b'HoWdY') # no spillage
47964796
with self.assertRaisesRegex(ValueError,
47974797
"exceeds available storage"):
4798-
sl[0] = 'encodées' # Exactly 9 bytes of UTF-8 data
4798+
sl[0] = 'hëllöö' # Exactly 8 bytes of UTF-8 data
47994799
self.assertEqual(sl[1], b'HoWdY')
48004800
with self.assertRaisesRegex(ValueError,
48014801
"exceeds available storage"):

0 commit comments

Comments
 (0)