Skip to content

Commit 2982dd3

Browse files
busunkim96theacodes
authored andcommitted
Use new Nox (#6175)
1 parent b09856c commit 2982dd3

File tree

35 files changed

+248
-893
lines changed

35 files changed

+248
-893
lines changed

.kokoro/build.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ fi
4646

4747
cd "$PACKAGE"
4848

49-
python3.6 -m pip install --quiet nox-automation
49+
# Remove old nox
50+
python3.6 -m pip uninstall --yes --quiet nox-automation
5051

51-
nox
52+
# Install nox
53+
python3.6 -m pip install --upgrade --quiet nox
54+
python3.6 -m nox --version
55+
56+
python3.6 -m nox

api_core/nox.py renamed to api_core/noxfile.py

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import nox # pytype: disable=import-error
2020

2121

22-
@nox.session
2322
def default(session):
2423
"""Default unit test session.
2524
@@ -52,57 +51,37 @@ def default(session):
5251
)
5352

5453

55-
@nox.session
56-
@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7'])
57-
def unit(session, py):
54+
@nox.session(python=['2.7', '3.5', '3.6', '3.7'])
55+
def unit(session):
5856
"""Run the unit test suite."""
59-
60-
# Run unit tests against all supported versions of Python.
61-
session.interpreter = 'python{}'.format(py)
62-
63-
# Set the virtualenv dirname.
64-
session.virtualenv_dirname = 'unit-' + py
65-
6657
default(session)
6758

6859

69-
@nox.session
70-
@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7'])
71-
def unit_grpc_gcp(session, py):
60+
@nox.session(python=['2.7', '3.5', '3.6', '3.7'])
61+
def unit_grpc_gcp(session):
7262
"""Run the unit test suite with grpcio-gcp installed."""
7363

74-
# Run unit tests against all supported versions of Python.
75-
session.interpreter = 'python{}'.format(py)
76-
77-
# Set the virtualenv dirname.
78-
session.virtualenv_dirname = 'unit-grpc-gcp-' + py
79-
8064
# Install grpcio-gcp
8165
session.install('grpcio-gcp')
8266

8367
default(session)
8468

8569

86-
@nox.session
70+
@nox.session(python='3.6')
8771
def lint(session):
8872
"""Run linters.
8973
9074
Returns a failure if the linters find linting errors or sufficiently
9175
serious code quality issues.
9276
"""
93-
session.interpreter = 'python3.6'
9477
session.install('flake8', 'flake8-import-order')
9578
session.install('.')
9679
session.run('flake8', 'google', 'tests')
9780

9881

99-
@nox.session
82+
@nox.session(python='3.6')
10083
def lint_setup_py(session):
10184
"""Verify that setup.py is valid (including RST check)."""
102-
session.interpreter = 'python3.6'
103-
104-
# Set the virtualenv dirname.
105-
session.virtualenv_dirname = 'setup'
10685

10786
session.install('docutils', 'Pygments')
10887
session.run(
@@ -111,25 +90,23 @@ def lint_setup_py(session):
11190

11291
# No 2.7 due to https://github.com/google/importlab/issues/26.
11392
# No 3.7 because pytype supports up to 3.6 only.
114-
@nox.session
93+
@nox.session(python='3.6')
11594
def pytype(session):
11695
"""Run type-checking."""
117-
session.interpreter = 'python3.6'
11896
session.install('.',
11997
'grpcio >= 1.8.2',
12098
'grpcio-gcp >= 0.2.2',
12199
'pytype >= 2018.9.26')
122100
session.run('pytype')
123101

124102

125-
@nox.session
103+
@nox.session(python='3.6')
126104
def cover(session):
127105
"""Run the final coverage report.
128106
129107
This outputs the coverage report aggregating coverage from the unit
130108
test runs (not system test runs), and then erases coverage data.
131109
"""
132-
session.interpreter = 'python3.6'
133110
session.install('coverage', 'pytest-cov')
134111
session.run('coverage', 'report', '--show-missing', '--fail-under=100')
135112
session.run('coverage', 'erase')

asset/nox.py renamed to asset/noxfile.py

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,7 @@
1919

2020
import nox
2121

22-
23-
@nox.session
2422
def default(session):
25-
return unit(session, 'default')
26-
27-
28-
@nox.session
29-
@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7'])
30-
def unit(session, py):
31-
"""Run the unit test suite."""
32-
33-
# Run unit tests against all supported versions of Python.
34-
if py != 'default':
35-
session.interpreter = 'python{}'.format(py)
36-
37-
# Set the virtualenv directory name.
38-
session.virtualenv_dirname = 'unit-' + py
39-
4023
# Install all test dependencies, then install this package in-place.
4124
session.install('pytest')
4225
session.install('-e', '.')
@@ -45,10 +28,14 @@ def unit(session, py):
4528
session.run('py.test', '--quiet', os.path.join('tests', 'unit'))
4629

4730

48-
@nox.session
31+
@nox.session(python=['2.7', '3.5', '3.6', '3.7'])
32+
def unit(session):
33+
"""Run the unit test suite."""
34+
default(session)
35+
36+
@nox.session(python='3.6')
4937
def lint_setup_py(session):
5038
"""Verify that setup.py is valid (including RST check)."""
51-
session.interpreter = 'python3.6'
5239
session.install('docutils', 'pygments')
5340
session.run('python', 'setup.py', 'check', '--restructuredtext',
5441
'--strict')

automl/nox.py renamed to automl/noxfile.py

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,35 +18,24 @@
1818
import nox
1919

2020

21-
@nox.session
2221
def default(session):
23-
return unit(session, 'default')
22+
# Install all test dependencies, then install this package in-place.
23+
session.install('pytest')
24+
session.install('-e', '.')
2425

26+
# Run py.test against the unit tests.
27+
session.run('py.test', '--quiet', os.path.join('tests', 'unit'))
2528

26-
@nox.session
27-
@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7'])
28-
def unit(session, py):
29-
"""Run the unit test suite."""
30-
31-
# Run unit tests against all supported versions of Python.
32-
if py != 'default':
33-
session.interpreter = 'python{}'.format(py)
34-
35-
# Set the virtualenv directory name.
36-
session.virtualenv_dirname = 'unit-' + py
3729

38-
# Install all test dependencies, then install this package in-place.
39-
session.install('pytest')
40-
session.install('-e', '.')
41-
42-
# Run py.test against the unit tests.
43-
session.run('py.test', '--quiet', os.path.join('tests', 'unit'))
30+
@nox.session(python=['2.7', '3.5', '3.6', '3.7'])
31+
def unit(session):
32+
"""Run the unit test suite."""
33+
default(session)
4434

4535

46-
@nox.session
36+
@nox.session(python='3.6')
4737
def lint_setup_py(session):
4838
"""Verify that setup.py is valid (including RST check)."""
49-
session.interpreter = 'python3.6'
5039
session.install('docutils', 'pygments')
5140
session.run('python', 'setup.py', 'check', '--restructuredtext',
5241
'--strict')

bigquery/nox.py renamed to bigquery/noxfile.py

Lines changed: 12 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
)
2626

2727

28-
@nox.session
2928
def default(session):
3029
"""Default unit test session.
3130
@@ -40,14 +39,14 @@ def default(session):
4039
session.install('-e', local_dep)
4140

4241
# Pyarrow does not support Python 3.7
43-
if session.interpreter == 'python3.7':
42+
if session.python == '3.7':
4443
dev_install = '.[pandas]'
4544
else:
4645
dev_install = '.[pandas, pyarrow]'
4746
session.install('-e', dev_install)
4847

4948
# IPython does not support Python 2 after version 5.x
50-
if session.interpreter == 'python2.7':
49+
if session.python == '2.7':
5150
session.install('ipython==5.5')
5251
else:
5352
session.install('ipython')
@@ -67,35 +66,20 @@ def default(session):
6766
)
6867

