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

Function thfunc1

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

Source from the content-addressed store, hash-verified

1637# The following are two functions used to test threading in the next class
1638
1639def thfunc1(cls):
1640 Decimal = cls.decimal.Decimal
1641 InvalidOperation = cls.decimal.InvalidOperation
1642 DivisionByZero = cls.decimal.DivisionByZero
1643 Overflow = cls.decimal.Overflow
1644 Underflow = cls.decimal.Underflow
1645 Inexact = cls.decimal.Inexact
1646 getcontext = cls.decimal.getcontext
1647 localcontext = cls.decimal.localcontext
1648
1649 d1 = Decimal(1)
1650 d3 = Decimal(3)
1651 test1 = d1/d3
1652
1653 cls.finish1.set()
1654 cls.synchro.wait()
1655
1656 test2 = d1/d3
1657 with localcontext() as c2:
1658 cls.assertTrue(c2.flags[Inexact])
1659 cls.assertRaises(DivisionByZero, c2.divide, d1, 0)
1660 cls.assertTrue(c2.flags[DivisionByZero])
1661 with localcontext() as c3:
1662 cls.assertTrue(c3.flags[Inexact])
1663 cls.assertTrue(c3.flags[DivisionByZero])
1664 cls.assertRaises(InvalidOperation, c3.compare, d1, Decimal('sNaN'))
1665 cls.assertTrue(c3.flags[InvalidOperation])
1666 del c3
1667 cls.assertFalse(c2.flags[InvalidOperation])
1668 del c2
1669
1670 cls.assertEqual(test1, Decimal('0.333333333333333333333333'))
1671 cls.assertEqual(test2, Decimal('0.333333333333333333333333'))
1672
1673 c1 = getcontext()
1674 cls.assertTrue(c1.flags[Inexact])
1675 for sig in Overflow, Underflow, DivisionByZero, InvalidOperation:
1676 cls.assertFalse(c1.flags[sig])
1677
1678def thfunc2(cls):
1679 Decimal = cls.decimal.Decimal

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…