From 2982dd3d565923509bab210eb45b800ce464fe8a Mon Sep 17 00:00:00 2001 From: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com> Date: Wed, 10 Oct 2018 11:04:44 -0700 Subject: [PATCH] Use new Nox (#6175) --- .kokoro/build.sh | 9 +++- api_core/{nox.py => noxfile.py} | 39 +++----------- asset/{nox.py => noxfile.py} | 25 +++------ automl/{nox.py => noxfile.py} | 31 ++++------- bigquery/{nox.py => noxfile.py} | 54 +++++--------------- bigquery_datatransfer/{nox.py => noxfile.py} | 23 ++------- bigtable/{nox.py => noxfile.py} | 36 +++---------- container/{nox.py => noxfile.py} | 31 +++-------- core/{nox.py => noxfile.py} | 31 +++-------- dataproc/{nox.py => noxfile.py} | 22 ++------ datastore/{nox.py => noxfile.py} | 47 +++++------------ dlp/{nox.py => noxfile.py} | 30 +++-------- dns/{nox.py => noxfile.py} | 24 ++------- error_reporting/{nox.py => noxfile.py} | 36 +++---------- firestore/{nox.py => noxfile.py} | 36 +++---------- iot/{nox.py => noxfile.py} | 36 ++++--------- tasks/nox.py => kms/noxfile.py | 26 +++------- language/{nox.py => noxfile.py} | 37 +++----------- logging/{nox.py => noxfile.py} | 49 ++++-------------- monitoring/{nox.py => noxfile.py} | 37 +++----------- oslogin/{nox.py => noxfile.py} | 25 +++------ pubsub/{nox.py => noxfile.py} | 41 +++------------ redis/{nox.py => noxfile.py} | 31 ++--------- resource_manager/{nox.py => noxfile.py} | 26 ++-------- runtimeconfig/{nox.py => noxfile.py} | 31 ++--------- spanner/{nox.py => noxfile.py} | 44 +++------------- speech/{nox.py => noxfile.py} | 36 +++---------- storage/{nox.py => noxfile.py} | 36 +++---------- kms/nox.py => tasks/noxfile.py | 23 ++------- texttospeech/{nox.py => noxfile.py} | 24 ++------- trace/{nox.py => noxfile.py} | 22 ++------ translate/{nox.py => noxfile.py} | 45 +++------------- videointelligence/{nox.py => noxfile.py} | 36 ++++--------- vision/{nox.py => noxfile.py} | 37 +++----------- websecurityscanner/{nox.py => noxfile.py} | 25 ++------- 35 files changed, 248 insertions(+), 893 deletions(-) rename api_core/{nox.py => noxfile.py} (77%) rename asset/{nox.py => noxfile.py} (74%) rename automl/{nox.py => noxfile.py} (58%) rename bigquery/{nox.py => noxfile.py} (79%) rename bigquery_datatransfer/{nox.py => noxfile.py} (82%) rename bigtable/{nox.py => noxfile.py} (80%) rename container/{nox.py => noxfile.py} (82%) rename core/{nox.py => noxfile.py} (81%) rename dataproc/{nox.py => noxfile.py} (84%) rename datastore/{nox.py => noxfile.py} (83%) rename dlp/{nox.py => noxfile.py} (81%) rename dns/{nox.py => noxfile.py} (82%) rename error_reporting/{nox.py => noxfile.py} (80%) rename firestore/{nox.py => noxfile.py} (80%) rename iot/{nox.py => noxfile.py} (71%) rename tasks/nox.py => kms/noxfile.py (74%) rename language/{nox.py => noxfile.py} (80%) rename logging/{nox.py => noxfile.py} (75%) rename monitoring/{nox.py => noxfile.py} (80%) rename oslogin/{nox.py => noxfile.py} (73%) rename pubsub/{nox.py => noxfile.py} (75%) rename redis/{nox.py => noxfile.py} (74%) rename resource_manager/{nox.py => noxfile.py} (81%) rename runtimeconfig/{nox.py => noxfile.py} (74%) rename spanner/{nox.py => noxfile.py} (74%) rename speech/{nox.py => noxfile.py} (79%) rename storage/{nox.py => noxfile.py} (80%) rename kms/nox.py => tasks/noxfile.py (74%) rename texttospeech/{nox.py => noxfile.py} (73%) rename trace/{nox.py => noxfile.py} (84%) rename translate/{nox.py => noxfile.py} (73%) rename videointelligence/{nox.py => noxfile.py} (71%) rename vision/{nox.py => noxfile.py} (79%) rename websecurityscanner/{nox.py => noxfile.py} (81%) diff --git a/.kokoro/build.sh b/.kokoro/build.sh index 3d5347b0042e..39634b7d6d52 100755 --- a/.kokoro/build.sh +++ b/.kokoro/build.sh @@ -46,6 +46,11 @@ fi cd "$PACKAGE" -python3.6 -m pip install --quiet nox-automation +# Remove old nox +python3.6 -m pip uninstall --yes --quiet nox-automation -nox +# Install nox +python3.6 -m pip install --upgrade --quiet nox +python3.6 -m nox --version + +python3.6 -m nox diff --git a/api_core/nox.py b/api_core/noxfile.py similarity index 77% rename from api_core/nox.py rename to api_core/noxfile.py index 7d14ad9befb1..77ef2cec9327 100644 --- a/api_core/nox.py +++ b/api_core/noxfile.py @@ -19,7 +19,6 @@ import nox # pytype: disable=import-error -@nox.session def default(session): """Default unit test session. @@ -52,57 +51,37 @@ def default(session): ) -@nox.session -@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7']) -def unit(session, py): +@nox.session(python=['2.7', '3.5', '3.6', '3.7']) +def unit(session): """Run the unit test suite.""" - - # Run unit tests against all supported versions of Python. - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'unit-' + py - default(session) -@nox.session -@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7']) -def unit_grpc_gcp(session, py): +@nox.session(python=['2.7', '3.5', '3.6', '3.7']) +def unit_grpc_gcp(session): """Run the unit test suite with grpcio-gcp installed.""" - # Run unit tests against all supported versions of Python. - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'unit-grpc-gcp-' + py - # Install grpcio-gcp session.install('grpcio-gcp') default(session) -@nox.session +@nox.session(python='3.6') def lint(session): """Run linters. Returns a failure if the linters find linting errors or sufficiently serious code quality issues. """ - session.interpreter = 'python3.6' session.install('flake8', 'flake8-import-order') session.install('.') session.run('flake8', 'google', 'tests') -@nox.session +@nox.session(python='3.6') def lint_setup_py(session): """Verify that setup.py is valid (including RST check).""" - session.interpreter = 'python3.6' - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'setup' session.install('docutils', 'Pygments') session.run( @@ -111,10 +90,9 @@ def lint_setup_py(session): # No 2.7 due to https://github.com/google/importlab/issues/26. # No 3.7 because pytype supports up to 3.6 only. -@nox.session +@nox.session(python='3.6') def pytype(session): """Run type-checking.""" - session.interpreter = 'python3.6' session.install('.', 'grpcio >= 1.8.2', 'grpcio-gcp >= 0.2.2', @@ -122,14 +100,13 @@ def pytype(session): session.run('pytype') -@nox.session +@nox.session(python='3.6') def cover(session): """Run the final coverage report. This outputs the coverage report aggregating coverage from the unit test runs (not system test runs), and then erases coverage data. """ - session.interpreter = 'python3.6' session.install('coverage', 'pytest-cov') session.run('coverage', 'report', '--show-missing', '--fail-under=100') session.run('coverage', 'erase') diff --git a/asset/nox.py b/asset/noxfile.py similarity index 74% rename from asset/nox.py rename to asset/noxfile.py index 884edf60d671..a3ed016336e6 100644 --- a/asset/nox.py +++ b/asset/noxfile.py @@ -19,24 +19,7 @@ import nox - -@nox.session def default(session): - return unit(session, 'default') - - -@nox.session -@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7']) -def unit(session, py): - """Run the unit test suite.""" - - # Run unit tests against all supported versions of Python. - if py != 'default': - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv directory name. - session.virtualenv_dirname = 'unit-' + py - # Install all test dependencies, then install this package in-place. session.install('pytest') session.install('-e', '.') @@ -45,10 +28,14 @@ def unit(session, py): session.run('py.test', '--quiet', os.path.join('tests', 'unit')) -@nox.session +@nox.session(python=['2.7', '3.5', '3.6', '3.7']) +def unit(session): + """Run the unit test suite.""" + default(session) + +@nox.session(python='3.6') def lint_setup_py(session): """Verify that setup.py is valid (including RST check).""" - session.interpreter = 'python3.6' session.install('docutils', 'pygments') session.run('python', 'setup.py', 'check', '--restructuredtext', '--strict') diff --git a/automl/nox.py b/automl/noxfile.py similarity index 58% rename from automl/nox.py rename to automl/noxfile.py index 58f8c2b507ce..8277b35f8a35 100644 --- a/automl/nox.py +++ b/automl/noxfile.py @@ -18,35 +18,24 @@ import nox -@nox.session def default(session): - return unit(session, 'default') + # Install all test dependencies, then install this package in-place. + session.install('pytest') + session.install('-e', '.') + # Run py.test against the unit tests. + session.run('py.test', '--quiet', os.path.join('tests', 'unit')) -@nox.session -@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7']) -def unit(session, py): - """Run the unit test suite.""" - - # Run unit tests against all supported versions of Python. - if py != 'default': - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv directory name. - session.virtualenv_dirname = 'unit-' + py - # Install all test dependencies, then install this package in-place. - session.install('pytest') - session.install('-e', '.') - - # Run py.test against the unit tests. - session.run('py.test', '--quiet', os.path.join('tests', 'unit')) +@nox.session(python=['2.7', '3.5', '3.6', '3.7']) +def unit(session): + """Run the unit test suite.""" + default(session) -@nox.session +@nox.session(python='3.6') def lint_setup_py(session): """Verify that setup.py is valid (including RST check).""" - session.interpreter = 'python3.6' session.install('docutils', 'pygments') session.run('python', 'setup.py', 'check', '--restructuredtext', '--strict') diff --git a/bigquery/nox.py b/bigquery/noxfile.py similarity index 79% rename from bigquery/nox.py rename to bigquery/noxfile.py index 902b6e663633..21b8487039cc 100644 --- a/bigquery/nox.py +++ b/bigquery/noxfile.py @@ -25,7 +25,6 @@ ) -@nox.session def default(session): """Default unit test session. @@ -40,14 +39,14 @@ def default(session): session.install('-e', local_dep) # Pyarrow does not support Python 3.7 - if session.interpreter == 'python3.7': + if session.python == '3.7': dev_install = '.[pandas]' else: dev_install = '.[pandas, pyarrow]' session.install('-e', dev_install) # IPython does not support Python 2 after version 5.x - if session.interpreter == 'python2.7': + if session.python == '2.7': session.install('ipython==5.5') else: session.install('ipython') @@ -67,35 +66,20 @@ def default(session): ) -@nox.session -@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7']) -def unit(session, py): +@nox.session(python=['2.7', '3.5', '3.6', '3.7']) +def unit(session): """Run the unit test suite.""" - - # Run unit tests against all supported versions of Python. - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'unit-' + py - default(session) -@nox.session -@nox.parametrize('py', ['2.7', '3.6']) -def system(session, py): +@nox.session(python=['2.7', '3.6']) +def system(session): """Run the system test suite.""" # Sanity check: Only run system tests if the environment variable is set. if not os.environ.get('GOOGLE_APPLICATION_CREDENTIALS', ''): session.skip('Credentials must be set via environment variable.') - # Run the system tests against latest Python 2 and Python 3 only. - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'sys-' + py - # Use pre-release gRPC for system tests. session.install('--pre', 'grpcio') @@ -108,7 +92,7 @@ def system(session, py): session.install('-e', '.[pandas]') # IPython does not support Python 2 after version 5.x - if session.interpreter == 'python2.7': + if session.python == '2.7': session.install('ipython==5.5') else: session.install('ipython') @@ -122,21 +106,14 @@ def system(session, py): ) -@nox.session -@nox.parametrize('py', ['2.7', '3.6']) -def snippets(session, py): +@nox.session(python=['2.7', '3.6']) +def snippets(session): """Run the system test suite.""" # Sanity check: Only run system tests if the environment variable is set. if not os.environ.get('GOOGLE_APPLICATION_CREDENTIALS', ''): session.skip('Credentials must be set via environment variable.') - # Run the system tests against latest Python 2 and Python 3 only. - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'snip-' + py - # Install all test dependencies, then install local packages in place. session.install('mock', 'pytest') for local_dep in LOCAL_DEPS: @@ -150,14 +127,13 @@ def snippets(session, py): 'py.test', os.path.join('docs', 'snippets.py'), *session.posargs) -@nox.session +@nox.session(python='3.6') def lint(session): """Run linters. Returns a failure if the linters find linting errors or sufficiently serious code quality issues. """ - session.interpreter = 'python3.6' session.install('flake8', *LOCAL_DEPS) session.install('.') @@ -167,28 +143,22 @@ def lint(session): 'flake8', os.path.join('docs', 'snippets.py')) -@nox.session +@nox.session(python='3.6') def lint_setup_py(session): """Verify that setup.py is valid (including RST check).""" - session.interpreter = 'python3.6' - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'setup' session.install('docutils', 'Pygments') session.run( 'python', 'setup.py', 'check', '--restructuredtext', '--strict') -@nox.session +@nox.session(python='3.6') def cover(session): """Run the final coverage report. This outputs the coverage report aggregating coverage from the unit test runs (not system test runs), and then erases coverage data. """ - session.interpreter = 'python3.6' - session.install('coverage', 'pytest-cov') session.run('coverage', 'report', '--show-missing', '--fail-under=100') session.run('coverage', 'erase') diff --git a/bigquery_datatransfer/nox.py b/bigquery_datatransfer/noxfile.py similarity index 82% rename from bigquery_datatransfer/nox.py rename to bigquery_datatransfer/noxfile.py index 5058fabc8067..fd85b781786b 100644 --- a/bigquery_datatransfer/nox.py +++ b/bigquery_datatransfer/noxfile.py @@ -24,7 +24,6 @@ ) -@nox.session def default(session): """Default unit test session. @@ -52,40 +51,28 @@ def default(session): ) -@nox.session -@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7']) -def unit(session, py): +@nox.session(python=['2.7', '3.5', '3.6', '3.7']) +def unit(session): """Run the unit test suite.""" - - session.interpreter = 'python{}'.format(py) - session.virtualenv_dirname = 'unit-' + py default(session) -@nox.session +@nox.session(python='3.6') def lint_setup_py(session): """Verify that setup.py is valid (including RST check).""" - session.interpreter = 'python3.6' session.install('docutils', 'pygments') session.run('python', 'setup.py', 'check', '--restructuredtext', '--strict') -@nox.session -@nox.parametrize('py', ['2.7', '3.6']) -def system(session, py): +@nox.session(python=['2.7', '3.6']) +def system(session): """Run the system test suite.""" # Sanity check: Only run system tests if the environment variable is set. if not os.environ.get('GOOGLE_APPLICATION_CREDENTIALS', ''): session.skip('Credentials must be set via environment variable.') - # Run the system tests against latest Python 2 and Python 3 only. - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'sys-' + py - # Use pre-release gRPC for system tests. session.install('--pre', 'grpcio') diff --git a/bigtable/nox.py b/bigtable/noxfile.py similarity index 80% rename from bigtable/nox.py rename to bigtable/noxfile.py index 1e8ce157ee81..28738b0c42fb 100644 --- a/bigtable/nox.py +++ b/bigtable/noxfile.py @@ -24,7 +24,6 @@ ) -@nox.session def default(session): """Default unit test session. @@ -54,35 +53,20 @@ def default(session): ) -@nox.session -@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7']) -def unit(session, py): +@nox.session(python=['2.7', '3.5', '3.6', '3.7']) +def unit(session): """Run the unit test suite.""" - - # Run unit tests against all supported versions of Python. - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'unit-' + py - default(session) -@nox.session -@nox.parametrize('py', ['2.7', '3.7']) -def system(session, py): +@nox.session(python=['2.7', '3.7']) +def system(session): """Run the system test suite.""" # Sanity check: Only run system tests if the environment variable is set. if not os.environ.get('GOOGLE_APPLICATION_CREDENTIALS', ''): session.skip('Credentials must be set via environment variable.') - # Run the system tests against latest Python 2 and Python 3 only. - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'sys-' + py - # Use pre-release gRPC for system tests. session.install('--pre', 'grpcio') @@ -98,40 +82,34 @@ def system(session, py): session.run('py.test', '--quiet', 'tests/system.py', *session.posargs) -@nox.session +@nox.session(python='3.6') def lint(session): """Run linters. Returns a failure if the linters find linting errors or sufficiently serious code quality issues. """ - session.interpreter = 'python3.6' session.install('flake8', *LOCAL_DEPS) session.install('.') session.run('flake8', 'google', 'tests') -@nox.session +@nox.session(python='3.6') def lint_setup_py(session): """Verify that setup.py is valid (including RST check).""" - session.interpreter = 'python3.6' - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'setup' session.install('docutils', 'Pygments') session.run( 'python', 'setup.py', 'check', '--restructuredtext', '--strict') -@nox.session +@nox.session(python='3.6') def cover(session): """Run the final coverage report. This outputs the coverage report aggregating coverage from the unit test runs (not system test runs), and then erases coverage data. """ - session.interpreter = 'python3.6' session.install('coverage', 'pytest-cov') session.run('coverage', 'report', '--show-missing', '--fail-under=100') session.run('coverage', 'erase') diff --git a/container/nox.py b/container/noxfile.py similarity index 82% rename from container/nox.py rename to container/noxfile.py index eb188487182d..37ad9c7cbad1 100644 --- a/container/nox.py +++ b/container/noxfile.py @@ -23,17 +23,13 @@ os.path.join('..', 'api_core'), ) - -@nox.session def default(session): """Default unit test session. - This is intended to be run **without** an interpreter set, so that the current ``python`` (on the ``PATH``) or the version of Python corresponding to the ``nox`` binary on the ``PATH`` can run the tests. """ - # Install all test dependencies, then install local packages in-place. session.install('mock', 'pytest', 'pytest-cov') for local_dep in LOCAL_DEPS: session.install('-e', local_dep) @@ -53,32 +49,20 @@ def default(session): *session.posargs ) - -@nox.session -@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7']) -def unit(session, py): - """Run the unit test suite.""" - - session.interpreter = 'python{}'.format(py) - session.virtualenv_dirname = 'unit-' + py +@nox.session(python=['2.7', '3.5', '3.6', '3.7']) +def unit(session): + """Default unit test session.""" + # Install all test dependencies, then install local packages in-place. default(session) - -@nox.session -@nox.parametrize('py', ['2.7', '3.6']) -def system(session, py): +@nox.session(python=['2.7', '3.6']) +def system(session): """Run the system test suite.""" # Sanity check: Only run system tests if the environment variable is set. if not os.environ.get('GOOGLE_APPLICATION_CREDENTIALS', ''): session.skip('Credentials must be set via environment variable.') - # Run the system tests against latest Python 2 and Python 3 only. - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'sys-' + py - # Use pre-release gRPC for system tests. session.install('--pre', 'grpcio') @@ -94,10 +78,9 @@ def system(session, py): session.run('py.test', '--quiet', 'tests/system/') -@nox.session +@nox.session(python='3.6') def lint_setup_py(session): """Verify that setup.py is valid (including RST check).""" - session.interpreter = 'python3.6' session.install('docutils', 'pygments') session.run('python', 'setup.py', 'check', '--restructuredtext', '--strict') diff --git a/core/nox.py b/core/noxfile.py similarity index 81% rename from core/nox.py rename to core/noxfile.py index e3d9a1ba701a..b35dbb8732a0 100644 --- a/core/nox.py +++ b/core/noxfile.py @@ -22,16 +22,14 @@ os.path.join('..', 'api_core'), ) - -@nox.session def default(session): """Default unit test session. - This is intended to be run **without** an interpreter set, so that the current ``python`` (on the ``PATH``) or the version of Python corresponding to the ``nox`` binary the ``PATH`` can run the tests. """ + # Install all test dependencies, then install local packages in-place. session.install( 'mock', @@ -58,54 +56,39 @@ def default(session): ) -@nox.session -@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7']) -def unit(session, py): - """Run the unit test suite.""" - - # Run unit tests against all supported versions of Python. - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'unit-' + py - +@nox.session(python=['2.7', '3.5', '3.6', '3.7']) +def unit(session): + """Default unit test session.""" default(session) - -@nox.session +@nox.session(python='3.6') def lint(session): """Run linters. Returns a failure if the linters find linting errors or sufficiently serious code quality issues. """ - session.interpreter = 'python3.6' session.install('flake8', 'flake8-import-order') session.install('.') session.run('flake8', 'google', 'tests') -@nox.session +@nox.session(python='3.6') def lint_setup_py(session): """Verify that setup.py is valid (including RST check).""" - session.interpreter = 'python3.6' - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'setup' session.install('docutils', 'Pygments') session.run( 'python', 'setup.py', 'check', '--restructuredtext', '--strict') -@nox.session +@nox.session(python='3.6') def cover(session): """Run the final coverage report. This outputs the coverage report aggregating coverage from the unit test runs (not system test runs), and then erases coverage data. """ - session.interpreter = 'python3.6' session.install('coverage', 'pytest-cov') session.run('coverage', 'report', '--show-missing', '--fail-under=100') session.run('coverage', 'erase') diff --git a/dataproc/nox.py b/dataproc/noxfile.py similarity index 84% rename from dataproc/nox.py rename to dataproc/noxfile.py index 3d84096895e3..ec3685373a7c 100644 --- a/dataproc/nox.py +++ b/dataproc/noxfile.py @@ -24,7 +24,6 @@ ) -@nox.session def default(session): """Default unit test session. @@ -52,28 +51,18 @@ def default(session): ) -@nox.session -@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7']) -def unit(session, py): +@nox.session(python=['2.7', '3.5', '3.6', '3.7']) +def unit(session): """Run the unit test suite.""" - - session.interpreter = 'python{}'.format(py) - session.virtualenv_dirname = 'unit-' + py default(session) -@nox.session -@nox.parametrize('py', ['2.7', '3.7']) -def system(session, py): +@nox.session(python=['2.7', '3.7']) +def system(session): """Run the system test suite.""" if not os.environ.get('GOOGLE_APPLICATION_CREDENTIALS', ''): session.skip('Credentials must be set via environment variable.') - - session.interpreter = 'python{}'.format(py) - - session.virtualenv_dirname = 'sys-' + py - # Use pre-release gRPC for system tests. session.install('--pre', 'grpcio') @@ -84,10 +73,9 @@ def system(session, py): *session.posargs) -@nox.session +@nox.session(python='3.6') def lint_setup_py(session): """Verify that setup.py is valid (including RST check).""" - session.interpreter = 'python3.6' session.install('docutils', 'pygments') session.run('python', 'setup.py', 'check', '--restructuredtext', '--strict') diff --git a/datastore/nox.py b/datastore/noxfile.py similarity index 83% rename from datastore/nox.py rename to datastore/noxfile.py index 79d04e1f16ba..39b4eef9c890 100644 --- a/datastore/nox.py +++ b/datastore/noxfile.py @@ -25,7 +25,6 @@ ) -@nox.session def default(session): """Default unit test session. @@ -55,35 +54,20 @@ def default(session): ) -@nox.session -@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7']) -def unit(session, py): +@nox.session(python=['2.7', '3.5', '3.6', '3.7']) +def unit(session): """Run the unit test suite.""" - - # Run unit tests against all supported versions of Python. - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'unit-' + py - default(session) -@nox.session -@nox.parametrize('py', ['2.7', '3.6']) -def system(session, py): +@nox.session(python=['2.7', '3.6']) +def system(session): """Run the system test suite.""" # Sanity check: Only run system tests if the environment variable is set. if not os.environ.get('GOOGLE_APPLICATION_CREDENTIALS', ''): session.skip('Credentials must be set via environment variable.') - # Run the system tests against latest Python 2 and Python 3 only. - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'sys-' + py - # Use pre-release gRPC for system tests. session.install('--pre', 'grpcio') @@ -98,19 +82,18 @@ def system(session, py): session.run('py.test', '--quiet', 'tests/system', *session.posargs) -@nox.session +@nox.session(python='3.6') def doctests(session): """Run the system test suite.""" + # Doctests run against Python 3.6 only. + # It is difficult to make doctests run against both Python 2 and Python 3 + # because they test string output equivalence, which is difficult to + # make match (e.g. unicode literals starting with "u"). # Sanity check: Only run system tests if the environment variable is set. if not os.environ.get('GOOGLE_APPLICATION_CREDENTIALS', ''): session.skip('Credentials must be set via environment variable.') - # Doctests run against Python 3.6 only. - # It is difficult to make doctests run against both Python 2 and Python 3 - # because they test string output equivalence, which is difficult to - # make match (e.g. unicode literals starting with "u"). - session.interpreter = 'python3.6' # Install all test dependencies, then install this package into the # virtualenv's dist-packages. @@ -124,40 +107,34 @@ def doctests(session): session.run('py.test', '--quiet', 'tests/doctests.py') -@nox.session +@nox.session(python='3.6') def lint(session): """Run linters. Returns a failure if the linters find linting errors or sufficiently serious code quality issues. """ - session.interpreter = 'python3.6' session.install('flake8', *LOCAL_DEPS) session.install('.') session.run('flake8', 'google', 'tests') -@nox.session +@nox.session(python='3.6') def lint_setup_py(session): """Verify that setup.py is valid (including RST check).""" - session.interpreter = 'python3.6' - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'setup' session.install('docutils', 'Pygments') session.run( 'python', 'setup.py', 'check', '--restructuredtext', '--strict') -@nox.session +@nox.session(python='3.6') def cover(session): """Run the final coverage report. This outputs the coverage report aggregating coverage from the unit test runs (not system test runs), and then erases coverage data. """ - session.interpreter = 'python3.6' session.install('coverage', 'pytest-cov') session.run('coverage', 'report', '--show-missing', '--fail-under=100') session.run('coverage', 'erase') diff --git a/dlp/nox.py b/dlp/noxfile.py similarity index 81% rename from dlp/nox.py rename to dlp/noxfile.py index 76e387099012..31bb3fcb7991 100644 --- a/dlp/nox.py +++ b/dlp/noxfile.py @@ -24,7 +24,6 @@ ) -@nox.session def default(session): """Run the unit test suite. @@ -49,32 +48,20 @@ def default(session): ) -@nox.session -@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7']) -def unit(session, py): +@nox.session(python=['2.7', '3.5', '3.6', '3.7']) +def unit(session): """Run the unit test suite.""" - # Run unit tests against all supported versions of Python. - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'unit-' + py - default(session) -@nox.session -@nox.parametrize('py', ['2.7', '3.6']) -def system(session, py): +@nox.session(python=['2.7', '3.6']) +def system(session): """Run the system test suite.""" if not os.environ.get('GOOGLE_APPLICATION_CREDENTIALS', ''): session.skip('Credentials must be set via environment variable.') - session.interpreter = 'python{}'.format(py) - - session.virtualenv_dirname = 'sys-' + py - # Use pre-release gRPC for system tests. session.install('--pre', 'grpcio') @@ -85,36 +72,33 @@ def system(session, py): os.path.join('tests', 'system'), *session.posargs) -@nox.session +@nox.session(python='3.6') def lint(session): """Run linters. Returns a failure if the linters find linting errors or sufficiently serious code quality issues. """ - session.interpreter = 'python3.6' session.install('flake8', *LOCAL_DEPS) session.install('.') session.run('flake8', 'google', 'tests') -@nox.session +@nox.session(python='3.6') def lint_setup_py(session): """Verify that setup.py is valid (including RST check).""" - session.interpreter = 'python3.6' session.install('docutils', 'pygments') session.run('python', 'setup.py', 'check', '--restructuredtext', '--strict') -@nox.session +@nox.session(python='3.6') def cover(session): """Run the final coverage report. This outputs the coverage report aggregating coverage from the unit test runs (not system test runs), and then erases coverage data. """ - session.interpreter = 'python3.6' session.chdir(os.path.dirname(__file__)) session.install('coverage', 'pytest-cov') session.run('coverage', 'report', '--show-missing', '--fail-under=100') diff --git a/dns/nox.py b/dns/noxfile.py similarity index 82% rename from dns/nox.py rename to dns/noxfile.py index e6a578ad4555..8ea0316d29db 100644 --- a/dns/nox.py +++ b/dns/noxfile.py @@ -25,7 +25,6 @@ ) -@nox.session def default(session): """Default unit test session. @@ -54,54 +53,41 @@ def default(session): ) -@nox.session -@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7']) -def unit(session, py): +@nox.session(python=['2.7', '3.5', '3.6', '3.7']) +def unit(session): """Run the unit test suite.""" - # Run unit tests against all supported versions of Python. - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'unit-' + py - default(session) -@nox.session +@nox.session(python='3.6') def lint(session): """Run linters. Returns a failure if the linters find linting errors or sufficiently serious code quality issues. """ - session.interpreter = 'python3.6' session.install('flake8', *LOCAL_DEPS) session.install('.') session.run('flake8', 'google', 'tests') -@nox.session +@nox.session(python='3.6') def lint_setup_py(session): """Verify that setup.py is valid (including RST check).""" - session.interpreter = 'python3.6' - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'setup' session.install('docutils', 'Pygments') session.run( 'python', 'setup.py', 'check', '--restructuredtext', '--strict') -@nox.session +@nox.session(python='3.6') def cover(session): """Run the final coverage report. This outputs the coverage report aggregating coverage from the unit test runs (not system test runs), and then erases coverage data. """ - session.interpreter = 'python3.6' session.install('coverage', 'pytest-cov') session.run('coverage', 'report', '--show-missing', '--fail-under=100') session.run('coverage', 'erase') diff --git a/error_reporting/nox.py b/error_reporting/noxfile.py similarity index 80% rename from error_reporting/nox.py rename to error_reporting/noxfile.py index f968977ece32..909559610370 100644 --- a/error_reporting/nox.py +++ b/error_reporting/noxfile.py @@ -26,7 +26,6 @@ ) -@nox.session def default(session): """Default unit test session. @@ -55,61 +54,41 @@ def default(session): ) -@nox.session -@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7']) -def unit(session, py): +@nox.session(python=['2.7', '3.5', '3.6', '3.7']) +def unit(session): """Run the unit test suite.""" - # Run unit tests against all supported versions of Python. - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'unit-' + py - default(session) -@nox.session +@nox.session(python='3.6') def lint(session): """Run linters. Returns a failure if the linters find linting errors or sufficiently serious code quality issues. """ - session.interpreter = 'python3.6' session.install('flake8', *LOCAL_DEPS) session.install('.') session.run('flake8', 'google', 'tests') -@nox.session +@nox.session(python='3.6') def lint_setup_py(session): """Verify that setup.py is valid (including RST check).""" - session.interpreter = 'python3.6' - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'setup' - session.install('docutils', 'Pygments') session.run( 'python', 'setup.py', 'check', '--restructuredtext', '--strict') -@nox.session -@nox.parametrize('py', ['2.7', '3.6']) -def system(session, py): +@nox.session(python=['2.7', '3.6']) +def system(session): """Run the system test suite.""" # Sanity check: Only run system tests if the environment variable is set. if not os.environ.get('GOOGLE_APPLICATION_CREDENTIALS', ''): session.skip('Credentials must be set via environment variable.') - # Run the system tests against latest Python 2 and Python 3 only. - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'sys-' + py - # Use pre-release gRPC for system tests. session.install('--pre', 'grpcio') @@ -124,14 +103,13 @@ def system(session, py): session.run('py.test', '-vvv', 'tests/system', *session.posargs) -@nox.session +@nox.session(python='3.6') def cover(session): """Run the final coverage report. This outputs the coverage report aggregating coverage from the unit test runs (not system test runs), and then erases coverage data. """ - session.interpreter = 'python3.6' session.install('coverage', 'pytest-cov') session.run('coverage', 'report', '--show-missing', '--fail-under=100') session.run('coverage', 'erase') diff --git a/firestore/nox.py b/firestore/noxfile.py similarity index 80% rename from firestore/nox.py rename to firestore/noxfile.py index 6b0dd65952ab..064f8044f182 100644 --- a/firestore/nox.py +++ b/firestore/noxfile.py @@ -26,7 +26,6 @@ ) -@nox.session def default(session): """Default unit test session. @@ -57,34 +56,20 @@ def default(session): ) -@nox.session -@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7']) -def unit(session, py): +@nox.session(python=['2.7', '3.5', '3.6', '3.7']) +def unit(session): """Run the unit test suite.""" - # Run unit tests against all supported versions of Python. - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'unit-' + py - default(session) -@nox.session -@nox.parametrize('py', ['2.7', '3.6']) -def system(session, py): +@nox.session(python=['2.7', '3.6']) +def system(session): """Run the system test suite.""" # Sanity check: Only run system tests if the environment variable is set. if not os.environ.get('FIRESTORE_APPLICATION_CREDENTIALS'): session.skip('Credentials must be set via environment variable.') - # Run the system tests against latest Python 2 and Python 3 only. - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'sys-' + py - # Use pre-release gRPC for system tests. session.install('--pre', 'grpcio') @@ -103,40 +88,33 @@ def system(session, py): ) -@nox.session +@nox.session(python='3.6') def lint(session): """Run linters. Returns a failure if the linters find linting errors or sufficiently serious code quality issues. """ - session.interpreter = 'python3.6' session.install('flake8', *LOCAL_DEPS) session.install('.') session.run('flake8', 'google', 'tests') -@nox.session +@nox.session(python='3.6') def lint_setup_py(session): """Verify that setup.py is valid (including RST check).""" - session.interpreter = 'python3.6' - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'setup' - session.install('docutils', 'Pygments') session.run( 'python', 'setup.py', 'check', '--restructuredtext', '--strict') -@nox.session +@nox.session(python='3.6') def cover(session): """Run the final coverage report. This outputs the coverage report aggregating coverage from the unit test runs (not system test runs), and then erases coverage data. """ - session.interpreter = 'python3.6' session.chdir(os.path.dirname(__file__)) session.install('coverage', 'pytest-cov') session.run('coverage', 'report', '--show-missing', '--fail-under=100') diff --git a/iot/nox.py b/iot/noxfile.py similarity index 71% rename from iot/nox.py rename to iot/noxfile.py index e7eebe585f33..2ce4269a0a93 100644 --- a/iot/nox.py +++ b/iot/noxfile.py @@ -18,23 +18,7 @@ import nox -@nox.session def default(session): - return unit(session, 'default') - - -@nox.session -@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7']) -def unit(session, py): - """Run the unit test suite.""" - - # Run unit tests against all supported versions of Python. - if py != 'default': - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv directory name. - session.virtualenv_dirname = 'unit-' + py - # Install all test dependencies, then install this package in-place. session.install('pytest') session.install('-e', '.') @@ -43,21 +27,20 @@ def unit(session, py): session.run('py.test', '--quiet', os.path.join('tests', 'unit')) -@nox.session -@nox.parametrize('py', ['2.7', '3.7']) -def system(session, py): +@nox.session(python=['2.7', '3.5', '3.6', '3.7']) +def unit(session): + """Run the unit test suite.""" + default(session) + + +@nox.session(python=['2.7', '3.7']) +def system(session): """Run the system test suite.""" # Sanity check: Only run system tests if the environment variable is set. if not os.environ.get('GOOGLE_APPLICATION_CREDENTIALS', ''): session.skip('Credentials must be set via environment variable.') - # Run unit tests against all supported versions of Python. - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'sys-' + py - # Install all test dependencies, then install this package in-place. session.install('pytest') session.install('-e', '.') @@ -67,10 +50,9 @@ def system(session, py): *session.posargs) -@nox.session +@nox.session(python='3.6') def lint_setup_py(session): """Verify that setup.py is valid (including RST check).""" - session.interpreter = 'python3.6' session.install('docutils', 'pygments') session.run('python', 'setup.py', 'check', '--restructuredtext', '--strict') diff --git a/tasks/nox.py b/kms/noxfile.py similarity index 74% rename from tasks/nox.py rename to kms/noxfile.py index 884edf60d671..6f269e97eb5e 100644 --- a/tasks/nox.py +++ b/kms/noxfile.py @@ -20,23 +20,7 @@ import nox -@nox.session def default(session): - return unit(session, 'default') - - -@nox.session -@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7']) -def unit(session, py): - """Run the unit test suite.""" - - # Run unit tests against all supported versions of Python. - if py != 'default': - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv directory name. - session.virtualenv_dirname = 'unit-' + py - # Install all test dependencies, then install this package in-place. session.install('pytest') session.install('-e', '.') @@ -45,10 +29,16 @@ def unit(session, py): session.run('py.test', '--quiet', os.path.join('tests', 'unit')) -@nox.session +@nox.session(python=['2.7', '3.5', '3.6', '3.7']) +def unit(session): + """Run the unit test suite.""" + default(session) + + + +@nox.session(python='3.6') def lint_setup_py(session): """Verify that setup.py is valid (including RST check).""" - session.interpreter = 'python3.6' session.install('docutils', 'pygments') session.run('python', 'setup.py', 'check', '--restructuredtext', '--strict') diff --git a/language/nox.py b/language/noxfile.py similarity index 80% rename from language/nox.py rename to language/noxfile.py index 9ea66d4a737c..a8fe8c5ac081 100644 --- a/language/nox.py +++ b/language/noxfile.py @@ -25,7 +25,6 @@ ) -@nox.session def default(session): """Default unit test session. @@ -54,35 +53,20 @@ def default(session): ) -@nox.session -@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7']) -def unit(session, py): +@nox.session(python=['2.7', '3.5', '3.6', '3.7']) +def unit(session): """Run the unit test suite.""" - - # Run unit tests against all supported versions of Python. - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'unit-' + py - default(session) -@nox.session -@nox.parametrize('py', ['2.7', '3.6']) -def system(session, py): +@nox.session(python=['2.7', '3.6']) +def system(session): """Run the system test suite.""" # Sanity check: Only run system tests if the environment variable is set. if not os.environ.get('GOOGLE_APPLICATION_CREDENTIALS', ''): session.skip('Credentials must be set via environment variable.') - # Run the system tests against latest Python 2 and Python 3 only. - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'sys-' + py - # Use pre-release gRPC for system tests. session.install('--pre', 'grpcio') @@ -98,40 +82,33 @@ def system(session, py): session.run('py.test', '--quiet', 'tests/system/') -@nox.session +@nox.session(python='3.6') def lint(session): """Run linters. Returns a failure if the linters find linting errors or sufficiently serious code quality issues. """ - session.interpreter = 'python3.6' session.install('flake8', *LOCAL_DEPS) session.install('.') session.run('flake8', 'google', 'tests') -@nox.session +@nox.session(python='3.6') def lint_setup_py(session): """Verify that setup.py is valid (including RST check).""" - session.interpreter = 'python3.6' - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'setup' - session.install('docutils', 'Pygments') session.run( 'python', 'setup.py', 'check', '--restructuredtext', '--strict') -@nox.session +@nox.session(python='3.6') def cover(session): """Run the final coverage report. This outputs the coverage report aggregating coverage from the unit test runs (not system test runs), and then erases coverage data. """ - session.interpreter = 'python3.6' session.install('coverage', 'pytest-cov') session.run('coverage', 'report', '--show-missing', '--fail-under=100') session.run('coverage', 'erase') diff --git a/logging/nox.py b/logging/noxfile.py similarity index 75% rename from logging/nox.py rename to logging/noxfile.py index 3ac0c3c9e217..dfc477e5d7dd 100644 --- a/logging/nox.py +++ b/logging/noxfile.py @@ -34,22 +34,13 @@ ) -@nox.session def default(session, django_dep=('django',)): """Default unit test session. - - This is intended to be run **without** an interpreter set, so - that the current ``python`` (on the ``PATH``) or the version of - Python corresponding to the ``nox`` binary the ``PATH`` can - run the tests. """ + # Install all test dependencies, then install this package in-place. deps = UNIT_TEST_DEPS - - if session.interpreter is None and sys.version_info[:2] == (2, 7): - deps += ('django >= 1.11.0, < 2.0.0dev',) - else: - deps += django_dep + deps += django_dep session.install(*deps) for local_dep in LOCAL_DEPS: @@ -71,17 +62,10 @@ def default(session, django_dep=('django',)): ) -@nox.session -@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7']) -def unit(session, py): +@nox.session(python=['2.7', '3.5', '3.6', '3.7']) +def unit(session): """Run the unit test suite.""" - # Run unit tests against all supported versions of Python. - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'unit-' + py - # Testing multiple version of django # See https://www.djangoproject.com/download/ for supported version django_deps_27 = [ @@ -89,27 +73,20 @@ def unit(session, py): ('django >= 1.11.0, < 2.0.0dev',), ] - if session.interpreter == 'python2.7': + if session.virtualenv.interpreter == '2.7': [default(session, django_dep=django) for django in django_deps_27] else: default(session) -@nox.session -@nox.parametrize('py', ['2.7', '3.6']) -def system(session, py): +@nox.session(python=['2.7', '3.6']) +def system(session): """Run the system test suite.""" # Sanity check: Only run system tests if the environment variable is set. if not os.environ.get('GOOGLE_APPLICATION_CREDENTIALS', ''): session.skip('Credentials must be set via environment variable.') - # Run the system tests against latest Python 2 and Python 3 only. - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'sys-' + py - # Use pre-release gRPC for system tests. session.install('--pre', 'grpcio') @@ -137,40 +114,34 @@ def system(session, py): *session.posargs) -@nox.session +@nox.session(python='3.6') def lint(session): """Run linters. Returns a failure if the linters find linting errors or sufficiently serious code quality issues. """ - session.interpreter = 'python3.6' session.install('flake8', *LOCAL_DEPS) session.install('.') session.run('flake8', 'google', 'tests') -@nox.session +@nox.session(python='3.6') def lint_setup_py(session): """Verify that setup.py is valid (including RST check).""" - session.interpreter = 'python3.6' - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'setup' session.install('docutils', 'Pygments') session.run( 'python', 'setup.py', 'check', '--restructuredtext', '--strict') -@nox.session +@nox.session(python='3.6') def cover(session): """Run the final coverage report. This outputs the coverage report aggregating coverage from the unit test runs (not system test runs), and then erases coverage data. """ - session.interpreter = 'python3.6' session.install('coverage', 'pytest-cov') session.run('coverage', 'report', '--show-missing', '--fail-under=100') session.run('coverage', 'erase') diff --git a/monitoring/nox.py b/monitoring/noxfile.py similarity index 80% rename from monitoring/nox.py rename to monitoring/noxfile.py index 045ddd9ecf9b..53ec4eff8f45 100644 --- a/monitoring/nox.py +++ b/monitoring/noxfile.py @@ -24,7 +24,6 @@ ) -@nox.session def default(session): """Default unit test session. @@ -54,35 +53,20 @@ def default(session): ) -@nox.session -@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7']) -def unit(session, py): +@nox.session(python=['2.7', '3.5', '3.6', '3.7']) +def unit(session): """Run the unit test suite.""" - - # Run unit tests against all supported versions of Python. - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'unit-' + py - default(session) -@nox.session -@nox.parametrize('py', ['2.7', '3.7']) -def system(session, py): +@nox.session(python=['2.7', '3.7']) +def system(session): """Run the system test suite.""" # Sanity check: Only run system tests if the environment variable is set. if not os.environ.get('GOOGLE_APPLICATION_CREDENTIALS', ''): session.skip('Credentials must be set via environment variable.') - # Run the system tests against latest Python 2 and Python 3 only. - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'sys-' + py - # Use pre-release gRPC for system tests. session.install('--pre', 'grpcio') @@ -98,40 +82,33 @@ def system(session, py): session.run('py.test', '--quiet', 'tests/system', *session.posargs) -@nox.session +@nox.session(python='3.6') def lint(session): """Run linters. Returns a failure if the linters find linting errors or sufficiently serious code quality issues. """ - session.interpreter = 'python3.6' session.install('flake8', *LOCAL_DEPS) session.install('.') session.run('flake8', 'google', 'tests') -@nox.session +@nox.session(python='3.6') def lint_setup_py(session): """Verify that setup.py is valid (including RST check).""" - session.interpreter = 'python3.6' - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'setup' - session.install('docutils', 'Pygments') session.run( 'python', 'setup.py', 'check', '--restructuredtext', '--strict') -@nox.session +@nox.session(python='3.6') def cover(session): """Run the final coverage report. This outputs the coverage report aggregating coverage from the unit test runs (not system test runs), and then erases coverage data. """ - session.interpreter = 'python3.6' session.install('coverage', 'pytest-cov') session.run('coverage', 'report', '--show-missing', '--fail-under=100') session.run('coverage', 'erase') diff --git a/oslogin/nox.py b/oslogin/noxfile.py similarity index 73% rename from oslogin/nox.py rename to oslogin/noxfile.py index 58f8c2b507ce..1b66d8b23018 100644 --- a/oslogin/nox.py +++ b/oslogin/noxfile.py @@ -18,23 +18,7 @@ import nox -@nox.session def default(session): - return unit(session, 'default') - - -@nox.session -@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7']) -def unit(session, py): - """Run the unit test suite.""" - - # Run unit tests against all supported versions of Python. - if py != 'default': - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv directory name. - session.virtualenv_dirname = 'unit-' + py - # Install all test dependencies, then install this package in-place. session.install('pytest') session.install('-e', '.') @@ -43,10 +27,15 @@ def unit(session, py): session.run('py.test', '--quiet', os.path.join('tests', 'unit')) -@nox.session +@nox.session(python=['2.7', '3.5', '3.6', '3.7']) +def unit(session): + """Run the unit test suite.""" + default(session) + + +@nox.session(python='3.6') def lint_setup_py(session): """Verify that setup.py is valid (including RST check).""" - session.interpreter = 'python3.6' session.install('docutils', 'pygments') session.run('python', 'setup.py', 'check', '--restructuredtext', '--strict') diff --git a/pubsub/nox.py b/pubsub/noxfile.py similarity index 75% rename from pubsub/nox.py rename to pubsub/noxfile.py index fc887cadfdc8..a061653d5407 100644 --- a/pubsub/nox.py +++ b/pubsub/noxfile.py @@ -28,11 +28,6 @@ @nox.session def default(session): """Default unit test session. - - This is intended to be run **without** an interpreter set, so - that the current ``python`` (on the ``PATH``) or the version of - Python corresponding to the ``nox`` binary the ``PATH`` can - run the tests. """ # Install all test dependencies, then install local packages in-place. session.install('mock', 'pytest', 'pytest-cov') @@ -54,35 +49,20 @@ def default(session): ) -@nox.session -@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7']) -def unit(session, py): +@nox.session(python=['2.7', '3.5', '3.6', '3.7']) +def unit(session): """Run the unit test suite.""" - - # Run unit tests against all supported versions of Python. - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'unit-' + py - default(session) -@nox.session -@nox.parametrize('py', ['2.7', '3.6']) -def system(session, py): +@nox.session(python=['2.7', '3.6']) +def system(session): """Run the system test suite.""" # Sanity check: Only run system tests if the environment variable is set. if not os.environ.get('GOOGLE_APPLICATION_CREDENTIALS', ''): session.skip('Credentials must be set via environment variable.') - # Run the system tests against latest Python 2 and Python 3 only. - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'sys-' + py - # Use pre-release gRPC for system tests. session.install('--pre', 'grpcio') @@ -102,40 +82,33 @@ def system(session, py): ) -@nox.session +@nox.session(python='3.6') def lint(session): """Run linters. Returns a failure if the linters find linting errors or sufficiently serious code quality issues. """ - session.interpreter = 'python3.6' session.install('flake8', *LOCAL_DEPS) session.install('.') session.run('flake8', 'google', 'tests') -@nox.session +@nox.session(python='3.6') def lint_setup_py(session): """Verify that setup.py is valid (including RST check).""" - session.interpreter = 'python3.6' - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'setup' - session.install('docutils', 'Pygments') session.run( 'python', 'setup.py', 'check', '--restructuredtext', '--strict') -@nox.session +@nox.session(python='3.6') def cover(session): """Run the final coverage report. This outputs the coverage report aggregating coverage from the unit test runs (not system test runs), and then erases coverage data. """ - session.interpreter = 'python3.6' session.install('coverage', 'pytest-cov') session.run('coverage', 'report', '--show-missing', '--fail-under=100') session.run('coverage', 'erase') diff --git a/redis/nox.py b/redis/noxfile.py similarity index 74% rename from redis/nox.py rename to redis/noxfile.py index 964788384a5c..c0a19036996f 100644 --- a/redis/nox.py +++ b/redis/noxfile.py @@ -25,14 +25,8 @@ ) -@nox.session def default(session): """Default unit test session. - - This is intended to be run **without** an interpreter set, so - that the current ``python`` (on the ``PATH``) or the version of - Python corresponding to the ``nox`` binary the ``PATH`` can - run the tests. """ # Install all test dependencies, then install local packages in-place. session.install('mock', 'pytest', 'pytest-cov') @@ -56,54 +50,39 @@ def default(session): ) -@nox.session -@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7']) -def unit(session, py): +@nox.session(python=['2.7', '3.5', '3.6', '3.7']) +def unit(session): """Run the unit test suite.""" - - # Run unit tests against all supported versions of Python. - if py != 'default': - session.interpreter = 'python{}'.format(py) - # Set the virtualenv directory name. - session.virtualenv_dirname = 'unit-' + py - default(session) -@nox.session +@nox.session(python='3.6') def lint(session): """Run linters. Returns a failure if the linters find linting errors or sufficiently serious code quality issues. """ - session.interpreter = 'python3.6' session.install('flake8', *LOCAL_DEPS) session.install('.') session.run('flake8', 'google', 'tests') -@nox.session +@nox.session(python='3.6') def lint_setup_py(session): """Verify that setup.py is valid (including RST check).""" - session.interpreter = 'python3.6' - - # Set the virtualenv directory name. - session.virtualenv_dirname = 'setup' - session.install('docutils', 'pygments') session.run('python', 'setup.py', 'check', '--restructuredtext', '--strict') -@nox.session +@nox.session(python='3.6') def cover(session): """Run the final coverage report. This outputs the coverage report aggregating coverage from the unit test runs (not system test runs), and then erases coverage data. """ - session.interpreter = 'python3.6' session.install('coverage', 'pytest-cov') session.run('coverage', 'report', '--show-missing', '--fail-under=100') session.run('coverage', 'erase') diff --git a/resource_manager/nox.py b/resource_manager/noxfile.py similarity index 81% rename from resource_manager/nox.py rename to resource_manager/noxfile.py index 1610698f6576..35bc9ad5805f 100644 --- a/resource_manager/nox.py +++ b/resource_manager/noxfile.py @@ -25,7 +25,6 @@ ) -@nox.session def default(session): """Default unit test session. @@ -54,54 +53,39 @@ def default(session): ) -@nox.session -@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7']) -def unit(session, py): - """Run the unit test suite.""" - - # Run unit tests against all supported versions of Python. - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'unit-' + py - +@nox.session(python=['2.7', '3.5', '3.6', '3.7']) +def unit(session): default(session) -@nox.session +@nox.session(python='3.6') def lint(session): """Run linters. Returns a failure if the linters find linting errors or sufficiently serious code quality issues. """ - session.interpreter = 'python3.6' session.install('flake8', *LOCAL_DEPS) session.install('.') session.run('flake8', 'google', 'tests') -@nox.session +@nox.session(python='3.6') def lint_setup_py(session): """Verify that setup.py is valid (including RST check).""" - session.interpreter = 'python3.6' - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'setup' session.install('docutils', 'Pygments') session.run( 'python', 'setup.py', 'check', '--restructuredtext', '--strict') -@nox.session +@nox.session(python='3.6') def cover(session): """Run the final coverage report. This outputs the coverage report aggregating coverage from the unit test runs (not system test runs), and then erases coverage data. """ - session.interpreter = 'python3.6' session.install('coverage', 'pytest-cov') session.run('coverage', 'report', '--show-missing', '--fail-under=100') session.run('coverage', 'erase') diff --git a/runtimeconfig/nox.py b/runtimeconfig/noxfile.py similarity index 74% rename from runtimeconfig/nox.py rename to runtimeconfig/noxfile.py index 7899d19c51d5..02dca1406752 100644 --- a/runtimeconfig/nox.py +++ b/runtimeconfig/noxfile.py @@ -25,14 +25,8 @@ ) -@nox.session def default(session): """Default unit test session. - - This is intended to be run **without** an interpreter set, so - that the current ``python`` (on the ``PATH``) or the version of - Python corresponding to the ``nox`` binary the ``PATH`` can - run the tests. """ # Install all test dependencies, then install this package in-place. session.install('mock', 'pytest', 'pytest-cov', *LOCAL_DEPS) @@ -52,54 +46,39 @@ def default(session): ) -@nox.session -@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7']) -def unit(session, py): +@nox.session(python=['2.7', '3.5', '3.6', '3.7']) +def unit(session): """Run the unit test suite.""" - - # Run unit tests against all supported versions of Python. - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'unit-' + py - default(session) -@nox.session +@nox.session(python='3.6') def lint(session): """Run linters. Returns a failure if the linters find linting errors or sufficiently serious code quality issues. """ - session.interpreter = 'python3.6' session.install('flake8', *LOCAL_DEPS) session.install('.') session.run('flake8', 'google', 'tests') -@nox.session +@nox.session(python='3.6') def lint_setup_py(session): """Verify that setup.py is valid (including RST check).""" - session.interpreter = 'python3.6' - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'setup' - session.install('docutils', 'Pygments') session.run( 'python', 'setup.py', 'check', '--restructuredtext', '--strict') -@nox.session +@nox.session(python='3.6') def cover(session): """Run the final coverage report. This outputs the coverage report aggregating coverage from the unit test runs (not system test runs), and then erases coverage data. """ - session.interpreter = 'python3.6' session.install('coverage', 'pytest-cov') session.run('coverage', 'report', '--show-missing', '--fail-under=100') session.run('coverage', 'erase') diff --git a/spanner/nox.py b/spanner/noxfile.py similarity index 74% rename from spanner/nox.py rename to spanner/noxfile.py index 7c307b078b05..290d5d17f4bf 100644 --- a/spanner/nox.py +++ b/spanner/noxfile.py @@ -25,15 +25,9 @@ ) -@nox.session def default(session): - """Default unit test session. + """Default unit test session.""" - This is intended to be run **without** an interpreter set, so - that the current ``python`` (on the ``PATH``) or the version of - Python corresponding to the ``nox`` binary the ``PATH`` can - run the tests. - """ # Install all test dependencies, then install local packages in-place. session.install('mock', 'pytest', 'pytest-cov') for local_dep in LOCAL_DEPS: @@ -56,17 +50,9 @@ def default(session): ) -@nox.session -@nox.parametrize('py', ['2.7', '3.4', '3.5', '3.6', '3.7']) -def unit(session, py): +@nox.session(python=['2.7', '3.4', '3.5', '3.6', '3.7']) +def unit(session): """Run the unit test suite.""" - - # Run unit tests against all supported versions of Python. - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'unit-' + py - default(session) @@ -85,58 +71,44 @@ def system_common(session): session.run('py.test', '--quiet', 'tests/system', *session.posargs) -@nox.session -@nox.parametrize('py', ['2.7', '3.6']) -def system(session, py): +@nox.session(python=['2.7', '3.6']) +def system(session): """Run the system test suite.""" # Sanity check: Only run system tests if the environment variable is set. if not os.environ.get('GOOGLE_APPLICATION_CREDENTIALS', ''): session.skip('Credentials must be set via environment variable.') - # Run the system tests against latest Python 2 and Python 3 only. - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'sys-' + py - system_common(session) -@nox.session +@nox.session(python='3.6') def lint(session): """Run linters. Returns a failure if the linters find linting errors or sufficiently serious code quality issues. """ - session.interpreter = 'python3.6' session.install('flake8', *LOCAL_DEPS) session.install('.') session.run('flake8', 'google', 'tests') -@nox.session +@nox.session(python='3.6') def lint_setup_py(session): """Verify that setup.py is valid (including RST check).""" - session.interpreter = 'python3.6' - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'setup' - session.install('docutils', 'Pygments') session.run( 'python', 'setup.py', 'check', '--restructuredtext', '--strict') -@nox.session +@nox.session(python='3.6') def cover(session): """Run the final coverage report. This outputs the coverage report aggregating coverage from the unit test runs (not system test runs), and then erases coverage data. """ - session.interpreter = 'python3.6' session.install('coverage', 'pytest-cov') session.run('coverage', 'report', '--show-missing', '--fail-under=100') session.run('coverage', 'erase') diff --git a/speech/nox.py b/speech/noxfile.py similarity index 79% rename from speech/nox.py rename to speech/noxfile.py index ee5edd578ef0..264c617cb39b 100644 --- a/speech/nox.py +++ b/speech/noxfile.py @@ -24,7 +24,6 @@ ) -@nox.session def default(session): """Default unit test session. @@ -50,35 +49,20 @@ def default(session): ) -@nox.session -@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7']) -def unit(session, py): +@nox.session(python=['2.7', '3.5', '3.6', '3.7']) +def unit(session): """Run the unit test suite.""" - - # Run unit tests against all supported versions of Python. - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'unit-' + py - default(session) -@nox.session -@nox.parametrize('py', ['2.7', '3.6']) -def system(session, py): +@nox.session(python=['2.7', '3.6']) +def system(session): """Run the system test suite.""" # Sanity check: Only run system tests if the environment variable is set. if not os.environ.get('GOOGLE_APPLICATION_CREDENTIALS', ''): session.skip('Credentials must be set via environment variable.') - # Run the system tests against latest Python 2 and Python 3 only. - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'sys-' + py - # Use pre-release gRPC for system tests. session.install('--pre', 'grpcio') @@ -92,40 +76,34 @@ def system(session, py): session.run('py.test', '--quiet', os.path.join('tests', 'system')) -@nox.session +@nox.session(python='3.6') def lint(session): """Run linters. Returns a failure if the linters find linting errors or sufficiently serious code quality issues. """ - session.interpreter = 'python3.6' session.install('flake8', *LOCAL_DEPS) session.install('.') session.run('flake8', 'google', 'tests') -@nox.session +@nox.session(python='3.6') def lint_setup_py(session): """Verify that setup.py is valid (including RST check).""" - session.interpreter = 'python3.6' - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'setup' session.install('docutils', 'Pygments') session.run( 'python', 'setup.py', 'check', '--restructuredtext', '--strict') -@nox.session +@nox.session(python='3.6') def cover(session): """Run the final coverage report. This outputs the coverage report aggregating coverage from the unit test runs (not system test runs), and then erases coverage data. """ - session.interpreter = 'python3.6' session.chdir(os.path.dirname(__file__)) session.install('coverage', 'pytest-cov') session.run('coverage', 'report', '--show-missing', '--fail-under=100') diff --git a/storage/nox.py b/storage/noxfile.py similarity index 80% rename from storage/nox.py rename to storage/noxfile.py index de8737970e80..d3a2b93dc117 100644 --- a/storage/nox.py +++ b/storage/noxfile.py @@ -55,35 +55,20 @@ def default(session): ) -@nox.session -@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7']) -def unit(session, py): +@nox.session(python=['2.7', '3.5', '3.6', '3.7']) +def unit(session): """Run the unit test suite.""" - - # Run unit tests against all supported versions of Python. - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'unit-' + py - default(session) -@nox.session -@nox.parametrize('py', ['2.7', '3.6']) -def system(session, py): +@nox.session(python=['2.7', '3.6']) +def system(session): """Run the system test suite.""" # Sanity check: Only run system tests if the environment variable is set. if not os.environ.get('GOOGLE_APPLICATION_CREDENTIALS', ''): session.skip('Credentials must be set via environment variable.') - # Run the system tests against latest Python 2 and Python 3 only. - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'sys-' + py - # Use pre-release gRPC for system tests. session.install('--pre', 'grpcio') @@ -104,40 +89,33 @@ def system(session, py): session.run('py.test', '--quiet', 'tests/system.py', *session.posargs) -@nox.session +@nox.session(python='3.6') def lint(session): """Run linters. Returns a failure if the linters find linting errors or sufficiently serious code quality issues. """ - session.interpreter = 'python3.6' session.install('flake8', *LOCAL_DEPS) session.install('.') session.run('flake8', 'google', 'tests') -@nox.session +@nox.session(python='3.6') def lint_setup_py(session): """Verify that setup.py is valid (including RST check).""" - session.interpreter = 'python3.6' - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'setup' - session.install('docutils', 'Pygments') session.run( 'python', 'setup.py', 'check', '--restructuredtext', '--strict') -@nox.session +@nox.session(python='3.6') def cover(session): """Run the final coverage report. This outputs the coverage report aggregating coverage from the unit test runs (not system test runs), and then erases coverage data. """ - session.interpreter = 'python3.6' session.install('coverage', 'pytest-cov') session.run('coverage', 'report', '--show-missing', '--fail-under=100') session.run('coverage', 'erase') diff --git a/kms/nox.py b/tasks/noxfile.py similarity index 74% rename from kms/nox.py rename to tasks/noxfile.py index 884edf60d671..923322a74128 100644 --- a/kms/nox.py +++ b/tasks/noxfile.py @@ -20,23 +20,7 @@ import nox -@nox.session def default(session): - return unit(session, 'default') - - -@nox.session -@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7']) -def unit(session, py): - """Run the unit test suite.""" - - # Run unit tests against all supported versions of Python. - if py != 'default': - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv directory name. - session.virtualenv_dirname = 'unit-' + py - # Install all test dependencies, then install this package in-place. session.install('pytest') session.install('-e', '.') @@ -44,11 +28,14 @@ def unit(session, py): # Run py.test against the unit tests. session.run('py.test', '--quiet', os.path.join('tests', 'unit')) +@nox.session(python=['2.7', '3.5', '3.6', '3.7']) +def unit(session): + """Run the unit test suite.""" + default(session) -@nox.session +@nox.session(python='3.6') def lint_setup_py(session): """Verify that setup.py is valid (including RST check).""" - session.interpreter = 'python3.6' session.install('docutils', 'pygments') session.run('python', 'setup.py', 'check', '--restructuredtext', '--strict') diff --git a/texttospeech/nox.py b/texttospeech/noxfile.py similarity index 73% rename from texttospeech/nox.py rename to texttospeech/noxfile.py index 58f8c2b507ce..e0719dff7a85 100644 --- a/texttospeech/nox.py +++ b/texttospeech/noxfile.py @@ -17,24 +17,7 @@ import nox - -@nox.session def default(session): - return unit(session, 'default') - - -@nox.session -@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7']) -def unit(session, py): - """Run the unit test suite.""" - - # Run unit tests against all supported versions of Python. - if py != 'default': - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv directory name. - session.virtualenv_dirname = 'unit-' + py - # Install all test dependencies, then install this package in-place. session.install('pytest') session.install('-e', '.') @@ -42,11 +25,14 @@ def unit(session, py): # Run py.test against the unit tests. session.run('py.test', '--quiet', os.path.join('tests', 'unit')) +@nox.session(python=['2.7', '3.5', '3.6', '3.7']) +def unit(session): + """Run the unit test suite.""" + default(session) -@nox.session +@nox.session(python='3.6') def lint_setup_py(session): """Verify that setup.py is valid (including RST check).""" - session.interpreter = 'python3.6' session.install('docutils', 'pygments') session.run('python', 'setup.py', 'check', '--restructuredtext', '--strict') diff --git a/trace/nox.py b/trace/noxfile.py similarity index 84% rename from trace/nox.py rename to trace/noxfile.py index b248b21771a7..d636041905cb 100644 --- a/trace/nox.py +++ b/trace/noxfile.py @@ -25,7 +25,6 @@ ) -@nox.session def default(session): """Default unit test session. @@ -54,49 +53,38 @@ def default(session): ) -@nox.session -@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7']) -def unit(session, py): +@nox.session(python=['2.7', '3.5', '3.6', '3.7']) +def unit(session): """Run the unit test suite.""" - - # Run unit tests against all supported versions of Python. - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'unit-' + py - default(session) -@nox.session +@nox.session(python='3.6') def lint(session): """Run linters. Returns a failure if the linters find linting errors or sufficiently serious code quality issues. """ - session.interpreter = 'python3.6' session.install('flake8', *LOCAL_DEPS) session.install('.') session.run('flake8', 'google', 'tests') -@nox.session +@nox.session(python='3.6') def lint_setup_py(session): """Verify that setup.py is valid (including RST check).""" - session.interpreter = 'python3.6' session.install('docutils', 'pygments') session.run( 'python', 'setup.py', 'check', '--restructuredtext', '--strict') -@nox.session +@nox.session(python='3.6') def cover(session): """Run the final coverage report. This outputs the coverage report aggregating coverage from the unit test runs (not system test runs), and then erases coverage data. """ - session.interpreter = 'python3.6' session.install('coverage', 'pytest-cov') session.run('coverage', 'report', '--show-missing', '--fail-under=100') session.run('coverage', 'erase') diff --git a/translate/nox.py b/translate/noxfile.py similarity index 73% rename from translate/nox.py rename to translate/noxfile.py index 0e92e0526cb3..2b5ced7d60cc 100644 --- a/translate/nox.py +++ b/translate/noxfile.py @@ -25,15 +25,8 @@ ) -@nox.session def default(session): - """Default unit test session. - - This is intended to be run **without** an interpreter set, so - that the current ``python`` (on the ``PATH``) or the version of - Python corresponding to the ``nox`` binary the ``PATH`` can - run the tests. - """ + """Default unit test session.""" # Install all test dependencies, then install local packages in-place. session.install('mock', 'pytest', 'pytest-cov') for local_dep in LOCAL_DEPS: @@ -49,35 +42,20 @@ def default(session): ) -@nox.session -@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7']) -def unit(session, py): +@nox.session(python=['2.7', '3.5', '3.6', '3.7']) +def unit(session): """Run the unit test suite.""" - - # Run unit tests against all supported versions of Python. - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'unit-' + py - default(session) -@nox.session -@nox.parametrize('py', ['2.7', '3.6']) -def system(session, py): +@nox.session(python=['2.7', '3.6']) +def system(session): """Run the system test suite.""" # Sanity check: Only run system tests if the environment variable is set. if not os.environ.get('GOOGLE_APPLICATION_CREDENTIALS', ''): session.skip('Credentials must be set via environment variable.') - # Run the system tests against latest Python 2 and Python 3 only. - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'sys-' + py - # Use pre-release gRPC for system tests. session.install('--pre', 'grpcio') @@ -92,40 +70,33 @@ def system(session, py): session.run('py.test', '--quiet', 'tests/system.py') -@nox.session +@nox.session(python='3.6') def lint(session): """Run linters. Returns a failure if the linters find linting errors or sufficiently serious code quality issues. """ - session.interpreter = 'python3.6' session.install('flake8', *LOCAL_DEPS) session.install('.') session.run('flake8', 'google', 'tests') -@nox.session +@nox.session(python='3.6') def lint_setup_py(session): """Verify that setup.py is valid (including RST check).""" - session.interpreter = 'python3.6' - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'setup' - session.install('docutils', 'Pygments') session.run( 'python', 'setup.py', 'check', '--restructuredtext', '--strict') -@nox.session +@nox.session(python='3.6') def cover(session): """Run the final coverage report. This outputs the coverage report aggregating coverage from the unit test runs (not system test runs), and then erases coverage data. """ - session.interpreter = 'python3.6' session.install('coverage', 'pytest-cov') session.run('coverage', 'report', '--show-missing', '--fail-under=100') session.run('coverage', 'erase') diff --git a/videointelligence/nox.py b/videointelligence/noxfile.py similarity index 71% rename from videointelligence/nox.py rename to videointelligence/noxfile.py index 0686a1eda886..138a0a07f6a5 100644 --- a/videointelligence/nox.py +++ b/videointelligence/noxfile.py @@ -18,23 +18,7 @@ import nox -@nox.session def default(session): - return unit(session, 'default') - - -@nox.session -@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7']) -def unit(session, py): - """Run the unit test suite.""" - - # Run unit tests against all supported versions of Python. - if py != 'default': - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv directory name. - session.virtualenv_dirname = 'unit-' + py - # Install all test dependencies, then install this package in-place. session.install('pytest') session.install('-e', '.') @@ -43,22 +27,21 @@ def unit(session, py): session.run('py.test', '--quiet', os.path.join('tests', 'unit')) +@nox.session(python=['2.7', '3.5', '3.6', '3.7']) +def unit(session): + """Run the unit test suite.""" + default(session) + + # TODO: Fix generated system tests -#@nox.session -#@nox.parametrize('py', ['2.7', '3.7']) -#def system(session, py): +#@nox.session(python=['2.7', '3.7']) +#def system(session): # """Run the system test suite.""" # # # Sanity check: Only run system tests if the environment variable is set. # if not os.environ.get('GOOGLE_APPLICATION_CREDENTIALS', ''): # session.skip('Credentials must be set via environment variable.') # -# # Run unit tests against all supported versions of Python. -# session.interpreter = 'python{}'.format(py) -# -# # Set the virtualenv dirname. -# session.virtualenv_dirname = 'sys-' + py -# # # Install all test dependencies, then install this package in-place. # session.install('pytest') # session.install('-e', '.') @@ -68,10 +51,9 @@ def unit(session, py): # *session.posargs) -@nox.session +@nox.session(python='3.6') def lint_setup_py(session): """Verify that setup.py is valid (including RST check).""" - session.interpreter = 'python3.6' session.install('docutils', 'pygments') session.run('python', 'setup.py', 'check', '--restructuredtext', '--strict') diff --git a/vision/nox.py b/vision/noxfile.py similarity index 79% rename from vision/nox.py rename to vision/noxfile.py index bd9161231f50..fb759b89744e 100644 --- a/vision/nox.py +++ b/vision/noxfile.py @@ -25,7 +25,6 @@ ) -@nox.session def default(session): """Default unit test session. @@ -52,35 +51,20 @@ def default(session): ) -@nox.session -@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7']) -def unit(session, py): +@nox.session(python=['2.7', '3.5', '3.6', '3.7']) +def unit(session): """Run the unit test suite.""" - - # Run unit tests against all supported versions of Python. - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'unit-' + py - default(session) -@nox.session -@nox.parametrize('py', ['2.7', '3.6']) -def system(session, py): +@nox.session(python=['2.7', '3.6']) +def system(session): """Run the system test suite.""" # Sanity check: Only run system tests if the environment variable is set. if not os.environ.get('GOOGLE_APPLICATION_CREDENTIALS', ''): session.skip('Credentials must be set via environment variable.') - # Run unit tests against all supported versions of Python. - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'sys-' + py - # Use pre-release gRPC for system tests. session.install('--pre', 'grpcio') @@ -98,40 +82,33 @@ def system(session, py): ) -@nox.session +@nox.session(python='3.6') def lint(session): """Run linters. Returns a failure if the linters find linting errors or sufficiently serious code quality issues. """ - session.interpreter = 'python3.6' session.install('flake8', *LOCAL_DEPS) session.install('.') session.run('flake8', 'google', 'tests') -@nox.session +@nox.session(python='3.6') def lint_setup_py(session): """Verify that setup.py is valid (including RST check).""" - session.interpreter = 'python3.6' - - # Set the virtualenv dirname. - session.virtualenv_dirname = 'setup' - session.install('docutils', 'pygments') session.run( 'python', 'setup.py', 'check', '--restructuredtext', '--strict') -@nox.session +@nox.session(python='3.6') def cover(session): """Run the final coverage report. This outputs the coverage report aggregating coverage from the unit test runs (not system test runs), and then erases coverage data. """ - session.interpreter = 'python3.6' session.chdir(os.path.dirname(__file__)) session.install('coverage', 'pytest-cov') session.run('coverage', 'report', '--show-missing') diff --git a/websecurityscanner/nox.py b/websecurityscanner/noxfile.py similarity index 81% rename from websecurityscanner/nox.py rename to websecurityscanner/noxfile.py index 5ed90894aa55..69f09e830534 100644 --- a/websecurityscanner/nox.py +++ b/websecurityscanner/noxfile.py @@ -24,7 +24,6 @@ ) -@nox.session def default(session): """Default unit test session. @@ -52,55 +51,41 @@ def default(session): ) -@nox.session -@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7']) -def unit(session, py): +@nox.session(python=['2.7', '3.5', '3.6', '3.7']) +def unit(session): """Run the unit test suite.""" - # Run unit tests against all supported versions of Python. - if py != 'default': - session.interpreter = 'python{}'.format(py) - - # Set the virtualenv directory name. - session.virtualenv_dirname = 'unit-' + py - default(session) -@nox.session +@nox.session(python='3.6') def lint(session): """Run linters. Returns a failure if the linters find linting errors or sufficiently serious code quality issues. """ - session.interpreter = 'python3.6' session.install('flake8', *LOCAL_DEPS) session.install('.') session.run('flake8', 'google', 'tests') -@nox.session +@nox.session(python='3.6') def lint_setup_py(session): """Verify that setup.py is valid (including RST check).""" - session.interpreter = 'python3.6' - - # Set the virtualenv directory name. - session.virtualenv_dirname = 'setup' session.install('docutils', 'pygments') session.run('python', 'setup.py', 'check', '--restructuredtext', '--strict') -@nox.session +@nox.session(python='3.6') def cover(session): """Run the final coverage report. This outputs the coverage report aggregating coverage from the unit test runs (not system test runs), and then erases coverage data. """ - session.interpreter = 'python3.6' session.install('coverage', 'pytest-cov') session.run('coverage', 'report', '--show-missing', '--fail-under=100') session.run('coverage', 'erase')