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

Method test_float

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

Source from the content-addressed store, hash-verified

275 self.assertRaises(SystemError, long, NULL)
276
277 def test_float(self):
278 # Test PyNumber_Float()
279 float_ = _testcapi.number_float
280
281 self.assertEqual(float_(1.25), 1.25)
282 self.assertEqual(float_(123), 123.)
283 self.assertEqual(float_("1.25"), 1.25)
284
285 self.assertEqual(float_(FloatLike.with_val(4.25)), 4.25)
286 self.assertEqual(float_(IndexLike.with_val(99)), 99.0)
287 self.assertEqual(float_(IndexLike.with_val(-1)), -1.0)
288
289 self.assertRaises(TypeError, float_, FloatLike.with_val(687))
290 with warnings.catch_warnings():
291 warnings.simplefilter("error", DeprecationWarning)
292 self.assertRaises(DeprecationWarning, float_, FloatLike.with_val(subclassof(float)(4.25)))
293 with self.assertWarns(DeprecationWarning):
294 self.assertEqual(float_(FloatLike.with_val(subclassof(float)(4.25))), 4.25)
295 self.assertRaises(RuntimeError, float_, FloatLike.with_exc(RuntimeError))
296
297 self.assertRaises(TypeError, float_, IndexLike.with_val(1.25))
298 self.assertRaises(OverflowError, float_, IndexLike.with_val(2**2000))
299
300 self.assertRaises(TypeError, float_, 1j)
301 self.assertRaises(TypeError, float_, object())
302 self.assertRaises(SystemError, float_, NULL)
303
304 def test_index(self):
305 # Test PyNumber_Index()

Callers

nothing calls this directly

Calls 6

subclassofFunction · 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