Skip to content
This repository was archived by the owner on Nov 29, 2023. It is now read-only.

Commit 919920f

Browse files
authored
nox unittest updates (#4646)
1 parent 4fe06e9 commit 919920f

File tree

1 file changed

+41
-12
lines changed

1 file changed

+41
-12
lines changed

nox.py

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,40 +13,69 @@
1313
# limitations under the License.
1414

1515
from __future__ import absolute_import
16+
1617
import os
1718

1819
import nox
1920

2021

22+
LOCAL_DEPS = (
23+
os.path.join('..', 'api_core'),
24+
)
25+
26+
2127
@nox.session
22-
@nox.parametrize('python_version', ['2.7', '3.4', '3.5', '3.6'])
23-
def unit_tests(session, python_version):
24-
"""Run the unit test suite."""
28+
def default(session):
29+
"""Default unit test session.
30+
31+
This is intended to be run **without** an interpreter set, so
32+
that the current ``python`` (on the ``PATH``) or the version of
33+
Python corresponding to the ``nox`` binary on the ``PATH`` can
34+
run the tests.
35+
"""
36+
# Install all test dependencies, then install this package in-place.
37+
session.install('mock', 'pytest', 'pytest-cov', *LOCAL_DEPS)
38+
session.install('-e', '.')
2539

26-
session.interpreter = 'python{}'.format(python_version)
40+
# Run py.test against the unit tests.
41+
session.run(
42+
'py.test',
43+
'--quiet',
44+
'--cov=google.cloud.container',
45+
'--cov=google.cloud.container_v1',
46+
'--cov=tests.unit',
47+
'--cov-append',
48+
'--cov-config=.coveragerc',
49+
'--cov-report=',
50+
os.path.join('tests', 'unit'),
51+
*session.posargs
52+
)
2753

28-
session.virtualenv_dirname = 'unit-' + python_version
2954

30-
session.install('pytest')
31-
session.install('-e', '.')
55+
@nox.session
56+
@nox.parametrize('py', ['2.7', '3.4', '3.5', '3.6'])
57+
def unit(session, py):
58+
"""Run the unit test suite."""
3259

33-
session.run('py.test', '--quiet', os.path.join('tests', 'unit'))
60+
session.interpreter = 'python{}'.format(py)
61+
session.virtualenv_dirname = 'unit-' + py
62+
default(session)
3463

3564

3665
@nox.session
37-
@nox.parametrize('python_version', ['2.7', '3.6'])
38-
def system_tests(session, python_version):
66+
@nox.parametrize('py', ['2.7', '3.6'])
67+
def system(session, py):
3968
"""Run the system test suite."""
4069

4170
# Sanity check: Only run system tests if the environment variable is set.
4271
if not os.environ.get('GOOGLE_APPLICATION_CREDENTIALS', ''):
4372
session.skip('Credentials must be set via environment variable.')
4473

4574
# Run the system tests against latest Python 2 and Python 3 only.
46-
session.interpreter = 'python{}'.format(python_version)
75+
session.interpreter = 'python{}'.format(py)
4776

4877
# Set the virtualenv dirname.
49-
session.virtualenv_dirname = 'sys-' + python_version
78+
session.virtualenv_dirname = 'sys-' + py
5079

5180
# Install all test dependencies, then install this package into the
5281
# virtualenv's dist-packages.

0 commit comments

Comments
 (0)