Skip to content

gh-143959: Fix test_datetime if _datetime is unavailable - #145248

Merged
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:test_datetime-no-_datetime
Mar 22, 2026
Merged

gh-143959: Fix test_datetime if _datetime is unavailable#145248
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:test_datetime-no-_datetime

Conversation

@serhiy-storchaka

@serhiy-storchakaserhiy-storchaka commented Feb 26, 2026

Copy link
Copy Markdown
Member

@serhiy-storchaka
serhiy-storchakaforce-pushed the test_datetime-no-_datetime branch from 6c63822 to 519b99eCompareFebruary 26, 2026 10:27
@vstinner

Copy link
Copy Markdown
Member

I tested this change with this local patch:

diff --git a/Lib/test/test_datetime.py b/Lib/test/test_datetime.py
index 005187f13e6..013816e99b3 100644
--- a/Lib/test/test_datetime.py+++ b/Lib/test/test_datetime.py@@ -4,6 +4,7 @@
from test.support.import_helper import import_fresh_module
+sys.modules['_datetime'] = None
TESTS = 'test.datetimetester'

On the main branch, test_datetime fails with:

test test_datetime crashed -- Traceback (most recent call last):
File "/home/vstinner/python/main/Lib/test/libregrtest/single.py", line 210, in _runtest_env_changed_exc
_load_run_test(result, runtests)
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
File "/home/vstinner/python/main/Lib/test/libregrtest/single.py", line 165, in _load_run_test
regrtest_runner(result, test_func, runtests)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vstinner/python/main/Lib/test/libregrtest/single.py", line 118, in regrtest_runner
test_result = test_func()
File "/home/vstinner/python/main/Lib/test/libregrtest/single.py", line 162, in test_func
return run_unittest(test_mod, runtests)
File "/home/vstinner/python/main/Lib/test/libregrtest/single.py", line 38, in run_unittest
raise Exception("errors while loading tests")
Exception: errors while loading tests

With this PR, test_datetime pass.

@vstinnervstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@serhiy-storchaka
serhiy-storchaka merged commit 97c725c into python:mainMar 22, 2026
49 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 22, 2026
…nGH-145248)
(cherry picked from commit 97c725c)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 22, 2026
…nGH-145248)
(cherry picked from commit 97c725c)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@bedevere-app

Copy link
Copy Markdown

GH-146288 is a backport of this pull request to the 3.14 branch.

@bedevere-appbedevere-appBot removed the needs backport to 3.14 bugs and security fixes label Mar 22, 2026
@bedevere-app

Copy link
Copy Markdown

GH-146289 is a backport of this pull request to the 3.13 branch.

@bedevere-appbedevere-appBot removed the needs backport to 3.13 bugs and security fixes label Mar 22, 2026
@serhiy-storchaka
serhiy-storchaka deleted the test_datetime-no-_datetime branch March 22, 2026 14:16
@serhiy-storchaka

Copy link
Copy Markdown
MemberAuthor

Thank you @vstinner for your review and for your patch #143997 (comment) which I used to write and test these changes.

serhiy-storchaka added a commit that referenced this pull request Mar 22, 2026
…45248) (GH-146289)
(cherry picked from commit 97c725c)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
serhiy-storchaka added a commit that referenced this pull request Mar 22, 2026
…45248) (GH-146288)
(cherry picked from commit 97c725c)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
CuriousLearner added a commit to CuriousLearner/cpython that referenced this pull request Mar 23, 2026
…8577
* 'main' of github.com:python/cpython:
pythongh-146197: Run -m test.pythoninfo on the Emscripten CI (python#146332)
pythongh-146325: Use `test.support.requires_fork` in test_fastpath_cache_cleared_in_forked_child (python#146330)
pythongh-146197: Add Emscripten to CI (python#146198)
pythongh-143387: Raise an exception instead of returning None when metadata file is missing. (python#146234)
pythongh-108907: ctypes: Document _type_ codes (pythonGH-145837)
pythongh-146175: Soft-deprecate outdated macros; convert internal usage (pythonGH-146178)
pythongh-146056: Rework ref counting in treebuilder_handle_end() (python#146167)
Add a warning about untrusted input to `configparser` docs (python#146276)
pythongh-145264: Do not ignore excess Base64 data after the first padded quad (pythonGH-145267)
pythongh-146308: Fix error handling issues in _remote_debugging module (python#146309)
pythongh-146192: Add base32 support to binascii (pythonGH-146193)
pythongh-135953: Properly obtain main thread identifier in Gecko Collector (python#146045)
pythongh-143414: Implement unique reference tracking for JIT, optimize unpacking of such tuples (pythonGH-144300)
pythongh-146261: Fix bug in `_Py_uop_sym_set_func_version` (pythonGH-146291)
pythongh-145144: Add more tests for UserList, UserDict, etc (pythonGH-145145)
pythongh-143959: Fix test_datetime if _datetime is unavailable (pythonGH-145248)
pythongh-146245: Fix reference and buffer leaks via audit hook in socket module (pythonGH-146248)
pythongh-140049: Colorize exception notes in `traceback.py` (python#140051)
Update docs for pythongh-146056 (pythonGH-146213)
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip newstestsTests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@serhiy-storchaka@vstinner