From d84c30a22eddeedc231460ee630723d4e20a3254 Mon Sep 17 00:00:00 2001 From: Hai Shi Date: Sun, 29 Mar 2020 15:10:20 +0800 Subject: [PATCH] Fix failed test_divide_and_round of test_datetime when run more than twice --- Lib/test/test_datetime.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Lib/test/test_datetime.py b/Lib/test/test_datetime.py index d659f369d54e46..00e713af860658 100644 --- a/Lib/test/test_datetime.py +++ b/Lib/test/test_datetime.py @@ -5,16 +5,11 @@ TESTS = 'test.datetimetester' -try: - pure_tests = import_fresh_module(TESTS, fresh=['datetime', '_strptime'], - blocked=['_datetime']) - fast_tests = import_fresh_module(TESTS, fresh=['datetime', - '_datetime', '_strptime']) -finally: - # XXX: import_fresh_module() is supposed to leave sys.module cache untouched, - # XXX: but it does not, so we have to cleanup ourselves. - for modname in ['datetime', '_datetime', '_strptime']: - sys.modules.pop(modname, None) +pure_tests = import_fresh_module(TESTS, fresh=['datetime', '_strptime'], + blocked=['_datetime']) +fast_tests = import_fresh_module(TESTS, fresh=['datetime', + '_datetime', '_strptime']) + test_modules = [pure_tests, fast_tests] test_suffixes = ["_Pure", "_Fast"] # XXX(gb) First run all the _Pure tests, then all the _Fast tests. You might