Skip to content

Commit df22dbc

Browse files
gh-143959: Split datetime tests requiring _datetime
1 parent 63cc125 commit df22dbc

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

Lib/test/test_datetime.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import sys
33
import functools
44

5+
from test import support
56
from test.support.import_helper import import_fresh_module
67

78

@@ -12,17 +13,24 @@ def load_tests(loader, tests, pattern):
1213
pure_tests = import_fresh_module(TESTS,
1314
fresh=['datetime', '_pydatetime', '_strptime'],
1415
blocked=['_datetime'])
15-
fast_tests = import_fresh_module(TESTS,
16-
fresh=['datetime', '_strptime'],
17-
blocked=['_pydatetime'])
16+
fast_tests = None
17+
if support.import_module('_datetime', required=False):
18+
fast_tests = import_fresh_module(
19+
TESTS,
20+
fresh=['datetime', '_strptime'],
21+
blocked=['_pydatetime'],
22+
)
1823
finally:
1924
# XXX: import_fresh_module() is supposed to leave sys.module cache untouched,
2025
# XXX: but it does not, so we have to cleanup ourselves.
21-
for modname in ['datetime', '_datetime', '_strptime']:
26+
for modname in ['datetime', '_datetime', '_pydatetime', '_strptime']:
2227
sys.modules.pop(modname, None)
2328

24-
test_modules = [pure_tests, fast_tests]
25-
test_suffixes = ["_Pure", "_Fast"]
29+
test_modules = [pure_tests]
30+
test_suffixes = ["_Pure"]
31+
if fast_tests is not None:
32+
test_modules.append(fast_tests)
33+
test_suffixes.append("_Fast")
2634
# XXX(gb) First run all the _Pure tests, then all the _Fast tests. You might
2735
# not believe this, but in spite of all the sys.modules trickery running a _Pure
2836
# test last will leave a mix of pure and native datetime stuff lying around.

0 commit comments

Comments
 (0)