|
46 | 46 | except ImportError:
|
47 | 47 | numpy_array = None
|
48 | 48 |
|
| 49 | +try: |
| 50 | + import _testcapi |
| 51 | +except ImportError: |
| 52 | + _testcapi = None |
| 53 | + |
49 | 54 |
|
50 | 55 | SHORT_TEST = True
|
51 | 56 |
|
@@ -967,8 +972,6 @@ def check_memoryview(m, expected_readonly=readonly):
|
967 | 972 | m.tobytes() # Releasing mm didn't release m
|
968 | 973 |
|
969 | 974 | def verify_getbuf(self, orig_ex, ex, req, sliced=False):
|
970 |
| - def simple_fmt(ex): |
971 |
| - return ex.format == '' or ex.format == 'B' |
972 | 975 | def match(req, flag):
|
973 | 976 | return ((req&flag) == flag)
|
974 | 977 |
|
@@ -2526,7 +2529,7 @@ def f(): return 7
|
2526 | 2529 | values = [INT(9), IDX(9),
|
2527 | 2530 | 2.2+3j, Decimal("-21.1"), 12.2, Fraction(5, 2),
|
2528 | 2531 | [1,2,3], {4,5,6}, {7:8}, (), (9,),
|
2529 |
| - True, False, None, NotImplemented, |
| 2532 | + True, False, None, Ellipsis, |
2530 | 2533 | b'a', b'abc', bytearray(b'a'), bytearray(b'abc'),
|
2531 | 2534 | 'a', 'abc', r'a', r'abc',
|
2532 | 2535 | f, lambda x: x]
|
@@ -4419,6 +4422,13 @@ def test_issue_7385(self):
|
4419 | 4422 | x = ndarray([1,2,3], shape=[3], flags=ND_GETBUF_FAIL)
|
4420 | 4423 | self.assertRaises(BufferError, memoryview, x)
|
4421 | 4424 |
|
| 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 | + |
4422 | 4432 |
|
4423 | 4433 | if __name__ == "__main__":
|
4424 | 4434 | unittest.main()
|
0 commit comments