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" , "db_dtypes" , "tests" , "noxfile.py" , "setup.py" ]
30
30
31
31
DEFAULT_PYTHON_VERSION = "3.8"
32
- SYSTEM_TEST_PYTHON_VERSIONS = [ "3.8" ]
32
+
33
33
UNIT_TEST_PYTHON_VERSIONS = ["3.6" , "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
+ UNIT_TEST_LOCAL_DEPENDENCIES = []
43
+ UNIT_TEST_DEPENDENCIES = []
44
+ UNIT_TEST_EXTRAS = []
45
+ UNIT_TEST_EXTRAS_BY_PYTHON = {}
46
+
47
+ SYSTEM_TEST_PYTHON_VERSIONS = ["3.8" ]
48
+ SYSTEM_TEST_STANDARD_DEPENDENCIES = [
49
+ "mock" ,
50
+ "pytest" ,
51
+ "google-cloud-testutils" ,
52
+ ]
53
+ SYSTEM_TEST_EXTERNAL_DEPENDENCIES = []
54
+ SYSTEM_TEST_LOCAL_DEPENDENCIES = []
55
+ SYSTEM_TEST_DEPENDENCIES = []
56
+ SYSTEM_TEST_EXTRAS = []
57
+ SYSTEM_TEST_EXTRAS_BY_PYTHON = {}
34
58
35
59
CURRENT_DIRECTORY = pathlib .Path (__file__ ).parent .absolute ()
36
60
@@ -84,23 +108,41 @@ def lint_setup_py(session):
84
108
session .run ("python" , "setup.py" , "check" , "--restructuredtext" , "--strict" )
85
109
86
110
111
+ def install_unittest_dependencies (session , * constraints ):
112
+ standard_deps = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_DEPENDENCIES
113
+ session .install (* standard_deps , * constraints )
114
+
115
+ if UNIT_TEST_EXTERNAL_DEPENDENCIES :
116
+ warnings .warn (
117
+ "'unit_test_external_dependencies' is deprecated. Instead, please "
118
+ "use 'unit_test_dependencies' or 'unit_test_local_dependencies'." ,
119
+ DeprecationWarning ,
120
+ )
121
+ session .install (* UNIT_TEST_EXTERNAL_DEPENDENCIES , * constraints )
122
+
123
+ if UNIT_TEST_LOCAL_DEPENDENCIES :
124
+ session .install (* UNIT_TEST_LOCAL_DEPENDENCIES , * constraints )
125
+
126
+ if UNIT_TEST_EXTRAS_BY_PYTHON :
127
+ extras = UNIT_TEST_EXTRAS_BY_PYTHON .get (session .python , [])
128
+ elif UNIT_TEST_EXTRAS :
129
+ extras = UNIT_TEST_EXTRAS
130
+ else :
131
+ extras = []
132
+
133
+ if extras :
134
+ session .install ("-e" , f".[{ ',' .join (extras )} ]" , * constraints )
135
+ else :
136
+ session .install ("-e" , "." , * constraints )
137
+
138
+
87
139
def default (session , tests_path ):
88
140
# Install all test dependencies, then install this package in-place.
89
141
90
142
constraints_path = str (
91
143
CURRENT_DIRECTORY / "testing" / f"constraints-{ session .python } .txt"
92
144
)
93
- session .install (
94
- "mock" ,
95
- "asyncmock" ,
96
- "pytest" ,
97
- "pytest-cov" ,
98
- "pytest-asyncio" ,
99
- "-c" ,
100
- constraints_path ,
101
- )
102
-
103
- session .install ("-e" , "." , "-c" , constraints_path )
145
+ install_unittest_dependencies (session , "-c" , constraints_path )
104
146
105
147
# Run py.test against the unit tests.
106
148
session .run (
@@ -218,6 +260,35 @@ def unit_prerelease(session):
218
260
prerelease (session , os .path .join ("tests" , "unit" ))
219
261
220
262
263
+ def install_systemtest_dependencies (session , * constraints ):
264
+
265
+ # Use pre-release gRPC for system tests.
266
+ session .install ("--pre" , "grpcio" )
267
+
268
+ session .install (* SYSTEM_TEST_STANDARD_DEPENDENCIES , * constraints )
269
+
270
+ if SYSTEM_TEST_EXTERNAL_DEPENDENCIES :
271
+ session .install (* SYSTEM_TEST_EXTERNAL_DEPENDENCIES , * constraints )
272
+
273
+ if SYSTEM_TEST_LOCAL_DEPENDENCIES :
274
+ session .install ("-e" , * SYSTEM_TEST_LOCAL_DEPENDENCIES , * constraints )
275
+
276
+ if SYSTEM_TEST_DEPENDENCIES :
277
+ session .install ("-e" , * SYSTEM_TEST_DEPENDENCIES , * constraints )
278
+
279
+ if SYSTEM_TEST_EXTRAS_BY_PYTHON :
280
+ extras = SYSTEM_TEST_EXTRAS_BY_PYTHON .get (session .python , [])
281
+ elif SYSTEM_TEST_EXTRAS :
282
+ extras = SYSTEM_TEST_EXTRAS
283
+ else :
284
+ extras = []
285
+
286
+ if extras :
287
+ session .install ("-e" , f".[{ ',' .join (extras )} ]" , * constraints )
288
+ else :
289
+ session .install ("-e" , "." , * constraints )
290
+
291
+
221
292
@nox .session (python = SYSTEM_TEST_PYTHON_VERSIONS )
222
293
def system (session ):
223
294
"""Run the system test suite."""
@@ -240,13 +311,7 @@ def system(session):
240
311
if not system_test_exists and not system_test_folder_exists :
241
312
session .skip ("System tests were not found" )
242
313
243
- # Use pre-release gRPC for system tests.
244
- session .install ("--pre" , "grpcio" )
245
-
246
- # Install all test dependencies, then install this package into the
247
- # virtualenv's dist-packages.
248
- session .install ("mock" , "pytest" , "google-cloud-testutils" , "-c" , constraints_path )
249
- session .install ("-e" , "." , "-c" , constraints_path )
314
+ install_systemtest_dependencies (session , "-c" , constraints_path )
250
315
251
316
# Run py.test against the system tests.
252
317
if system_test_exists :
0 commit comments