mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
GH-84976: Move Lib/datetime.py to Lib/_pydatetime
This breaks the tests, but we are keeping it as a separate commit so that the move operation and editing of the moved files are separate, for a cleaner history.
This commit is contained in:
parent
8d34031068
commit
65c4a2b326
4 changed files with 14 additions and 5 deletions
|
@ -39,6 +39,10 @@ except ImportError:
|
||||||
|
|
||||||
# Needed by test_datetime
|
# Needed by test_datetime
|
||||||
import _strptime
|
import _strptime
|
||||||
|
try:
|
||||||
|
import _pydatetime
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
#
|
#
|
||||||
|
|
||||||
pickle_loads = {pickle.loads, pickle._loads}
|
pickle_loads = {pickle.loads, pickle._loads}
|
||||||
|
@ -92,7 +96,7 @@ class TestModule(unittest.TestCase):
|
||||||
if '_Fast' in self.__class__.__name__:
|
if '_Fast' in self.__class__.__name__:
|
||||||
self.skipTest('Only run for Pure Python implementation')
|
self.skipTest('Only run for Pure Python implementation')
|
||||||
|
|
||||||
dar = datetime_module._divide_and_round
|
dar = _pydatetime._divide_and_round
|
||||||
|
|
||||||
self.assertEqual(dar(-10, -3), 3)
|
self.assertEqual(dar(-10, -3), 3)
|
||||||
self.assertEqual(dar(5, -2), -2)
|
self.assertEqual(dar(5, -2), -2)
|
||||||
|
|
|
@ -8,10 +8,12 @@ TESTS = 'test.datetimetester'
|
||||||
|
|
||||||
def load_tests(loader, tests, pattern):
|
def load_tests(loader, tests, pattern):
|
||||||
try:
|
try:
|
||||||
pure_tests = import_fresh_module(TESTS, fresh=['datetime', '_strptime'],
|
pure_tests = import_fresh_module(TESTS,
|
||||||
blocked=['_datetime'])
|
fresh=['datetime', '_pydatetime', '_strptime'],
|
||||||
fast_tests = import_fresh_module(TESTS, fresh=['datetime',
|
blocked=['_datetime'])
|
||||||
'_datetime', '_strptime'])
|
fast_tests = import_fresh_module(TESTS,
|
||||||
|
fresh=['datetime', '_strptime'],
|
||||||
|
blocked=['_pydatetime'])
|
||||||
finally:
|
finally:
|
||||||
# XXX: import_fresh_module() is supposed to leave sys.module cache untouched,
|
# XXX: import_fresh_module() is supposed to leave sys.module cache untouched,
|
||||||
# XXX: but it does not, so we have to cleanup ourselves.
|
# XXX: but it does not, so we have to cleanup ourselves.
|
||||||
|
@ -42,6 +44,8 @@ def load_tests(loader, tests, pattern):
|
||||||
cls_._save_sys_modules = sys.modules.copy()
|
cls_._save_sys_modules = sys.modules.copy()
|
||||||
sys.modules[TESTS] = module
|
sys.modules[TESTS] = module
|
||||||
sys.modules['datetime'] = module.datetime_module
|
sys.modules['datetime'] = module.datetime_module
|
||||||
|
if hasattr(module, '_pydatetime'):
|
||||||
|
sys.modules['_pydatetime'] = module._pydatetime
|
||||||
sys.modules['_strptime'] = module._strptime
|
sys.modules['_strptime'] = module._strptime
|
||||||
@classmethod
|
@classmethod
|
||||||
def tearDownClass(cls_):
|
def tearDownClass(cls_):
|
||||||
|
|
1
Python/stdlib_module_names.h
generated
1
Python/stdlib_module_names.h
generated
|
@ -56,6 +56,7 @@ static const char* _Py_stdlib_module_names[] = {
|
||||||
"_posixshmem",
|
"_posixshmem",
|
||||||
"_posixsubprocess",
|
"_posixsubprocess",
|
||||||
"_py_abc",
|
"_py_abc",
|
||||||
|
"_pydatetime",
|
||||||
"_pydecimal",
|
"_pydecimal",
|
||||||
"_pyio",
|
"_pyio",
|
||||||
"_pylong",
|
"_pylong",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue