3838 "unit" ,
3939 "unit_grpc_gcp" ,
4040 "unit_wo_grpc" ,
41- "unit_with_auth_aio" ,
41+ "unit_w_prerelease_deps" ,
42+ "unit_w_async_rest_extra" ,
4243 "cover" ,
4344 "pytype" ,
4445 "mypy" ,
@@ -110,7 +111,7 @@ def install_prerelease_dependencies(session, constraints_path):
110111 session .install (* other_deps )
111112
112113
113- def default (session , install_grpc = True , prerelease = False , install_auth_aio = False ):
114+ def default (session , install_grpc = True , prerelease = False , install_async_rest = False ):
114115 """Default unit test session.
115116
116117 This is intended to be run **without** an interpreter set, so
@@ -129,25 +130,38 @@ def default(session, install_grpc=True, prerelease=False, install_auth_aio=False
129130 "pytest-xdist" ,
130131 )
131132
133+ install_extras = []
134+ if install_grpc :
135+ install_extras .append ("grpc" )
136+
132137 constraints_dir = str (CURRENT_DIRECTORY / "testing" )
138+ if install_async_rest :
139+ install_extras .append ("async_rest" )
140+ constraints_type = "async-rest-"
141+ else :
142+ constraints_type = ""
133143
144+ lib_with_extras = f".[{ ',' .join (install_extras )} ]" if len (install_extras ) else "."
134145 if prerelease :
135146 install_prerelease_dependencies (
136- session , f"{ constraints_dir } /constraints-{ PYTHON_VERSIONS [0 ]} .txt"
147+ session ,
148+ f"{ constraints_dir } /constraints-{ constraints_type } { PYTHON_VERSIONS [0 ]} .txt" ,
137149 )
138150 # This *must* be the last install command to get the package from source.
139- session .install ("-e" , "." , "--no-deps" )
151+ session .install ("-e" , lib_with_extras , "--no-deps" )
140152 else :
141- session .install (
142- "-e" ,
143- ".[grpc]" if install_grpc else "." ,
144- "-c" ,
145- f"{ constraints_dir } /constraints-{ session .python } .txt" ,
153+ constraints_file = (
154+ f"{ constraints_dir } /constraints-{ constraints_type } { session .python } .txt"
146155 )
156+ # fall back to standard constraints file
157+ if not pathlib .Path (constraints_file ).exists ():
158+ constraints_file = f"{ constraints_dir } /constraints-{ session .python } .txt"
147159
148- if install_auth_aio :
149160 session .install (
150- "google-auth @ git+https://[email protected] /googleapis/google-auth-library-python@8833ad6f92c3300d6645355994c7db2356bd30ad" 161+ "-e" ,
162+ lib_with_extras ,
163+ "-c" ,
164+ constraints_file ,
151165 )
152166
153167 # Print out package versions of dependencies
@@ -205,7 +219,7 @@ def unit(session):
205219
206220
207221@nox .session (python = PYTHON_VERSIONS )
208- def unit_with_prerelease_deps (session ):
222+ def unit_w_prerelease_deps (session ):
209223 """Run the unit test suite."""
210224 default (session , prerelease = True )
211225
@@ -236,9 +250,9 @@ def unit_wo_grpc(session):
236250
237251
238252@nox .session (python = PYTHON_VERSIONS )
239- def unit_with_auth_aio (session ):
240- """Run the unit test suite with google.auth.aio installed """
241- default (session , install_auth_aio = True )
253+ def unit_w_async_rest_extra (session ):
254+ """Run the unit test suite with the `async_rest` extra """
255+ default (session , install_async_rest = True )
242256
243257
244258@nox .session (python = DEFAULT_PYTHON_VERSION )
@@ -261,7 +275,7 @@ def mypy(session):
261275 """Run type-checking."""
262276 # TODO(https://github.com/googleapis/python-api-core/issues/682):
263277 # Use the latest version of mypy instead of mypy<1.11.0
264- session .install (".[grpc]" , "mypy<1.11.0" )
278+ session .install (".[grpc,async_rest ]" , "mypy<1.11.0" )
265279 session .install (
266280 "types-setuptools" ,
267281 "types-requests" ,
0 commit comments