6968

70-
@nox.session
71-
@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7'])
72-
def unit(session, py):
69+
@nox.session(python=['2.7', '3.5', '3.6', '3.7'])
70+
def unit(session):
7371
"""Run the unit test suite."""
74-
75-
# Run unit tests against all supported versions of Python.
76-
session.interpreter = 'python{}'.format(py)
77-
78-
# Set the virtualenv dirname.
79-
session.virtualenv_dirname = 'unit-' + py
80-
8172
default(session)
8273

8374

84-
@nox.session
85-
@nox.parametrize('py', ['2.7', '3.6'])
86-
def system(session, py):
75+
@nox.session(python=['2.7', '3.6'])
76+
def system(session):
8777
"""Run the system test suite."""
8878

8979
# Sanity check: Only run system tests if the environment variable is set.
9080
if not os.environ.get('GOOGLE_APPLICATION_CREDENTIALS', ''):
9181
session.skip('Credentials must be set via environment variable.')
9282

93-
# Run the system tests against latest Python 2 and Python 3 only.
94-
session.interpreter = 'python{}'.format(py)
95-
96-
# Set the virtualenv dirname.
97-
session.virtualenv_dirname = 'sys-' + py
98-
9983
# Use pre-release gRPC for system tests.
10084
session.install('--pre', 'grpcio')
10185

