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

Method test_long

Lib/test/test_capi/test_number.py:252–275  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

250 self.assertEqual(inplacepower(x, 11, 5), (x, 11))
251
252 def test_long(self):
253 # Test PyNumber_Long()
254 long = _testcapi.number_long
255
256 self.assertEqual(long(42), 42)
257 self.assertEqual(long(1.25), 1)
258 self.assertEqual(long("42"), 42)
259 self.assertEqual(long(b"42"), 42)
260 self.assertEqual(long(bytearray(b"42")), 42)
261 self.assertEqual(long(memoryview(b"42")), 42)
262 self.assertEqual(long(IndexLike.with_val(99)), 99)
263 self.assertEqual(long(IntLike.with_val(99)), 99)
264
265 self.assertRaises(TypeError, long, IntLike.with_val(1.0))
266 with warnings.catch_warnings():
267 warnings.simplefilter("error", DeprecationWarning)
268 self.assertRaises(DeprecationWarning, long, IntLike.with_val(True))
269 with self.assertWarns(DeprecationWarning):
270 self.assertEqual(long(IntLike.with_val(True)), 1)
271 self.assertRaises(RuntimeError, long, IntLike.with_exc(RuntimeError))
272
273 self.assertRaises(TypeError, long, 1j)
274 self.assertRaises(TypeError, long, object())
275 self.assertRaises(SystemError, long, NULL)
276
277 def test_float(self):
278 # Test PyNumber_Float()

Callers

nothing calls this directly

Calls 5

with_valMethod · 0.80
assertWarnsMethod · 0.80
with_excMethod · 0.80
assertEqualMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected