Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 003f3b4

Browse filesBrowse files
authored
Merge pull request #4632 from dalinaum/test/test_buffer
Update test/test_buffer from CPython 3.11.2
2 parents 18f6a65 + 6e0de0d commit 003f3b4
Copy full SHA for 003f3b4

File tree

1 file changed

+13
-3
lines changed
Filter options

1 file changed

+13
-3
lines changed

‎Lib/test/test_buffer.py

Copy file name to clipboardExpand all lines: Lib/test/test_buffer.py
+13-3Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@
4646
except ImportError:
4747
numpy_array = None
4848

49+
try:
50+
import _testcapi
51+
except ImportError:
52+
_testcapi = None
53+
4954

5055
SHORT_TEST = True
5156

@@ -967,8 +972,6 @@ def check_memoryview(m, expected_readonly=readonly):
967972
m.tobytes() # Releasing mm didn't release m
968973

969974
def verify_getbuf(self, orig_ex, ex, req, sliced=False):
970-
def simple_fmt(ex):
971-
return ex.format == '' or ex.format == 'B'
972975
def match(req, flag):
973976
return ((req&flag) == flag)
974977

@@ -2526,7 +2529,7 @@ def f(): return 7
25262529
values = [INT(9), IDX(9),
25272530
2.2+3j, Decimal("-21.1"), 12.2, Fraction(5, 2),
25282531
[1,2,3], {4,5,6}, {7:8}, (), (9,),
2529-
True, False, None, NotImplemented,
2532+
True, False, None, Ellipsis,
25302533
b'a', b'abc', bytearray(b'a'), bytearray(b'abc'),
25312534
'a', 'abc', r'a', r'abc',
25322535
f, lambda x: x]
@@ -4419,6 +4422,13 @@ def test_issue_7385(self):
44194422
x = ndarray([1,2,3], shape=[3], flags=ND_GETBUF_FAIL)
44204423
self.assertRaises(BufferError, memoryview, x)
44214424

4425+
@support.cpython_only
4426+
def test_pybuffer_size_from_format(self):
4427+
# basic tests
4428+
for format in ('', 'ii', '3s'):
4429+
self.assertEqual(_testcapi.PyBuffer_SizeFromFormat(format),
4430+
struct.calcsize(format))
4431+
44224432

44234433
if __name__ == "__main__":
44244434
unittest.main()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.