@@ -4454,19 +4454,19 @@ def test_rop(self):
4454
4454
def test_round (self ):
4455
4455
# Python3 behavior: round() returns Decimal
4456
4456
Decimal = self .decimal .Decimal
4457
- getcontext = self .decimal .getcontext
4457
+ localcontext = self .decimal .localcontext
4458
4458
4459
- c = getcontext ()
4460
- c .prec = 28
4459
+ with localcontext () as c :
4460
+ c .prec = 28
4461
4461
4462
- self .assertEqual (str (Decimal ("9.99" ).__round__ ()), "10" )
4463
- self .assertEqual (str (Decimal ("9.99e-5" ).__round__ ()), "0" )
4464
- self .assertEqual (str (Decimal ("1.23456789" ).__round__ (5 )), "1.23457" )
4465
- self .assertEqual (str (Decimal ("1.2345" ).__round__ (10 )), "1.2345000000" )
4466
- self .assertEqual (str (Decimal ("1.2345" ).__round__ (- 10 )), "0E+10" )
4462
+ self .assertEqual (str (Decimal ("9.99" ).__round__ ()), "10" )
4463
+ self .assertEqual (str (Decimal ("9.99e-5" ).__round__ ()), "0" )
4464
+ self .assertEqual (str (Decimal ("1.23456789" ).__round__ (5 )), "1.23457" )
4465
+ self .assertEqual (str (Decimal ("1.2345" ).__round__ (10 )), "1.2345000000" )
4466
+ self .assertEqual (str (Decimal ("1.2345" ).__round__ (- 10 )), "0E+10" )
4467
4467
4468
- self .assertRaises (TypeError , Decimal ("1.23" ).__round__ , "5" )
4469
- self .assertRaises (TypeError , Decimal ("1.23" ).__round__ , 5 , 8 )
4468
+ self .assertRaises (TypeError , Decimal ("1.23" ).__round__ , "5" )
4469
+ self .assertRaises (TypeError , Decimal ("1.23" ).__round__ , 5 , 8 )
4470
4470
4471
4471
def test_create_decimal (self ):
4472
4472
c = self .decimal .Context ()
@@ -5410,7 +5410,7 @@ def test_from_tuple(self):
5410
5410
5411
5411
# SSIZE_MIN
5412
5412
x = (1 , (), - sys .maxsize - 1 )
5413
- self .assertEqual (str (c .create_decimal (x )), '-0E-1000026 ' )
5413
+ self .assertEqual (str (c .create_decimal (x )), '-0E-1000007 ' )
5414
5414
self .assertRaises (InvalidOperation , Decimal , x )
5415
5415
5416
5416
x = (1 , (0 , 1 , 2 ), - sys .maxsize - 1 )
0 commit comments