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

Method testInitFromFloat

Lib/test/test_fractions.py:341–349  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

339
340 @requires_IEEE_754
341 def testInitFromFloat(self):
342 self.assertEqual((5, 2), _components(F(2.5)))
343 self.assertEqual((0, 1), _components(F(-0.0)))
344 self.assertEqual((3602879701896397, 36028797018963968),
345 _components(F(0.1)))
346 # bug 16469: error types should be consistent with float -> int
347 self.assertRaises(ValueError, F, float('nan'))
348 self.assertRaises(OverflowError, F, float('inf'))
349 self.assertRaises(OverflowError, F, float('-inf'))
350
351 def testInitFromDecimal(self):
352 self.assertEqual((11, 10),

Callers

nothing calls this directly

Calls 4

_componentsFunction · 0.85
FClass · 0.70
assertEqualMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected