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

Function thfunc1

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

Source from the content-addressed store, hash-verified

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