1818
1919from __future__ import absolute_import
2020import os
21+ import pathlib
2122import shutil
2223
2324import nox
3031SYSTEM_TEST_PYTHON_VERSIONS = ["3.8" ]
3132UNIT_TEST_PYTHON_VERSIONS = ["3.6" , "3.7" , "3.8" , "3.9" ]
3233
34+ CURRENT_DIRECTORY = pathlib .Path (__file__ ).parent .absolute ()
35+
3336# 'docfx' is excluded since it only needs to run in 'docs-presubmit'
3437nox .options .sessions = [
3538 "unit" ,
@@ -78,13 +81,14 @@ def lint_setup_py(session):
7881
7982def default (session ):
8083 # 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"
8586 )
87+ session .install ("asyncmock" , "pytest-asyncio" , "-c" , constraints_path )
8688
87- session .install ("-e" , "." )
89+ session .install ("mock" , "pytest" , "pytest-cov" , "-c" , constraints_path )
90+
91+ session .install ("-e" , "." , "-c" , constraints_path )
8892
8993 # Run py.test against the unit tests.
9094 session .run (
@@ -136,6 +140,10 @@ def system_emulated(session):
136140@nox .session (python = SYSTEM_TEST_PYTHON_VERSIONS )
137141def system (session ):
138142 """Run the system test suite."""
143+ constraints_path = str (
144+ CURRENT_DIRECTORY / "testing" / f"constraints-{ session .python } .txt"
145+ )
146+
139147 system_test_path = os .path .join ("tests" , "system.py" )
140148 system_test_folder_path = os .path .join ("tests" , "system" )
141149
@@ -147,7 +155,7 @@ def system(session):
147155 session .skip ("Credentials must be set via environment variable" )
148156 # Install pyopenssl for mTLS testing.
149157 if os .environ .get ("GOOGLE_API_USE_CLIENT_CERTIFICATE" , "false" ) == "true" :
150- session .install ("pyopenssl" )
158+ session .install ("pyopenssl" , "-c" , constraints_path )
151159
152160 system_test_exists = os .path .exists (system_test_path )
153161 system_test_folder_exists = os .path .exists (system_test_folder_path )
@@ -160,10 +168,8 @@ def system(session):
160168
161169 # Install all test dependencies, then install this package into the
162170 # 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 )
167173
168174 # Run py.test against the system tests.
169175 if system_test_exists :
0 commit comments