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
mark failing tests in test_picklebuffer.py
  • Loading branch information
ShaharNaveh committed Jul 25, 2025
commit 0d1a68dfaba3825b1aa5520c4f9fd986fb837d39
28 changes: 27 additions & 1 deletion Lib/test/test_picklebuffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
"""

import gc
from pickle import PickleBuffer
# TODO: RUSTPYTHON; Implment PickleBuffer
try:
from pickle import PickleBuffer
except ImportError:
PickleBuffer = None
import weakref
import unittest

Expand All @@ -30,6 +34,8 @@ def check_memoryview(self, pb, equiv):
self.assertEqual(m.format, expected.format)
self.assertEqual(m.tobytes(), expected.tobytes())

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_constructor_failure(self):
with self.assertRaises(TypeError):
PickleBuffer()
Expand All @@ -41,6 +47,8 @@ def test_constructor_failure(self):
with self.assertRaises(ValueError):
PickleBuffer(m)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_basics(self):
pb = PickleBuffer(b"foo")
self.assertEqual(b"foo", bytes(pb))
Expand All @@ -54,6 +62,8 @@ def test_basics(self):
m[0] = 48
self.assertEqual(b"0oo", bytes(pb))

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_release(self):
pb = PickleBuffer(b"foo")
pb.release()
Expand All @@ -64,6 +74,8 @@ def test_release(self):
# Idempotency
pb.release()

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_cycle(self):
b = B(b"foo")
pb = PickleBuffer(b)
Expand All @@ -73,6 +85,8 @@ def test_cycle(self):
gc.collect()
self.assertIsNone(wpb())

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_ndarray_2d(self):
# C-contiguous
ndarray = import_helper.import_module("_testbuffer").ndarray
Expand All @@ -96,17 +110,23 @@ def test_ndarray_2d(self):

# Tests for PickleBuffer.raw()

# TODO: RUSTPYTHON
@unittest.expectedFailure
def check_raw(self, obj, equiv):
pb = PickleBuffer(obj)
with pb.raw() as m:
self.assertIsInstance(m, memoryview)
self.check_memoryview(m, equiv)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_raw(self):
for obj in (b"foo", bytearray(b"foo")):
with self.subTest(obj=obj):
self.check_raw(obj, obj)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_raw_ndarray(self):
# 1-D, contiguous
ndarray = import_helper.import_module("_testbuffer").ndarray
Expand All @@ -128,11 +148,15 @@ def test_raw_ndarray(self):
equiv = b'\xc8\x01\x00\x00'
self.check_raw(arr, equiv)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def check_raw_non_contiguous(self, obj):
pb = PickleBuffer(obj)
with self.assertRaisesRegex(BufferError, "non-contiguous"):
pb.raw()

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_raw_non_contiguous(self):
# 1-D
ndarray = import_helper.import_module("_testbuffer").ndarray
Expand All @@ -142,6 +166,8 @@ def test_raw_non_contiguous(self):
arr = ndarray(list(range(12)), shape=(4, 3), format='<i')[::2]
self.check_raw_non_contiguous(arr)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_raw_released(self):
pb = PickleBuffer(b"foo")
pb.release()
Expand Down