[Python-checkins] gh-91821: Make decimal test succeed consistently (#91825)

JelleZijlstra webhook-mailer at python.org
Sun Apr 24 18:03:06 EDT 2022


https://github.com/python/cpython/commit/e93d2fbddaee329b2e8f405cbb5aec44ca221de6
commit: e93d2fbddaee329b2e8f405cbb5aec44ca221de6
branch: main
author: Jelle Zijlstra <jelle.zijlstra at gmail.com>
committer: JelleZijlstra <jelle.zijlstra at gmail.com>
date: 2022-04-24T15:02:57-07:00
summary:

gh-91821: Make decimal test succeed consistently (#91825)

The test relies on precision being set to 9, but some ways of
invoking this test leave it set to 28 instead. I don't know
exactly how it happens, but setting the precision directly should
make the behavior consistent.

files:
A Misc/NEWS.d/next/Library/2022-04-22-08-25-18.gh-issue-91821.XwMkj0.rst
M Lib/test/test_decimal.py

diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py
index 96f8f7f32c454..f7a47c86a3fe8 100644
--- a/Lib/test/test_decimal.py
+++ b/Lib/test/test_decimal.py
@@ -5520,6 +5520,7 @@ def test_from_tuple(self):
 
         with localcontext() as c:
 
+            c.prec = 9
             c.traps[InvalidOperation] = True
             c.traps[Overflow] = True
             c.traps[Underflow] = True
diff --git a/Misc/NEWS.d/next/Library/2022-04-22-08-25-18.gh-issue-91821.XwMkj0.rst b/Misc/NEWS.d/next/Library/2022-04-22-08-25-18.gh-issue-91821.XwMkj0.rst
new file mode 100644
index 0000000000000..9d7f9d48c4c99
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2022-04-22-08-25-18.gh-issue-91821.XwMkj0.rst
@@ -0,0 +1 @@
+Fix unstable ``test_from_tuple`` test in ``test_decimal.py``.



More information about the Python-checkins mailing list