Skip to content

Commit 309cb0a

Browse files
committed
Avoid double rounding in test code
1 parent d11d567 commit 309cb0a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Lib/test/test_statistics.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -2237,7 +2237,9 @@ def test_decimal_sqrt_of_frac(self):
22372237
# Confirm expected root with a quad precision decimal computation
22382238
with decimal.localcontext(decimal.DefaultContext) as ctx:
22392239
ctx.prec *= 4
2240-
high_prec_root = (Decimal(numerator) / Decimal(denominator)).sqrt()
2240+
high_prec_ratio = Decimal(numerator) / Decimal(denominator)
2241+
ctx.rounding = decimal.ROUND_05UP
2242+
high_prec_root = high_prec_ratio.sqrt()
22412243
with decimal.localcontext(decimal.DefaultContext):
22422244
target_root = +high_prec_root
22432245
self.assertEqual(root, target_root)

0 commit comments

Comments
 (0)