forked from Rust-related/RustPython
Update test/test_buffer from CPython 3.11.2
This commit is contained in:
16
Lib/test/test_buffer.py
vendored
16
Lib/test/test_buffer.py
vendored
@@ -46,6 +46,11 @@ try:
|
||||
except ImportError:
|
||||
numpy_array = None
|
||||
|
||||
try:
|
||||
import _testcapi
|
||||
except ImportError:
|
||||
_testcapi = None
|
||||
|
||||
|
||||
SHORT_TEST = True
|
||||
|
||||
@@ -967,8 +972,6 @@ class TestBufferProtocol(unittest.TestCase):
|
||||
m.tobytes() # Releasing mm didn't release m
|
||||
|
||||
def verify_getbuf(self, orig_ex, ex, req, sliced=False):
|
||||
def simple_fmt(ex):
|
||||
return ex.format == '' or ex.format == 'B'
|
||||
def match(req, flag):
|
||||
return ((req&flag) == flag)
|
||||
|
||||
@@ -2526,7 +2529,7 @@ class TestBufferProtocol(unittest.TestCase):
|
||||
values = [INT(9), IDX(9),
|
||||
2.2+3j, Decimal("-21.1"), 12.2, Fraction(5, 2),
|
||||
[1,2,3], {4,5,6}, {7:8}, (), (9,),
|
||||
True, False, None, NotImplemented,
|
||||
True, False, None, Ellipsis,
|
||||
b'a', b'abc', bytearray(b'a'), bytearray(b'abc'),
|
||||
'a', 'abc', r'a', r'abc',
|
||||
f, lambda x: x]
|
||||
@@ -4419,6 +4422,13 @@ class TestBufferProtocol(unittest.TestCase):
|
||||
x = ndarray([1,2,3], shape=[3], flags=ND_GETBUF_FAIL)
|
||||
self.assertRaises(BufferError, memoryview, x)
|
||||
|
||||
@support.cpython_only
|
||||
def test_pybuffer_size_from_format(self):
|
||||
# basic tests
|
||||
for format in ('', 'ii', '3s'):
|
||||
self.assertEqual(_testcapi.PyBuffer_SizeFromFormat(format),
|
||||
struct.calcsize(format))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user