@@ -108,7 +92,7 @@ def system(session, py):
10892
session.install('-e', '.[pandas]')
10993

11094
# IPython does not support Python 2 after version 5.x
111-
if session.interpreter == 'python2.7':
95+
if session.python == '2.7':
11296
session.install('ipython==5.5')
11397
else:
11498
session.install('ipython')
@@ -122,21 +106,14 @@ def system(session, py):
122106
)
123107

124108

125-
@nox.session
126-
@nox.parametrize('py', ['2.7', '3.6'])
127-
def snippets(session, py):
109+
@nox.session(python=['2.7', '3.6'])
110+
def snippets(session):
128111
"""Run the system test suite."""
129112

130113
# Sanity check: Only run system tests if the environment variable is set.
131114
if not os.environ.get('GOOGLE_APPLICATION_CREDENTIALS', ''):
132115
session.skip('Credentials must be set via environment variable.')
133116

134-
# Run the system tests against latest Python 2 and Python 3 only.
135-
session.interpreter = 'python{}'.format(py)
136-
137-
# Set the virtualenv dirname.
138-
session.virtualenv_dirname = 'snip-' + py
139-
140117
# Install all test dependencies, then install local packages in place.
141118
session.install('mock', 'pytest')
142119
for local_dep in LOCAL_DEPS:
@@ -150,14 +127,13 @@ def snippets(session, py):
150127
'py.test', os.path.join('docs', 'snippets.py'), *session.posargs)
151128

152129

153-
@nox.session
130+
@nox.session(python='3.6')
154131
def lint(session):
155132
"""Run linters.
156133
157134
Returns a failure if the linters find linting errors or sufficiently
158135
serious code quality issues.
159136
"""
160-
session.interpreter = 'python3.6'
161137

162138
session.install('flake8', *LOCAL_DEPS)
163139
session.install('.')
@@ -167,28 +143,22 @@ def lint(session):
167143
'flake8', os.path.join('docs', 'snippets.py'))
168144

169145

170-
@nox.session
146+
@nox.session(python='3.6')
171147
def lint_setup_py(session):
172148
"""Verify that setup.py is valid (including RST check)."""
173-
session.interpreter = 'python3.6'
174-
175-
# Set the virtualenv dirname.
176-
session.virtualenv_dirname = 'setup'
177149

178150
session.install('docutils', 'Pygments')
179151
session.run(
180152
'python', 'setup.py', 'check', '--restructuredtext', '--strict')
181153

182154

183-
@nox.session
155+
@nox.session(python='3.6')
184156
def cover(session):
185157
"""Run the final coverage report.
186158
187159
This outputs the coverage report aggregating coverage from the unit
188160
test runs (not system test runs), and then erases coverage data.
189161
"""
190-
session.interpreter = 'python3.6'
191-
192162
session.install('coverage', 'pytest-cov')
193163
session.run('coverage', 'report', '--show-missing', '--fail-under=100')
194164
session.run('coverage', 'erase')

0 commit comments

Comments
 (0)