Skip to content
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

Add runtime check for valid Python interpreter #7365

Merged
merged 13 commits into from Mar 14, 2019

Simplify skip_unless_any_pythons_present()

Use any() builtin. Earlier we were checking how many pythons are discovered. I realized that skipIf doesn't print the message when False, so this isn't very useful to spend the time figuring out as no one will read the message. Instead, make the code simpler.
  • Loading branch information...
Eric-Arellano committed Mar 12, 2019
commit 8dedbe258c5eb81cdae421440c4cb3f65a0c9840
@@ -58,12 +58,9 @@ def skip_unless_any_pythons_present(*versions):
:param string *versions: Python version strings, such as 2.7, 3.
"""
present_versions = [v for v in versions if has_python_version(v)]
if len(present_versions) == 0:
return skipIf(True, 'Could not find at least one of the required pythons on the system. Skipping.')
if len(present_versions) == 1:
return skipIf(False, 'One of the required pythons is present: {}. Continuing with test!'.format(present_versions[0]))
return skipIf(False, 'Multiple of the required pythons are present: {}. Continuing with the test!'.format(present_versions))
if any(v for v in versions if has_python_version(v)):
return skipIf(False, 'At least one of the expected python versions found.')
return skipIf(True, 'Could not find at least one of the required pythons from {} on the system. Skipping.'.format(versions))


def skip_unless_pythons(*versions):
This conversation was marked as resolved by Eric-Arellano

This comment has been minimized.

Copy link
@Eric-Arellano

Eric-Arellano Mar 12, 2019

Author Contributor

Note I really want to rename all the functions in this file to skip_unless_*_present. All the docstrings already use the word "present", and I think adding it to the name would make it much clearer in calling files what the decorator is doing. Avoided doing this here for scope creep.

This comment has been minimized.

Copy link
@Eric-Arellano

Eric-Arellano Mar 12, 2019

Author Contributor

Done in #7366!

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.