gh-143959: Make _datetime optional for test_sys#144003
gh-143959: Make _datetime optional for test_sys#144003serhiy-storchaka merged 3 commits intopython:mainfrom
Conversation
Lib/test/test_sys.py
Outdated
| self.assertEqual(sys.getsizeof(True, -1), size('') + self.longdigit) | ||
|
|
||
| def test_objecttypes(self): | ||
| import _datetime |
There was a problem hiding this comment.
I suggest to import it just before it is used, like collections.
And since it is optional, skip the corresponding test if the import fails.
There was a problem hiding this comment.
Thanks! Fixed it
There was a problem hiding this comment.
And since it is optional, skip the corresponding test if the import fails.
_datetime is now a built-in module, it's not really optional.
There was a problem hiding this comment.
Isn't it just an implementation detail? It was made builtin to solve a particular technical issue which can be solved in other way.
Lib/test/test_sys.py
Outdated
| check(x, size('5Pi')) | ||
| # PyCapsule | ||
| import _datetime | ||
| check(_datetime.datetime_CAPI, size('6P')) |
There was a problem hiding this comment.
As @serhiy-storchaka requested, this line should only be run if _datetime is available. Something like:
try:
import _datetime
except ImportError:
pass
else:
check(_datetime.datetime_CAPI, size('6P'))|
Thanks @youknowone for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14. |
(cherry picked from commit c447d1b) Co-authored-by: Jeong, YunWon <69878+youknowone@users.noreply.github.com>
(cherry picked from commit c447d1b) Co-authored-by: Jeong, YunWon <69878+youknowone@users.noreply.github.com>
|
GH-144143 is a backport of this pull request to the 3.14 branch. |
|
GH-144144 is a backport of this pull request to the 3.13 branch. |
The
_datetimedependency oftest_sysis only required for@cpython_onlydecorated test.