21
21
import pathlib
22
22
import re
23
23
import shutil
24
+ import warnings
24
25
25
26
import nox
26
27
27
-
28
28
BLACK_VERSION = "black==22.3.0"
29
29
BLACK_PATHS = ["docs" , "pandas_gbq" , "tests" , "noxfile.py" , "setup.py" ]
30
30
31
31
DEFAULT_PYTHON_VERSION = "3.8"
32
- SYSTEM_TEST_PYTHON_VERSIONS = [ "3.7" , "3.8" , "3.9" , "3.10" ]
32
+
33
33
UNIT_TEST_PYTHON_VERSIONS = ["3.7" , "3.8" , "3.9" , "3.10" ]
34
+ UNIT_TEST_STANDARD_DEPENDENCIES = [
35
+ "mock" ,
36
+ "asyncmock" ,
37
+ "pytest" ,
38
+ "pytest-cov" ,
39
+ "pytest-asyncio" ,
40
+ ]
41
+ UNIT_TEST_EXTERNAL_DEPENDENCIES = [
42
+ "freezegun" ,
43
+ ]
44
+ UNIT_TEST_LOCAL_DEPENDENCIES = []
45
+ UNIT_TEST_DEPENDENCIES = []
46
+ UNIT_TEST_EXTRAS = [
47
+ "tqdm" ,
48
+ ]
49
+ UNIT_TEST_EXTRAS_BY_PYTHON = {
50
+ "3.9" : [],
51
+ }
52
+
53
+ SYSTEM_TEST_PYTHON_VERSIONS = ["3.7" , "3.8" , "3.9" , "3.10" ]
54
+ SYSTEM_TEST_STANDARD_DEPENDENCIES = [
55
+ "mock" ,
56
+ "pytest" ,
57
+ "google-cloud-testutils" ,
58
+ ]
59
+ SYSTEM_TEST_EXTERNAL_DEPENDENCIES = []
60
+ SYSTEM_TEST_LOCAL_DEPENDENCIES = []
61
+ SYSTEM_TEST_DEPENDENCIES = []
62
+ SYSTEM_TEST_EXTRAS = [
63
+ "tqdm" ,
64
+ ]
65
+ SYSTEM_TEST_EXTRAS_BY_PYTHON = {}
34
66
35
67
CURRENT_DIRECTORY = pathlib .Path (__file__ ).parent .absolute ()
36
68
@@ -82,28 +114,41 @@ def lint_setup_py(session):
82
114
session .run ("python" , "setup.py" , "check" , "--restructuredtext" , "--strict" )
83
115
84
116
117
+ def install_unittest_dependencies (session , * constraints ):
118
+ standard_deps = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_DEPENDENCIES
119
+ session .install (* standard_deps , * constraints )
120
+
121
+ if UNIT_TEST_EXTERNAL_DEPENDENCIES :
122
+ warnings .warn (
123
+ "'unit_test_external_dependencies' is deprecated. Instead, please "
124
+ "use 'unit_test_dependencies' or 'unit_test_local_dependencies'." ,
125
+ DeprecationWarning ,
126
+ )
127
+ session .install (* UNIT_TEST_EXTERNAL_DEPENDENCIES , * constraints )
128
+
129
+ if UNIT_TEST_LOCAL_DEPENDENCIES :
130
+ session .install (* UNIT_TEST_LOCAL_DEPENDENCIES , * constraints )
131
+
132
+ if UNIT_TEST_EXTRAS_BY_PYTHON :
133
+ extras = UNIT_TEST_EXTRAS_BY_PYTHON .get (session .python , [])
134
+ elif UNIT_TEST_EXTRAS :
135
+ extras = UNIT_TEST_EXTRAS
136
+ else :
137
+ extras = []
138
+
139
+ if extras :
140
+ session .install ("-e" , f".[{ ',' .join (extras )} ]" , * constraints )
141
+ else :
142
+ session .install ("-e" , "." , * constraints )
143
+
144
+
85
145
def default (session ):
86
146
# Install all test dependencies, then install this package in-place.
87
147
88
148
constraints_path = str (
89
149
CURRENT_DIRECTORY / "testing" / f"constraints-{ session .python } .txt"
90
150
)
91
- session .install (
92
- "mock" ,
93
- "asyncmock" ,
94
- "pytest" ,
95
- "pytest-cov" ,
96
- "pytest-asyncio" ,
97
- "-c" ,
98
- constraints_path ,
99
- )
100
- session .install ("freezegun" , "-c" , constraints_path )
101
-
102
- if session .python == "3.9" :
103
- extras = ""
104
- else :
105
- extras = "[tqdm]"
106
- session .install ("-e" , f".{ extras } " , "-c" , constraints_path )
151
+ install_unittest_dependencies (session , "-c" , constraints_path )
107
152
108
153
# Run py.test against the unit tests.
109
154
session .run (
@@ -127,6 +172,35 @@ def unit(session):
127
172
default (session )
128
173
129
174
175
+ def install_systemtest_dependencies (session , * constraints ):
176
+
177
+ # Use pre-release gRPC for system tests.
178
+ session .install ("--pre" , "grpcio" )
179
+
180
+ session .install (* SYSTEM_TEST_STANDARD_DEPENDENCIES , * constraints )
181
+
182
+ if SYSTEM_TEST_EXTERNAL_DEPENDENCIES :
183
+ session .install (* SYSTEM_TEST_EXTERNAL_DEPENDENCIES , * constraints )
184
+
185
+ if SYSTEM_TEST_LOCAL_DEPENDENCIES :
186
+ session .install ("-e" , * SYSTEM_TEST_LOCAL_DEPENDENCIES , * constraints )
187
+
188
+ if SYSTEM_TEST_DEPENDENCIES :
189
+ session .install ("-e" , * SYSTEM_TEST_DEPENDENCIES , * constraints )
190
+
191
+ if SYSTEM_TEST_EXTRAS_BY_PYTHON :
192
+ extras = SYSTEM_TEST_EXTRAS_BY_PYTHON .get (session .python , [])
193
+ elif SYSTEM_TEST_EXTRAS :
194
+ extras = SYSTEM_TEST_EXTRAS
195
+ else :
196
+ extras = []
197
+
198
+ if extras :
199
+ session .install ("-e" , f".[{ ',' .join (extras )} ]" , * constraints )
200
+ else :
201
+ session .install ("-e" , "." , * constraints )
202
+
203
+
130
204
@nox .session (python = SYSTEM_TEST_PYTHON_VERSIONS )
131
205
def system (session ):
132
206
"""Run the system test suite."""
@@ -149,13 +223,7 @@ def system(session):
149
223
if not system_test_exists and not system_test_folder_exists :
150
224
session .skip ("System tests were not found" )
151
225
152
- # Use pre-release gRPC for system tests.
153
- session .install ("--pre" , "grpcio" )
154
-
155
- # Install all test dependencies, then install this package into the
156
- # virtualenv's dist-packages.
157
- session .install ("mock" , "pytest" , "google-cloud-testutils" , "-c" , constraints_path )
158
- session .install ("-e" , ".[tqdm]" , "-c" , constraints_path )
226
+ install_systemtest_dependencies (session , "-c" , constraints_path )
159
227
160
228
# Run py.test against the system tests.
161
229
if system_test_exists :
0 commit comments