-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
gh-131290: ensure that test files can be executed as standalone scripts #131371
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
Changes from 6 commits
a9c7bc0
b875bee
678893f
4670696
3241aeb
5ffd268
d3cdd6b
682613f
22c996d
6744e91
2509478
fd29fd1
a6868a2
bef8cc5
584e07b
9ec71f2
2134259
cd3f0bb
19e1a3a
d12e5c6
9e28fa4
ca81976
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 |
---|---|---|
|
@@ -260,4 +260,12 @@ def test_module_has_no_spec(self): | |
|
||
|
||
if __name__ == "__main__": | ||
import importlib.util | ||
|
||
# Adding the __spec__ attribute to the __main__ module | ||
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. Which test is failing because of the lack of 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. test_others
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. Can you make it a local solution for Pdb then? possibly extracting this test into a separate function? |
||
if getattr(sys.modules["__main__"], "__spec__", None) is None: | ||
sys.modules["__main__"].__spec__ = importlib.machinery.ModuleSpec( | ||
name="__main__", loader=None, origin="builtin" | ||
) | ||
|
||
unittest_main() |
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -1931,6 +1931,8 @@ def test_print_warning(self): | |||||||||||||
|
||||||||||||||
def test_unicode_guard_env(self): | ||||||||||||||
guard = os.environ.get(setup.UNICODE_GUARD_ENV) | ||||||||||||||
# if you run the test directly, | ||||||||||||||
# then look at the if __name__ == '__main__' of this file | ||||||||||||||
self.assertIsNotNone(guard, f"{setup.UNICODE_GUARD_ENV} not set") | ||||||||||||||
if guard.isascii(): | ||||||||||||||
# Skip to signify that the env var value was changed by the user; | ||||||||||||||
|
@@ -2546,4 +2548,5 @@ def test_test_result_get_state(self): | |||||||||||||
|
||||||||||||||
|
||||||||||||||
if __name__ == '__main__': | ||||||||||||||
os.environ['PYTHONREGRTEST_UNICODE_GUARD'] = 'some_value' # for test_unicode_guard_env | ||||||||||||||
unittest.main() | ||||||||||||||
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.
Suggested change
and add some |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Several tests are modified when called directly via ./python Lib/test/... | ||
MaximGit1 marked this conversation as resolved.
Show resolved
Hide resolved
|
Uh oh!
There was an error while loading. Please reload this page.