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

Method test_index

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

Source from the content-addressed store, hash-verified

302 self.assertRaises(SystemError, float_, NULL)
303
304 def test_index(self):
305 # Test PyNumber_Index()
306 index = _testcapi.number_index
307
308 self.assertEqual(index(11), 11)
309
310 with warnings.catch_warnings():
311 warnings.simplefilter("error", DeprecationWarning)
312 self.assertRaises(DeprecationWarning, index, IndexLike.with_val(True))
313 with self.assertWarns(DeprecationWarning):
314 self.assertEqual(index(IndexLike.with_val(True)), 1)
315 self.assertRaises(TypeError, index, IndexLike.with_val(1.0))
316 self.assertRaises(RuntimeError, index, IndexLike.with_exc(RuntimeError))
317
318 self.assertRaises(TypeError, index, 1.25)
319 self.assertRaises(TypeError, index, "42")
320 self.assertRaises(TypeError, index, object())
321 self.assertRaises(SystemError, index, NULL)
322
323 def test_tobase(self):
324 # Test PyNumber_ToBase()

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected