There was an error while loading. Please reload this page.
1 parent d50a7c4 commit 2d7ff6eCopy full SHA for 2d7ff6e
1 file changed
Lib/test/test_decimal.py
@@ -5892,13 +5892,17 @@ def load_tests(loader, tests, pattern):
5892
5893
if TODO_TESTS is None:
5894
from doctest import DocTestSuite, IGNORE_EXCEPTION_DETAIL
5895
+ orig_context = orig_sys_decimal.getcontext().copy()
5896
for mod in C, P:
5897
if not mod:
5898
continue
5899
def setUp(slf, mod=mod):
5900
sys.modules['decimal'] = mod
- def tearDown(slf):
5901
+ init(mod)
5902
+ def tearDown(slf, mod=mod):
5903
sys.modules['decimal'] = orig_sys_decimal
5904
+ mod.setcontext(ORIGINAL_CONTEXT[mod].copy())
5905
+ orig_sys_decimal.setcontext(orig_context.copy())
5906
optionflags = IGNORE_EXCEPTION_DETAIL if mod is C else 0
5907
5908
tests.addTest(DocTestSuite(mod, setUp=setUp, tearDown=tearDown,
@@ -5913,8 +5917,8 @@ def setUpModule():
5913
5917
TEST_ALL = ARITH if ARITH is not None else is_resource_enabled('decimal')
5914
5918
5915
5919
def tearDownModule():
5916
- if C: C.setcontext(ORIGINAL_CONTEXT[C])
- P.setcontext(ORIGINAL_CONTEXT[P])
5920
+ if C: C.setcontext(ORIGINAL_CONTEXT[C].copy())
5921
+ P.setcontext(ORIGINAL_CONTEXT[P].copy())
5922
if not C:
5923
warnings.warn('C tests skipped: no module named _decimal.',
5924
UserWarning)
0 commit comments