20
20
import nox
21
21
22
22
23
- LOCAL_DEPS = (
24
- os .path .join ('..' , 'api_core[grpc]' ),
25
- os .path .join ('..' , 'core' ),
26
- # TODO: Move bigquery_storage back to dev_install once dtypes feature is
27
- # released. Issue #7049
28
- os .path .join ('..' , 'bigquery_storage[pandas,fastavro]' ),
29
- )
23
+ LOCAL_DEPS = (os .path .join (".." , "api_core[grpc]" ), os .path .join (".." , "core" ))
24
+
25
+ DEFAULT_PYTHON = "3.6"
30
26
31
27
32
28
def default (session ):
@@ -38,169 +34,154 @@ def default(session):
38
34
run the tests.
39
35
"""
40
36
# Install all test dependencies, then install local packages in-place.
41
- session .install (' mock' , ' pytest' , ' pytest-cov' )
37
+ session .install (" mock" , " pytest" , " pytest-cov" )
42
38
for local_dep in LOCAL_DEPS :
43
- session .install ('-e' , local_dep )
39
+ session .install ("-e" , local_dep )
44
40
45
- # Pyarrow does not support Python 3.7
46
- if session .python == '3.7' :
47
- dev_install = '.[pandas]'
48
- else :
49
- dev_install = '.[pandas, pyarrow]'
50
- session .install ('-e' , dev_install )
41
+ session .install ("-e" , ".[all]" )
51
42
52
43
# IPython does not support Python 2 after version 5.x
53
- if session .python == ' 2.7' :
54
- session .install (' ipython==5.5' )
44
+ if session .python == " 2.7" :
45
+ session .install (" ipython==5.5" )
55
46
else :
56
- session .install (' ipython' )
47
+ session .install (" ipython" )
57
48
58
49
# Run py.test against the unit tests.
59
50
session .run (
60
- ' py.test' ,
61
- ' --quiet' ,
62
- ' --cov=google.cloud.bigquery' ,
63
- ' --cov=tests.unit' ,
64
- ' --cov-append' ,
65
- ' --cov-config=.coveragerc' ,
66
- ' --cov-report=' ,
67
- ' --cov-fail-under=97' ,
68
- os .path .join (' tests' , ' unit' ),
51
+ " py.test" ,
52
+ " --quiet" ,
53
+ " --cov=google.cloud.bigquery" ,
54
+ " --cov=tests.unit" ,
55
+ " --cov-append" ,
56
+ " --cov-config=.coveragerc" ,
57
+ " --cov-report=" ,
58
+ " --cov-fail-under=97" ,
59
+ os .path .join (" tests" , " unit" ),
69
60
* session .posargs
70
61
)
71
62
72
63
73
- @nox .session (python = [' 2.7' , ' 3.5' , ' 3.6' , ' 3.7' ])
64
+ @nox .session (python = [" 2.7" , " 3.5" , " 3.6" , " 3.7" ])
74
65
def unit (session ):
75
66
"""Run the unit test suite."""
76
67
default (session )
77
68
78
69
79
- @nox .session (python = [' 2.7' , '3.6' ])
70
+ @nox .session (python = [" 2.7" , DEFAULT_PYTHON ])
80
71
def system (session ):
81
72
"""Run the system test suite."""
82
73
83
74
# Sanity check: Only run system tests if the environment variable is set.
84
- if not os .environ .get (' GOOGLE_APPLICATION_CREDENTIALS' , '' ):
85
- session .skip (' Credentials must be set via environment variable.' )
75
+ if not os .environ .get (" GOOGLE_APPLICATION_CREDENTIALS" , "" ):
76
+ session .skip (" Credentials must be set via environment variable." )
86
77
87
78
# Use pre-release gRPC for system tests.
88
- session .install (' --pre' , ' grpcio' )
79
+ session .install (" --pre" , " grpcio" )
89
80
90
81
# Install all test dependencies, then install local packages in place.
91
- session .install (' mock' , ' pytest' )
82
+ session .install (" mock" , " pytest" )
92
83
for local_dep in LOCAL_DEPS :
93
- session .install ('-e' , local_dep )
94
- session .install ('-e' , os .path .join ('..' , ' storage' ))
95
- session .install ('-e' , os .path .join ('..' , ' test_utils' ))
96
- session .install ('-e' , '.[pandas]' )
84
+ session .install ("-e" , local_dep )
85
+ session .install ("-e" , os .path .join (".." , " storage" ))
86
+ session .install ("-e" , os .path .join (".." , " test_utils" ))
87
+ session .install ("-e" , ".[all]" )
97
88
98
89
# IPython does not support Python 2 after version 5.x
99
- if session .python == ' 2.7' :
100
- session .install (' ipython==5.5' )
90
+ if session .python == " 2.7" :
91
+ session .install (" ipython==5.5" )
101
92
else :
102
- session .install (' ipython' )
93
+ session .install (" ipython" )
103
94
104
95
# Run py.test against the system tests.
105
96
session .run (
106
- 'py.test' ,
107
- '--quiet' ,
108
- os .path .join ('tests' , 'system.py' ),
109
- * session .posargs
97
+ "py.test" , "--quiet" , os .path .join ("tests" , "system.py" ), * session .posargs
110
98
)
111
99
112
100
113
- @nox .session (python = [' 2.7' , '3.6' ])
101
+ @nox .session (python = [" 2.7" , DEFAULT_PYTHON ])
114
102
def snippets (session ):
115
103
"""Run the snippets test suite."""
116
104
117
105
# Sanity check: Only run snippets tests if the environment variable is set.
118
- if not os .environ .get (' GOOGLE_APPLICATION_CREDENTIALS' , '' ):
119
- session .skip (' Credentials must be set via environment variable.' )
106
+ if not os .environ .get (" GOOGLE_APPLICATION_CREDENTIALS" , "" ):
107
+ session .skip (" Credentials must be set via environment variable." )
120
108
121
109
# Install all test dependencies, then install local packages in place.
122
- session .install (' mock' , ' pytest' )
110
+ session .install (" mock" , " pytest" )
123
111
for local_dep in LOCAL_DEPS :
124
- session .install ('-e' , local_dep )
125
- session .install ('-e' , os .path .join ('..' , ' storage' ))
126
- session .install ('-e' , os .path .join ('..' , ' test_utils' ))
127
- session .install ('-e' , '.[pandas, pyarrow, fastparquet]' )
112
+ session .install ("-e" , local_dep )
113
+ session .install ("-e" , os .path .join (".." , " storage" ))
114
+ session .install ("-e" , os .path .join (".." , " test_utils" ))
115
+ session .install ("-e" , ".[all]" )
128
116
129
117
# Run py.test against the snippets tests.
130
- session .run (
131
- 'py.test' , os .path .join ('docs' , 'snippets.py' ), * session .posargs )
118
+ session .run ("py.test" , os .path .join ("docs" , "snippets.py" ), * session .posargs )
132
119
133
120
134
- @nox .session (python = '3.6' )
121
+ @nox .session (python = DEFAULT_PYTHON )
135
122
def cover (session ):
136
123
"""Run the final coverage report.
137
124
138
125
This outputs the coverage report aggregating coverage from the unit
139
126
test runs (not system test runs), and then erases coverage data.
140
127
"""
141
- session .install (' coverage' , ' pytest-cov' )
142
- session .run (' coverage' , ' report' , ' --show-missing' , ' --fail-under=100' )
143
- session .run (' coverage' , ' erase' )
128
+ session .install (" coverage" , " pytest-cov" )
129
+ session .run (" coverage" , " report" , " --show-missing" , " --fail-under=100" )
130
+ session .run (" coverage" , " erase" )
144
131
145
132
146
- @nox .session (python = '3.6' )
133
+ @nox .session (python = DEFAULT_PYTHON )
147
134
def lint (session ):
148
135
"""Run linters.
149
136
150
137
Returns a failure if the linters find linting errors or sufficiently
151
138
serious code quality issues.
152
139
"""
153
140
154
- session .install ('flake8' , * LOCAL_DEPS )
155
- session .install ('.' )
156
- session .run ('flake8' , os .path .join ('google' , 'cloud' , 'bigquery' ))
157
- session .run ('flake8' , 'tests' )
158
- session .run (
159
- 'flake8' , os .path .join ('docs' , 'snippets.py' ))
141
+ session .install ("flake8" , * LOCAL_DEPS )
142
+ session .install ("." )
143
+ session .run ("flake8" , os .path .join ("google" , "cloud" , "bigquery" ))
144
+ session .run ("flake8" , "tests" )
145
+ session .run ("flake8" , os .path .join ("docs" , "snippets.py" ))
160
146
161
147
162
- @nox .session (python = '3.6' )
148
+ @nox .session (python = DEFAULT_PYTHON )
163
149
def lint_setup_py (session ):
164
150
"""Verify that setup.py is valid (including RST check)."""
165
151
166
- session .install ('docutils' , 'Pygments' )
167
- session .run (
168
- 'python' , 'setup.py' , 'check' , '--restructuredtext' , '--strict' )
169
-
152
+ session .install ("docutils" , "Pygments" )
153
+ session .run ("python" , "setup.py" , "check" , "--restructuredtext" , "--strict" )
170
154
171
155
172
- @nox .session (python = "3.6" )
156
+ @nox .session (python = DEFAULT_PYTHON )
173
157
def blacken (session ):
174
158
"""Run black.
175
159
Format code to uniform standard.
176
160
"""
177
161
session .install ("black" )
178
- session .run (
179
- "black" ,
180
- "google" ,
181
- "tests" ,
182
- "docs" ,
183
- )
162
+ session .run ("black" , "google" , "tests" , "docs" )
184
163
185
164
186
- @nox .session (python = '3.6' )
165
+ @nox .session (python = DEFAULT_PYTHON )
187
166
def docs (session ):
188
167
"""Build the docs."""
189
168
190
- session .install (' ipython' , ' recommonmark' , ' sphinx' , ' sphinx_rtd_theme' )
169
+ session .install (" ipython" , " recommonmark" , " sphinx" , " sphinx_rtd_theme" )
191
170
for local_dep in LOCAL_DEPS :
192
- session .install ('-e' , local_dep )
193
- session .install ('-e' , os .path .join ('..' , ' storage' ))
194
- session .install ('-e' , '.[pandas, pyarrow]' )
171
+ session .install ("-e" , local_dep )
172
+ session .install ("-e" , os .path .join (".." , " storage" ))
173
+ session .install ("-e" , ".[all]" )
195
174
196
- shutil .rmtree (os .path .join (' docs' , ' _build' ), ignore_errors = True )
175
+ shutil .rmtree (os .path .join (" docs" , " _build" ), ignore_errors = True )
197
176
session .run (
198
- 'sphinx-build' ,
199
- '-W' , # warnings as errors
200
- '-T' , # show full traceback on exception
201
- '-N' , # no colors
202
- '-b' , 'html' ,
203
- '-d' , os .path .join ('docs' , '_build' , 'doctrees' , '' ),
204
- os .path .join ('docs' , '' ),
205
- os .path .join ('docs' , '_build' , 'html' , '' ),
177
+ "sphinx-build" ,
178
+ "-W" , # warnings as errors
179
+ "-T" , # show full traceback on exception
180
+ "-N" , # no colors
181
+ "-b" ,
182
+ "html" ,
183
+ "-d" ,
184
+ os .path .join ("docs" , "_build" , "doctrees" , "" ),
185
+ os .path .join ("docs" , "" ),
186
+ os .path .join ("docs" , "_build" , "html" , "" ),
206
187
)
0 commit comments