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

Method testInitFromDecimal

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

Source from the content-addressed store, hash-verified

349 self.assertRaises(OverflowError, F, float('-inf'))
350
351 def testInitFromDecimal(self):
352 self.assertEqual((11, 10),
353 _components(F(Decimal('1.1'))))
354 self.assertEqual((7, 200),
355 _components(F(Decimal('3.5e-2'))))
356 self.assertEqual((0, 1),
357 _components(F(Decimal('.000e20'))))
358 # bug 16469: error types should be consistent with decimal -> int
359 self.assertRaises(ValueError, F, Decimal('nan'))
360 self.assertRaises(ValueError, F, Decimal('snan'))
361 self.assertRaises(OverflowError, F, Decimal('inf'))
362 self.assertRaises(OverflowError, F, Decimal('-inf'))
363
364 def testInitFromIntegerRatio(self):
365 self.assertEqual((7, 3), _components(F(Ratio((7, 3)))))

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected