1- # Copyright (c) 2017 pandas-gbq Authors All rights reserved.
2- # Use of this source code is governed by a BSD-style
3- # license that can be found in the LICENSE file.
4-
5- """Nox test automation configuration.
6-
7- See: https://nox.readthedocs.io/en/latest/
8- """
9-
1+ # -*- coding: utf-8 -*-
2+ #
3+ # Copyright 2018 Google LLC
4+ #
5+ # Licensed under the Apache License, Version 2.0 (the "License");
6+ # you may not use this file except in compliance with the License.
7+ # You may obtain a copy of the License at
8+ #
9+ # https://www.apache.org/licenses/LICENSE-2.0
10+ #
11+ # Unless required by applicable law or agreed to in writing, software
12+ # distributed under the License is distributed on an "AS IS" BASIS,
13+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+ # See the License for the specific language governing permissions and
15+ # limitations under the License.
16+
17+ # Generated by synthtool. DO NOT EDIT!
18+
19+ from __future__ import absolute_import
1020import os
11- import os . path
21+ import pathlib
1222import shutil
1323
1424import nox
1828BLACK_PATHS = ["docs" , "pandas_gbq" , "tests" , "noxfile.py" , "setup.py" ]
1929
2030DEFAULT_PYTHON_VERSION = "3.8"
21- SYSTEM_TEST_PYTHON_VERSIONS = ["3.8" ]
31+ SYSTEM_TEST_PYTHON_VERSIONS = ["3.8" , "3.9" ]
2232UNIT_TEST_PYTHON_VERSIONS = ["3.7" , "3.8" , "3.9" ]
2333
34+ CURRENT_DIRECTORY = pathlib .Path (__file__ ).parent .absolute ()
35+
36+ # 'docfx' is excluded since it only needs to run in 'docs-presubmit'
37+ nox .options .sessions = [
38+ "unit" ,
39+ "system" ,
40+ "cover" ,
41+ "lint" ,
42+ "lint_setup_py" ,
43+ "blacken" ,
44+ "docs" ,
45+ ]
2446
2547# Error if a python version is missing
2648nox .options .error_on_missing_interpreters = True
2951@nox .session (python = DEFAULT_PYTHON_VERSION )
3052def lint (session ):
3153 """Run linters.
54+
3255 Returns a failure if the linters find linting errors or sufficiently
3356 serious code quality issues.
3457 """
@@ -55,32 +78,99 @@ def lint_setup_py(session):
5578 session .run ("python" , "setup.py" , "check" , "--restructuredtext" , "--strict" )
5679
5780
58- @nox .session (python = UNIT_TEST_PYTHON_VERSIONS )
59- def unit (session ):
60- session .install ("pytest" , "pytest-cov" )
81+ def default (session ):
82+ # Install all test dependencies, then install this package in-place.
83+
84+ constraints_path = str (
85+ CURRENT_DIRECTORY / "testing" / f"constraints-{ session .python } .txt"
86+ )
6187 session .install (
62- "-e" ,
63- "." ,
64- # Use dependencies versions from constraints file. This enables testing
65- # across a more full range of versions of the dependencies.
88+ "mock" ,
89+ "asyncmock" ,
90+ "pytest" ,
91+ "pytest-cov" ,
92+ "pytest-asyncio" ,
6693 "-c" ,
67- os . path . join ( "." , "ci" , "constraints-{}.pip" . format ( session . python )) ,
94+ constraints_path ,
6895 )
96+
97+ session .install ("-e" , ".[tqdm]" , "-c" , constraints_path )
98+
99+ # Run py.test against the unit tests.
69100 session .run (
70- "pytest " ,
71- os . path . join ( "." , "tests" , "unit" ) ,
72- "-v " ,
101+ "py.test " ,
102+ "--quiet" ,
103+ f"--junitxml=unit_ { session . python } _sponge_log.xml " ,
73104 "--cov=pandas_gbq" ,
74- "--cov=tests.unit" ,
75- "--cov-report" ,
76- "xml:/tmp/pytest-cov.xml" ,
105+ "--cov=tests/unit" ,
106+ "--cov-append" ,
107+ "--cov-config=.coveragerc" ,
108+ "--cov-report=" ,
109+ "--cov-fail-under=0" ,
110+ os .path .join ("tests" , "unit" ),
77111 * session .posargs ,
78112 )
79113
80114
115+ @nox .session (python = UNIT_TEST_PYTHON_VERSIONS )
116+ def unit (session ):
117+ """Run the unit test suite."""
118+ default (session )
119+
120+
121+ @nox .session (python = SYSTEM_TEST_PYTHON_VERSIONS )
122+ def system (session ):
123+ """Run the system test suite."""
124+ constraints_path = str (
125+ CURRENT_DIRECTORY / "testing" / f"constraints-{ session .python } .txt"
126+ )
127+ system_test_path = os .path .join ("tests" , "system.py" )
128+ system_test_folder_path = os .path .join ("tests" , "system" )
129+
130+ # Check the value of `RUN_SYSTEM_TESTS` env var. It defaults to true.
131+ if os .environ .get ("RUN_SYSTEM_TESTS" , "true" ) == "false" :
132+ session .skip ("RUN_SYSTEM_TESTS is set to false, skipping" )
133+ # Install pyopenssl for mTLS testing.
134+ if os .environ .get ("GOOGLE_API_USE_CLIENT_CERTIFICATE" , "false" ) == "true" :
135+ session .install ("pyopenssl" )
136+
137+ system_test_exists = os .path .exists (system_test_path )
138+ system_test_folder_exists = os .path .exists (system_test_folder_path )
139+ # Sanity check: only run tests if found.
140+ if not system_test_exists and not system_test_folder_exists :
141+ session .skip ("System tests were not found" )
142+
143+ # Use pre-release gRPC for system tests.
144+ session .install ("--pre" , "grpcio" )
145+
146+ # Install all test dependencies, then install this package into the
147+ # virtualenv's dist-packages.
148+ session .install ("mock" , "pytest" , "google-cloud-testutils" , "-c" , constraints_path )
149+ session .install ("-e" , ".[tqdm]" , "-c" , constraints_path )
150+
151+ # Run py.test against the system tests.
152+ if system_test_exists :
153+ session .run (
154+ "py.test" ,
155+ "--quiet" ,
156+ f"--junitxml=system_{ session .python } _sponge_log.xml" ,
157+ system_test_path ,
158+ * session .posargs ,
159+ )
160+ if system_test_folder_exists :
161+ session .run (
162+ "py.test" ,
163+ "--quiet" ,
164+ f"--junitxml=system_{ session .python } _sponge_log.xml" ,
165+ system_test_folder_path ,
166+ * session .posargs ,
167+ )
168+
169+
81170@nox .session (python = DEFAULT_PYTHON_VERSION )
82171def cover (session ):
83172 """Run the final coverage report.
173+
84174 This outputs the coverage report aggregating coverage from the unit
85175 test runs (not system test runs), and then erases coverage data.
86176 """
@@ -112,27 +202,36 @@ def docs(session):
112202 )
113203
114204
115- @nox .session (python = SYSTEM_TEST_PYTHON_VERSIONS )
116- def system (session ):
117- session .install ("pytest" , "pytest-cov" )
205+ @nox .session (python = DEFAULT_PYTHON_VERSION )
206+ def docfx (session ):
207+ """Build the docfx yaml files for this library."""
208+
209+ session .install ("-e" , "." )
118210 session .install (
119- "-e" ,
120- "." ,
121- # Use dependencies versions from constraints file. This enables testing
122- # across a more full range of versions of the dependencies.
123- "-c" ,
124- os .path .join ("." , "ci" , "constraints-{}.pip" .format (session .python )),
211+ "sphinx==4.0.1" , "alabaster" , "recommonmark" , "gcp-sphinx-docfx-yaml"
125212 )
126213
127- # Skip local auth tests on CI.
128- additional_args = list (session .posargs )
129- if "CIRCLECI" in os .environ :
130- additional_args = additional_args + ["-m" , "not local_auth" ]
131-
214+ shutil .rmtree (os .path .join ("docs" , "_build" ), ignore_errors = True )
132215 session .run (
133- "pytest" ,
134- os .path .join ("." , "tests" , "system" ),
135- os .path .join ("." , "samples" , "snippets" ),
136- "-v" ,
137- * additional_args ,
216+ "sphinx-build" ,
217+ "-T" , # show full traceback on exception
218+ "-N" , # no colors
219+ "-D" ,
220+ (
221+ "extensions=sphinx.ext.autodoc,"
222+ "sphinx.ext.autosummary,"
223+ "docfx_yaml.extension,"
224+ "sphinx.ext.intersphinx,"
225+ "sphinx.ext.coverage,"
226+ "sphinx.ext.napoleon,"
227+ "sphinx.ext.todo,"
228+ "sphinx.ext.viewcode,"
229+ "recommonmark"
230+ ),
231+ "-b" ,
232+ "html" ,
233+ "-d" ,
234+ os .path .join ("docs" , "_build" , "doctrees" , "" ),
235+ os .path .join ("docs" , "" ),
236+ os .path .join ("docs" , "_build" , "html" , "" ),
138237 )
0 commit comments