MCPcopy Create free account
hub / github.com/RustPython/RustPython / test_quantize

Method test_quantize

Lib/test/test_decimal.py:2776–2798  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2774 "Decimal('10')")
2775
2776 def test_quantize(self):
2777 Decimal = self.decimal.Decimal
2778 Context = self.decimal.Context
2779 InvalidOperation = self.decimal.InvalidOperation
2780
2781 c = Context(Emax=99999, Emin=-99999)
2782 self.assertEqual(
2783 Decimal('7.335').quantize(Decimal('.01')),
2784 Decimal('7.34')
2785 )
2786 self.assertEqual(
2787 Decimal('7.335').quantize(Decimal('.01'), rounding=ROUND_DOWN),
2788 Decimal('7.33')
2789 )
2790 self.assertRaises(
2791 InvalidOperation,
2792 Decimal("10e99999").quantize, Decimal('1e100000'), context=c
2793 )
2794
2795 c = Context()
2796 d = Decimal("0.871831e800")
2797 x = d.quantize(context=c, exp=Decimal("1e797"), rounding=ROUND_DOWN)
2798 self.assertEqual(x, Decimal('8.71E+799'))
2799
2800 def test_complex(self):
2801 Decimal = self.decimal.Decimal

Callers

nothing calls this directly

Calls 5

quantizeMethod · 0.95
DecimalClass · 0.85
ContextClass · 0.70
assertEqualMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected