Skip to content

Commit 4063a99

Browse files
committed
+ tests for read-only buffers
1 parent 5e4947a commit 4063a99

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

Lib/test/test_struct.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,9 @@ def test_pack_into(self):
461461
self.assertRaises((TypeError, struct.error), struct.pack_into, b'', sb,
462462
None)
463463

464+
# Just a wrong buf.
465+
self.assertRaises(TypeError, s.pack_into, "ЫЫЫ", 0, b'gravitsappa')
466+
464467
def test_pack_into_fn(self):
465468
test_string = b'Reykjavik rocks, eow!'
466469
writable_buf = array.array('b', b' '*100)
@@ -484,6 +487,9 @@ def test_pack_into_fn(self):
484487
self.assertRaises((ValueError, struct.error), pack_into, small_buf, 2,
485488
test_string)
486489

490+
# Just a wrong buf.
491+
self.assertRaises(TypeError, pack_into, "ЫЫЫ", 0, b'pepelats')
492+
487493
def test_unpack_with_buffer(self):
488494
# SF bug 1563759: struct.unpack doesn't support buffer protocol objects
489495
data1 = array.array('B', b'\x12\x34\x56\x78')

0 commit comments

Comments
 (0)