28
28
# WARNING - WARNING - WARNING - WARNING - WARNING
29
29
# WARNING - WARNING - WARNING - WARNING - WARNING
30
30
31
- # Copy `noxfile_config.py` to your directory and modify it instead.
31
+ BLACK_VERSION = "black==19.10b0"
32
32
33
+ # Copy `noxfile_config.py` to your directory and modify it instead.
33
34
34
35
# `TEST_CONFIG` dict is a configuration hook that allows users to
35
36
# modify the test configurations. The values here should be in sync
38
39
39
40
TEST_CONFIG = {
40
41
# You can opt out from the test for specific Python versions.
41
- 'ignored_versions' : ["2.7" ],
42
+ 'ignored_versions' : [],
42
43
43
44
# Old samples are opted out of enforcing Python type hints
44
45
# All new samples should feature them
50
51
# to use your own Cloud project.
51
52
'gcloud_project_env' : 'GOOGLE_CLOUD_PROJECT' ,
52
53
# 'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT',
53
-
54
+ # If you need to use a specific version of pip,
55
+ # change pip_version_override to the string representation
56
+ # of the version number, for example, "20.2.4"
57
+ "pip_version_override" : None ,
54
58
# A dictionary you want to inject into your test. Don't put any
55
59
# secrets here. These values will override predefined values.
56
60
'envs' : {},
@@ -84,15 +88,15 @@ def get_pytest_env_vars() -> Dict[str, str]:
84
88
85
89
86
90
# DO NOT EDIT - automatically generated.
87
- # All versions used to tested samples.
88
- ALL_VERSIONS = ["2.7" , " 3.6" , "3.7" , "3.8" , "3.9" ]
91
+ # All versions used to test samples.
92
+ ALL_VERSIONS = ["3.6" , "3.7" , "3.8" , "3.9" ]
89
93
90
94
# Any default versions that should be ignored.
91
95
IGNORED_VERSIONS = TEST_CONFIG ['ignored_versions' ]
92
96
93
97
TESTED_VERSIONS = sorted ([v for v in ALL_VERSIONS if v not in IGNORED_VERSIONS ])
94
98
95
- INSTALL_LIBRARY_FROM_SOURCE = bool ( os .environ .get ("INSTALL_LIBRARY_FROM_SOURCE" , False ))
99
+ INSTALL_LIBRARY_FROM_SOURCE = os .environ .get ("INSTALL_LIBRARY_FROM_SOURCE" , False ) in ( "True" , "true" )
96
100
#
97
101
# Style Checks
98
102
#
@@ -156,7 +160,7 @@ def lint(session: nox.sessions.Session) -> None:
156
160
157
161
@nox .session
158
162
def blacken (session : nox .sessions .Session ) -> None :
159
- session .install ("black" )
163
+ session .install (BLACK_VERSION )
160
164
python_files = [path for path in os .listdir ("." ) if path .endswith (".py" )]
161
165
162
166
session .run ("black" , * python_files )
@@ -170,12 +174,21 @@ def blacken(session: nox.sessions.Session) -> None:
170
174
171
175
172
176
def _session_tests (session : nox .sessions .Session , post_install : Callable = None ) -> None :
177
+ if TEST_CONFIG ["pip_version_override" ]:
178
+ pip_version = TEST_CONFIG ["pip_version_override" ]
179
+ session .install (f"pip=={ pip_version } " )
173
180
"""Runs py.test for a particular project."""
174
181
if os .path .exists ("requirements.txt" ):
175
- session .install ("-r" , "requirements.txt" )
182
+ if os .path .exists ("constraints.txt" ):
183
+ session .install ("-r" , "requirements.txt" , "-c" , "constraints.txt" )
184
+ else :
185
+ session .install ("-r" , "requirements.txt" )
176
186
177
187
if os .path .exists ("requirements-test.txt" ):
178
- session .install ("-r" , "requirements-test.txt" )
188
+ if os .path .exists ("constraints-test.txt" ):
189
+ session .install ("-r" , "requirements-test.txt" , "-c" , "constraints-test.txt" )
190
+ else :
191
+ session .install ("-r" , "requirements-test.txt" )
179
192
180
193
if INSTALL_LIBRARY_FROM_SOURCE :
181
194
session .install ("-e" , _get_repo_root ())
0 commit comments