Skip to content

Commit bfa8e85

Browse files
Restore decimal context after decimal doctests
The modified context caused tests failures in several other tests.
1 parent f878d46 commit bfa8e85

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Lib/test/test_decimal.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5892,13 +5892,16 @@ def load_tests(loader, tests, pattern):
58925892

58935893
if TODO_TESTS is None:
58945894
from doctest import DocTestSuite, IGNORE_EXCEPTION_DETAIL
5895+
orig_context = orig_sys_decimal.getcontext().copy()
58955896
for mod in C, P:
58965897
if not mod:
58975898
continue
58985899
def setUp(slf, mod=mod):
58995900
sys.modules['decimal'] = mod
59005901
def tearDown(slf):
59015902
sys.modules['decimal'] = orig_sys_decimal
5903+
mod.setcontext(ORIGINAL_CONTEXT[mod])
5904+
orig_sys_decimal.setcontext(orig_context)
59025905
optionflags = IGNORE_EXCEPTION_DETAIL if mod is C else 0
59035906
sys.modules['decimal'] = mod
59045907
tests.addTest(DocTestSuite(mod, setUp=setUp, tearDown=tearDown,

0 commit comments

Comments
 (0)