-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
gh-143959: Split datetime tests requiring _datetime #143997
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 7 commits
df22dbc
3b42bcd
ecfbbbd
b227ee9
281077d
9fafddb
f21b5de
20b6944
b589068
73a161a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,25 +4,36 @@ | |
|
|
||
| from test.support.import_helper import import_fresh_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']) | ||
| try: | ||
| import _datetime | ||
| except ImportError: | ||
| has_datetime = False | ||
| else: | ||
| has_datetime = True | ||
| del _datetime | ||
| pure_tests = import_fresh_module( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can now restore the old formatting.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks — I’ve restored the original formatting.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is not restored yet.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I’ve now restored the original structure by keeping the two |
||
| TESTS, | ||
| fresh=['datetime', '_pydatetime', '_strptime'], | ||
| blocked=['_datetime'], | ||
| ) | ||
| fast_tests = import_fresh_module( | ||
| TESTS, | ||
| fresh=['datetime', '_strptime'], | ||
| blocked=['_pydatetime'], | ||
| ) | ||
|
VanshAgarwal24036 marked this conversation as resolved.
Outdated
|
||
| 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"] | ||
|
|
||
| # 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. | ||
|
|
@@ -45,6 +56,9 @@ def load_tests(loader, tests, pattern): | |
| class Wrapper(cls): | ||
| @classmethod | ||
| def setUpClass(cls_, module=module): | ||
| if module is fast_tests and not has_datetime: | ||
| raise unittest.SkipTest("requires _datetime module") | ||
|
|
||
| cls_._save_sys_modules = sys.modules.copy() | ||
| sys.modules[TESTS] = module | ||
| sys.modules['datetime'] = module.datetime_module | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.