MCPcopy Index your code
hub / github.com/python/cpython / test_long_asvoidptr

Method test_long_asvoidptr

Lib/test/test_capi/test_long.py:305–327  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

303 self.assertRaises(SystemError, asdouble, NULL)
304
305 def test_long_asvoidptr(self):
306 # Test PyLong_AsVoidPtr()
307 fromvoidptr = _testlimitedcapi.pylong_fromvoidptr
308 asvoidptr = _testlimitedcapi.pylong_asvoidptr
309 obj = object()
310 x = fromvoidptr(obj)
311 y = fromvoidptr(NULL)
312 self.assertIs(asvoidptr(x), obj)
313 self.assertIs(asvoidptr(y), NULL)
314 self.assertIs(asvoidptr(IntSubclass(x)), obj)
315
316 # negative values
317 M = (1 << _testcapi.SIZEOF_VOID_P * 8)
318 if x >= M//2:
319 self.assertIs(asvoidptr(x - M), obj)
320 if y >= M//2:
321 self.assertIs(asvoidptr(y - M), NULL)
322
323 self.assertRaises(TypeError, asvoidptr, Index(x))
324 self.assertRaises(TypeError, asvoidptr, object())
325 self.assertRaises(OverflowError, asvoidptr, 2**1000)
326 self.assertRaises(OverflowError, asvoidptr, -2**1000)
327 # CRASHES asvoidptr(NULL)
328
329 def _test_long_aspid(self, aspid):
330 # Test PyLong_AsPid()

Callers

nothing calls this directly

Calls 4

IntSubclassClass · 0.70
IndexClass · 0.70
assertIsMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected