18
18
19
19
from __future__ import absolute_import
20
20
import os
21
+ import pathlib
21
22
import shutil
22
23
23
24
import nox
30
31
SYSTEM_TEST_PYTHON_VERSIONS = ["3.8" ]
31
32
UNIT_TEST_PYTHON_VERSIONS = ["3.6" , "3.7" , "3.8" , "3.9" ]
32
33
34
+ CURRENT_DIRECTORY = pathlib .Path (__file__ ).parent .absolute ()
35
+
33
36
# 'docfx' is excluded since it only needs to run in 'docs-presubmit'
34
37
nox .options .sessions = [
35
38
"unit" ,
@@ -78,13 +81,14 @@ def lint_setup_py(session):
78
81
79
82
def default (session ):
80
83
# Install all test dependencies, then install this package in-place.
81
- session .install ("asyncmock" , "pytest-asyncio" )
82
-
83
- session .install (
84
- "mock" , "pytest" , "pytest-cov" ,
84
+ constraints_path = str (
85
+ CURRENT_DIRECTORY / "testing" / f"constraints-{ session .python } .txt"
85
86
)
87
+ session .install ("asyncmock" , "pytest-asyncio" , "-c" , constraints_path )
86
88
87
- session .install ("-e" , "." )
89
+ session .install ("mock" , "pytest" , "pytest-cov" , "-c" , constraints_path )
90
+
91
+ session .install ("-e" , "." , "-c" , constraints_path )
88
92
89
93
# Run py.test against the unit tests.
90
94
session .run (
@@ -136,6 +140,10 @@ def system_emulated(session):
136
140
@nox .session (python = SYSTEM_TEST_PYTHON_VERSIONS )
137
141
def system (session ):
138
142
"""Run the system test suite."""
143
+ constraints_path = str (
144
+ CURRENT_DIRECTORY / "testing" / f"constraints-{ session .python } .txt"
145
+ )
146
+
139
147
system_test_path = os .path .join ("tests" , "system.py" )
140
148
system_test_folder_path = os .path .join ("tests" , "system" )
141
149
@@ -147,7 +155,7 @@ def system(session):
147
155
session .skip ("Credentials must be set via environment variable" )
148
156
# Install pyopenssl for mTLS testing.
149
157
if os .environ .get ("GOOGLE_API_USE_CLIENT_CERTIFICATE" , "false" ) == "true" :
150
- session .install ("pyopenssl" )
158
+ session .install ("pyopenssl" , "-c" , constraints_path )
151
159
152
160
system_test_exists = os .path .exists (system_test_path )
153
161
system_test_folder_exists = os .path .exists (system_test_folder_path )
@@ -160,10 +168,8 @@ def system(session):
160
168
161
169
# Install all test dependencies, then install this package into the
162
170
# virtualenv's dist-packages.
163
- session .install (
164
- "mock" , "pytest" , "google-cloud-testutils" ,
165
- )
166
- session .install ("-e" , "." )
171
+ session .install ("mock" , "pytest" , "google-cloud-testutils" , "-c" , constraints_path )
172
+ session .install ("-e" , "." , "-c" , constraints_path )
167
173
168
174
# Run py.test against the system tests.
169
175
if system_test_exists :
0 commit comments