summaryrefslogtreecommitdiff
path: root/Lib/test/test_decimal.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_decimal.py')
-rw-r--r--Lib/test/test_decimal.py26
1 files changed, 9 insertions, 17 deletions
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py
index a76b505bfe..bb27eec3e8 100644
--- a/Lib/test/test_decimal.py
+++ b/Lib/test/test_decimal.py
@@ -23,7 +23,6 @@ or Behaviour) to test each part, or without parameter to test both parts. If
you're working through IDLE, you can import this test module and call test_main()
with the corresponding argument.
"""
-from __future__ import with_statement
import glob
import math
@@ -47,10 +46,12 @@ Signals = tuple(getcontext().flags.keys())
def init():
global ORIGINAL_CONTEXT
ORIGINAL_CONTEXT = getcontext().copy()
- DefaultContext.prec = 9
- DefaultContext.rounding = ROUND_HALF_EVEN
- DefaultContext.traps = dict.fromkeys(Signals, 0)
- setcontext(DefaultContext)
+ DefaultTestContext = Context(
+ prec = 9,
+ rounding = ROUND_HALF_EVEN,
+ traps = dict.fromkeys(Signals, 0)
+ )
+ setcontext(DefaultTestContext)
TESTDATADIR = 'decimaltestdata'
if __name__ == '__main__':
@@ -180,8 +181,6 @@ class DecimalTest(unittest.TestCase):
"""
def setUp(self):
self.context = Context()
- for key in DefaultContext.traps.keys():
- DefaultContext.traps[key] = 1
self.ignore_list = ['#']
# Basically, a # means return NaN InvalidOperation.
# Different from a sNaN in trim
@@ -192,13 +191,6 @@ class DecimalTest(unittest.TestCase):
'minexponent' : self.change_min_exponent,
'clamp' : self.change_clamp}
- def tearDown(self):
- """Cleaning up enviroment."""
- # leaving context in original state
- for key in DefaultContext.traps.keys():
- DefaultContext.traps[key] = 0
- return
-
def eval_file(self, file):
global skip_expected
if skip_expected:
@@ -949,8 +941,8 @@ def thfunc1(cls):
test2 = d1/d3
cls.finish1.set()
- cls.assertEqual(test1, Decimal('0.333333333'))
- cls.assertEqual(test2, Decimal('0.333333333'))
+ cls.assertEqual(test1, Decimal('0.3333333333333333333333333333'))
+ cls.assertEqual(test2, Decimal('0.3333333333333333333333333333'))
return
def thfunc2(cls):
@@ -963,7 +955,7 @@ def thfunc2(cls):
cls.synchro.set()
cls.finish2.set()
- cls.assertEqual(test1, Decimal('0.333333333'))
+ cls.assertEqual(test1, Decimal('0.3333333333333333333333333333'))
cls.assertEqual(test2, Decimal('0.333333333333333333'))
return