Commit 74654901 authored by Tim Peters's avatar Tim Peters

DecimalContextTestCase: this permanently changed the

default decimal context, causing test_tokenize to fail
if it ran after test_contextlib.  Changed to restore
the decimal context in effect at the test's start.
parent 8582b259
...@@ -313,6 +313,8 @@ class DecimalContextTestCase(unittest.TestCase): ...@@ -313,6 +313,8 @@ class DecimalContextTestCase(unittest.TestCase):
def testBasic(self): def testBasic(self):
ctx = decimal.getcontext() ctx = decimal.getcontext()
orig_context = ctx.copy()
try:
ctx.prec = save_prec = decimal.ExtendedContext.prec + 5 ctx.prec = save_prec = decimal.ExtendedContext.prec + 5
with decimal.ExtendedContext: with decimal.ExtendedContext:
self.assertEqual(decimal.getcontext().prec, self.assertEqual(decimal.getcontext().prec,
...@@ -327,6 +329,8 @@ class DecimalContextTestCase(unittest.TestCase): ...@@ -327,6 +329,8 @@ class DecimalContextTestCase(unittest.TestCase):
self.assertEqual(decimal.getcontext().prec, save_prec) self.assertEqual(decimal.getcontext().prec, save_prec)
else: else:
self.fail("Didn't raise ZeroDivisionError") self.fail("Didn't raise ZeroDivisionError")
finally:
decimal.setcontext(orig_context)
# This is needed to make the test actually run under regrtest.py! # This is needed to make the test actually run under regrtest.py!
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment