Created
February 7, 2019 16:58
-
-
Save saml/a417fd27f5b1e015c8b69eb125e6037b to your computer and use it in GitHub Desktop.
nox and posargs where it starts with --
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import nox | |
@nox.session(python=['2.7', '3.6']) | |
def tests(session): | |
parser = argparse.ArgumentParser() | |
parser.add_argument('--notest', action='store_true', default=False, help='Install dependencies. But do not run test.') | |
parser.add_argument('args', nargs=argparse.REMAINDER) | |
args = parser.parse_args(session.posargs) | |
if not args.notest: | |
session.run('pytest', *args.args) | |
""" | |
$ nox -r -- --foo | |
nox > Running session tests-2.7 | |
nox > Re-using existing virtualenv at /tmp/.nox/tests-2-7. | |
usage: nox [-h] [--notest] ... | |
nox: error: unrecognized arguments: --foo | |
$ nox -r -- a --foo | |
nox > Running session tests-2.7 | |
nox > Re-using existing virtualenv at /tmp/.nox/tests-2-7. | |
nox > pytest a --foo | |
... | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment