Index: Lib/test/test_decimal.py =================================================================== --- Lib/test/test_decimal.py (revision 77468) +++ Lib/test/test_decimal.py (working copy) @@ -485,25 +485,21 @@ d = Decimal(45) e = Decimal(d) self.assertEqual(str(e), '45') - self.assertNotEqual(id(d), id(e)) #very large positive d = Decimal(500000123) e = Decimal(d) self.assertEqual(str(e), '500000123') - self.assertNotEqual(id(d), id(e)) #negative d = Decimal(-45) e = Decimal(d) self.assertEqual(str(e), '-45') - self.assertNotEqual(id(d), id(e)) #zero d = Decimal(0) e = Decimal(d) self.assertEqual(str(e), '0') - self.assertNotEqual(id(d), id(e)) def test_explicit_context_create_decimal(self): @@ -789,7 +785,7 @@ en_US = { 'decimal_point' : '.', 'grouping' : [3, 3, 0], - 'thousands_sep': ',' + 'thousands_sep' : ',' } fr_FR = { @@ -1099,8 +1095,8 @@ test2 = d1/d3 cls.finish1.set() - cls.assertEqual(test1, Decimal('0.3333333333333333333333333333')) - cls.assertEqual(test2, Decimal('0.3333333333333333333333333333')) + cls.assertEqual(test1, Decimal('0.333333333333333333333333')) + cls.assertEqual(test2, Decimal('0.333333333333333333333333')) return def thfunc2(cls): @@ -1113,7 +1109,7 @@ cls.synchro.set() cls.finish2.set() - cls.assertEqual(test1, Decimal('0.3333333333333333333333333333')) + cls.assertEqual(test1, Decimal('0.333333333333333333333333')) cls.assertEqual(test2, Decimal('0.333333333333333333')) return @@ -1130,7 +1126,11 @@ # that hangs IDLE and I couldn't find it def test_threading(self): - #Test the "threading isolation" of a Context. + # Test the "threading isolation" of a Context. Also test changing + # the DefaultContext, which acts as a template for the thread-local + # contexts. + saveprec = DefaultContext.prec + DefaultContext.prec = 24 self.synchro = threading.Event() self.finish1 = threading.Event() @@ -1144,6 +1144,8 @@ self.finish1.wait() self.finish2.wait() + + DefaultContext.prec = saveprec return if threading is None: @@ -1570,7 +1572,7 @@ def test_from_float(self): - class MyDecimal(Decimal): + class MyDecimal(Decimal): pass r = MyDecimal.from_float(0.1) @@ -1670,12 +1672,12 @@ # check that the result (numeric result + flags raised) of an # arithmetic operation doesn't depend on the current flags - context = Context(prec=9, Emin = -999999999, Emax = 999999999, - rounding=ROUND_HALF_EVEN, traps=[], flags=[]) + context = Context(prec=9, Emin = -425000000, Emax = 425000000, + rounding=ROUND_HALF_EVEN, traps=[], flags=[]) # operations that raise various flags, in the form (function, arglist) operations = [ - (context._apply, [Decimal("100E-1000000009")]), + (context._apply, [Decimal("100E-425000010")]), (context.sqrt, [Decimal(2)]), (context.add, [Decimal("1.23456789"), Decimal("9.87654321")]), (context.multiply, [Decimal("1.23456789"), Decimal("9.87654321")]),