-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
bpo-41371: Handle lzma lib import error in test_zoneinfo.py #21730
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
Conversation
Doc/library/tkinter.rst
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes are unrelated to the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, will remove.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| raise unittest.skip("Failed to import lzma.") | |
| raise unittest.SkipTest("Failed to import lzma.") |
SkipTest is the appropriate exception to be raised. Using skip causes the below error.
./python -Wall -m test test_zoneinfo
0:00:00 load avg: 0.03 Run tests sequentially
0:00:00 load avg: 0.03 [1/1] test_zoneinfo
test test_zoneinfo crashed -- Traceback (most recent call last):
File "/root/cpython/Lib/test/test_zoneinfo/test_zoneinfo.py", line 26, in <module>
import lzma
File "/root/cpython/Lib/lzma.py", line 27, in <module>
from _lzma import *
ModuleNotFoundError: No module named '_lzma'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/root/cpython/Lib/test/libregrtest/runtest.py", line 272, in _runtest_inner
refleak = _runtest_inner2(ns, test_name)
File "/root/cpython/Lib/test/libregrtest/runtest.py", line 223, in _runtest_inner2
the_module = importlib.import_module(abstest)
File "/root/cpython/Lib/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 790, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/root/cpython/Lib/test/test_zoneinfo/__init__.py", line 1, in <module>
from .test_zoneinfo import *
File "/root/cpython/Lib/test/test_zoneinfo/test_zoneinfo.py", line 28, in <module>
raise unittest.skip("Failed to import lzma.")
TypeError: exceptions must derive from BaseException
test_zoneinfo failed
== Tests result: FAILURE ==
1 test failed:
test_zoneinfo
Total duration: 60 ms
Tests result: FAILURE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, @vstinner made a better suggestion in bpo-41475, using test.support.import_module to import lzma:
That skips the tests if the import fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ill update the PR later today. Thank you for the feedback!
pganssle
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @tirkarthi, please remove the unrelated changes and switch to raising unittest.SkipTest.
I'll note that there's also a requires_lzma decorator that does this, but I don't think it works at the test module level.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
https://bugs.python.org/issue41371