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 a default session list #40

Closed
duggelz opened this issue Aug 30, 2017 · 12 comments
Closed

Add a default session list #40

duggelz opened this issue Aug 30, 2017 · 12 comments
Milestone

Comments

@duggelz
Copy link

duggelz commented Aug 30, 2017

Invoking nox with no command line arguments runs every session. It would be useful if the nox.py could specify a default list of sessions to run in that case, for example

nox.default_sessions([ 'lint', 'tests' ])
@duggelz
Copy link
Author

duggelz commented Aug 30, 2017

CC @lukesneeringer

@lukesneeringer
Copy link
Contributor

lukesneeringer commented Aug 30, 2017

My suggestion is to actually make whether or not a session is a "default" session be part of session registration, e.g.

@nox.session(run_by_default=False)
def peekaboo(session):
    ...

This has a few limitations:

  • It only works if you use the @nox.session decorator; if you rely on session_foo function names, no dice. I assert this is fine.
  • There is no particularly good way to take a subset of parametrized sessions. So, in other words, while nox.default_sessions(["unit_tests(python_version='3.6')"]) would be easy (but eww!), it would be downright impossble if run_by_default only took a boolean. I assert this is also fine, and excluding parametrization should be done with session.skip
    • If we really needed this in the future, we could also make run_by_default accept a tuple with the permutations to run by default.

@theacodes
Copy link
Collaborator

I could go either way on this, but just noting that pytest's parametrize has pytest.param specifically for adding more information (marks) to individual runs:

# content of test_expectation.py
import pytest
@pytest.mark.parametrize("test_input,expected", [
    ("3+5", 8),
    ("2+4", 6),
    pytest.param("6*9", 42,
                 marks=pytest.mark.xfail),
])
def test_eval(test_input, expected):
    assert eval(test_input) == expected

If we want to go down the route that @lukesneeringer is suggesting we could do:

@nox.session
@nox.parametrize('foo, bar', [
     (1, 2),
     nox.param(3, 4, run_by_default=False)
])

@lukesneeringer
Copy link
Contributor

If we did that, would the entire kaboodle be an initial requirement, or just the more general case?

@theacodes
Copy link
Collaborator

theacodes commented Aug 30, 2017 via email

@lukesneeringer
Copy link
Contributor

I could get behind @nox.mark.default so long as if nothing is marked default, they all are.

Should we change to @nox.mark.parametrize?

@theacodes
Copy link
Collaborator

Eh, I'd be okay with just nox.default and nox.parametrize. I don't think our API surface will be big enough to need to separate those into a mark namespace.

@theacodes theacodes added this to the 1.0.0 milestone Jul 30, 2018
@pradyunsg
Copy link
Contributor

Agreed. I don't think nox needs a complete mark namespace.

@stsewd
Copy link
Collaborator

stsewd commented Aug 25, 2018

I would love to have an env variable for this, tox has TOXENV, when it is defined and you run tox, only that environment is ran. For nox we could have NOXSESSION.

@theacodes
Copy link
Collaborator

@stsewd that would be much easier to do than this proposal, and could be done independently.

@sethmlarson
Copy link
Contributor

I'm going to take a stab at implementing this, just signaling to anyone else if it's already in progress.

@theacodes
Copy link
Collaborator

Closing this in favor of #141, let's move the discussion there.

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

No branches or pull requests

6 participants