MCPcopy Index your code
hub / github.com/RustPython/RustPython / thfunc2

Function thfunc2

Lib/test/test_decimal.py:1683–1725  ·  view source on GitHub ↗
(cls)

Source from the content-addressed store, hash-verified

1681 cls.assertFalse(c1.flags[sig])
1682
1683def thfunc2(cls):
1684 Decimal = cls.decimal.Decimal
1685 InvalidOperation = cls.decimal.InvalidOperation
1686 DivisionByZero = cls.decimal.DivisionByZero
1687 Overflow = cls.decimal.Overflow
1688 Underflow = cls.decimal.Underflow
1689 Inexact = cls.decimal.Inexact
1690 getcontext = cls.decimal.getcontext
1691 localcontext = cls.decimal.localcontext
1692
1693 d1 = Decimal(1)
1694 d3 = Decimal(3)
1695 test1 = d1/d3
1696
1697 thiscontext = getcontext()
1698 thiscontext.prec = 18
1699 test2 = d1/d3
1700
1701 with localcontext() as c2:
1702 cls.assertTrue(c2.flags[Inexact])
1703 cls.assertRaises(Overflow, c2.multiply, Decimal('1e425000000'), 999)
1704 cls.assertTrue(c2.flags[Overflow])
1705 with localcontext(thiscontext) as c3:
1706 cls.assertTrue(c3.flags[Inexact])
1707 cls.assertFalse(c3.flags[Overflow])
1708 c3.traps[Underflow] = True
1709 cls.assertRaises(Underflow, c3.divide, Decimal('1e-425000000'), 999)
1710 cls.assertTrue(c3.flags[Underflow])
1711 del c3
1712 cls.assertFalse(c2.flags[Underflow])
1713 cls.assertFalse(c2.traps[Underflow])
1714 del c2
1715
1716 cls.synchro.set()
1717 cls.finish2.set()
1718
1719 cls.assertEqual(test1, Decimal('0.333333333333333333333333'))
1720 cls.assertEqual(test2, Decimal('0.333333333333333333'))
1721
1722 cls.assertFalse(thiscontext.traps[Underflow])
1723 cls.assertTrue(thiscontext.flags[Inexact])
1724 for sig in Overflow, Underflow, DivisionByZero, InvalidOperation:
1725 cls.assertFalse(thiscontext.flags[sig])
1726
1727
1728@threading_helper.requires_working_threading()

Callers

nothing calls this directly

Calls 8

DecimalClass · 0.85
getcontextFunction · 0.85
localcontextFunction · 0.85
assertTrueMethod · 0.80
assertFalseMethod · 0.80
assertRaisesMethod · 0.45
setMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected