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