MCPcopy Create free account
hub / github.com/python/cpython / check_long_asintandoverflow

Method check_long_asintandoverflow

Lib/test/test_capi/test_long.py:202–215  ·  view source on GitHub ↗
(self, func, min_val, max_val)

Source from the content-addressed store, hash-verified

200 self.assertRaises(SystemError, func, NULL)
201
202 def check_long_asintandoverflow(self, func, min_val, max_val):
203 # round trip (object -> C integer -> object)
204 for value in (min_val, max_val, -1, 0, 1, 1234):
205 with self.subTest(value=value):
206 self.assertEqual(func(value), (value, 0))
207 self.assertEqual(func(IntSubclass(value)), (value, 0))
208 self.assertEqual(func(Index(value)), (value, 0))
209
210 self.assertEqual(func(MyIndexAndInt()), (10, 0))
211
212 self.assertEqual(func(min_val - 1), (-1, -1))
213 self.assertEqual(func(max_val + 1), (-1, +1))
214 self.assertRaises(SystemError, func, None)
215 self.assertRaises(TypeError, func, 1.0)
216
217 def test_long_asint(self):
218 # Test PyLong_AsInt()

Calls 7

MyIndexAndIntClass · 0.85
IntSubclassClass · 0.70
IndexClass · 0.70
funcFunction · 0.50
subTestMethod · 0.45
assertEqualMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected