Skip to content

Conversation

@nmaynes
Copy link
Contributor

@nmaynes nmaynes commented Aug 4, 2020

Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whoops, will remove.

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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

Copy link
Member

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.

Copy link
Contributor Author

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!

@tirkarthi tirkarthi requested a review from pganssle August 4, 2020 13:43
Copy link
Member

@pganssle pganssle left a 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.

@bedevere-bot
Copy link

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 I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting changes skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants