bpo-33750: Reset thread-local context precision in test_round(). (GH-7355) (#7357)

(cherry picked from commit e95dfc5006)

Co-authored-by: Stefan Krah <skrah@bytereef.org>
This commit is contained in:
Miss Islington (bot) 2018-06-03 10:36:34 -07:00 committed by Stefan Krah
parent ad4c7954df
commit bdab3ea8b9

View file

@ -4454,9 +4454,9 @@ class Coverage(unittest.TestCase):
def test_round(self): def test_round(self):
# Python3 behavior: round() returns Decimal # Python3 behavior: round() returns Decimal
Decimal = self.decimal.Decimal Decimal = self.decimal.Decimal
getcontext = self.decimal.getcontext localcontext = self.decimal.localcontext
c = getcontext() with localcontext() as c:
c.prec = 28 c.prec = 28
self.assertEqual(str(Decimal("9.99").__round__()), "10") self.assertEqual(str(Decimal("9.99").__round__()), "10")
@ -5410,7 +5410,7 @@ class CWhitebox(unittest.TestCase):
# SSIZE_MIN # SSIZE_MIN
x = (1, (), -sys.maxsize-1) x = (1, (), -sys.maxsize-1)
self.assertEqual(str(c.create_decimal(x)), '-0E-1000026') self.assertEqual(str(c.create_decimal(x)), '-0E-1000007')
self.assertRaises(InvalidOperation, Decimal, x) self.assertRaises(InvalidOperation, Decimal, x)
x = (1, (0, 1, 2), -sys.maxsize-1) x = (1, (0, 1, 2), -sys.maxsize-1)