Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 23 additions & 10 deletions Lib/test/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,40 @@
import sys
import functools

from test.support.import_helper import import_fresh_module
from test.support.import_helper import import_fresh_module, import_module


TESTS = 'test.datetimetester'

def load_tests(loader, tests, pattern):
try:
pure_tests = import_fresh_module(TESTS,
fresh=['datetime', '_pydatetime', '_strptime'],
blocked=['_datetime'])
fast_tests = import_fresh_module(TESTS,
fresh=['datetime', '_strptime'],
blocked=['_pydatetime'])
pure_tests = import_fresh_module(
TESTS,
fresh=['datetime', '_pydatetime', '_strptime'],
blocked=['_datetime'],
)
fast_tests = None
try:
import_module('_datetime')
except ImportError:
fast_tests = None
else:
fast_tests = import_fresh_module(
TESTS,
fresh=['datetime', '_strptime'],
blocked=['_pydatetime'],
)
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']:
for modname in ['datetime', '_datetime', '_pydatetime', '_strptime']:
sys.modules.pop(modname, None)

test_modules = [pure_tests, fast_tests]
test_suffixes = ["_Pure", "_Fast"]
test_modules = [pure_tests]
test_suffixes = ["_Pure"]
if fast_tests is not None:
test_modules.append(fast_tests)
test_suffixes.append("_Fast")
# XXX(gb) First run all the _Pure tests, then all the _Fast tests. You might
# not believe this, but in spite of all the sys.modules trickery running a _Pure
# test last will leave a mix of pure and native datetime stuff lying around.
Expand Down
Loading