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

Skip conda_tests session by default if user does not have conda #521

Merged
merged 3 commits into from
Dec 22, 2021
Merged

Skip conda_tests session by default if user does not have conda #521

merged 3 commits into from
Dec 22, 2021

Conversation

FollowTheProcess
Copy link
Collaborator

Fixes #520

Adds a simple session filter at the top of our noxfile.py that runs all sessions (other than conda_tests) by default, only adding conda_tests if the user has conda installed.

# Skip 'conda_tests' if user doesn't have conda installed
nox.options.sessions = ["tests", "cover", "blacken", "lint", "docs"]
if shutil.which("conda"):
    nox.options.sessions.append("conda_tests")

I also spotted a stray conda-dependent test without a pytest.mark.skipif(not HAS_CONDA) guard on it so I quickly added that too:

@pytest.mark.skipif(not HAS_CONDA, reason="Missing conda command.")
def test_condaenv_(make_conda):
    venv, dir_ = make_conda()
    assert not venv.is_offline()

Copy link
Collaborator

@DiddiLeija DiddiLeija left a comment

Choose a reason for hiding this comment

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

This works! Thank you @FollowTheProcess!

Copy link
Collaborator

@cjolowicz cjolowicz left a comment

Choose a reason for hiding this comment

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

Thanks for taking care of this!

How about using session.skip?

def conda_tests(session):
    if not shutil.which("conda"):
        session.skip("conda is not installed")
    ...

Nox's output will then make it clear that the session was skipped and why.

@FollowTheProcess
Copy link
Collaborator Author

@cjolowicz Didn't know about session.skip, that should be perfect. Weirdly though I still get the error!

image

I'm guessing that the

nox.session(..., venv_backend=conda)

is what triggers it? In which case it probably never gets to the session.skip line?

Copy link
Collaborator

@cjolowicz cjolowicz left a comment

Choose a reason for hiding this comment

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

Oh right, that makes sense.

@cjolowicz cjolowicz merged commit 60babe8 into wntrblm:main Dec 22, 2021
@FollowTheProcess FollowTheProcess deleted the conda-tests-filter branch December 22, 2021 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Conda tests session should skip rather than fail if conda not installed
3 participants