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

Function thfunc2

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

Source from the content-addressed store, hash-verified

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

Used in the wild real call sites across dependent graphs

searching dependent graphs…