39
39
40
40
TEST_CONFIG = {
41
41
# You can opt out from the test for specific Python versions.
42
- "ignored_versions" : [],
42
+ 'ignored_versions' : [],
43
+
43
44
# Old samples are opted out of enforcing Python type hints
44
45
# All new samples should feature them
45
- "enforce_type_hints" : False ,
46
+ 'enforce_type_hints' : False ,
47
+
46
48
# An envvar key for determining the project id to use. Change it
47
49
# to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a
48
50
# build specific Cloud project. You can also use your own string
49
51
# to use your own Cloud project.
50
- " gcloud_project_env" : " GOOGLE_CLOUD_PROJECT" ,
52
+ ' gcloud_project_env' : ' GOOGLE_CLOUD_PROJECT' ,
51
53
# 'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT',
52
54
# If you need to use a specific version of pip,
53
55
# change pip_version_override to the string representation
54
56
# of the version number, for example, "20.2.4"
55
57
"pip_version_override" : None ,
56
58
# A dictionary you want to inject into your test. Don't put any
57
59
# secrets here. These values will override predefined values.
58
- " envs" : {},
60
+ ' envs' : {},
59
61
}
60
62
61
63
62
64
try :
63
65
# Ensure we can import noxfile_config in the project's directory.
64
- sys .path .append ("." )
66
+ sys .path .append ('.' )
65
67
from noxfile_config import TEST_CONFIG_OVERRIDE
66
68
except ImportError as e :
67
69
print ("No user noxfile_config found: detail: {}" .format (e ))
@@ -76,12 +78,12 @@ def get_pytest_env_vars() -> Dict[str, str]:
76
78
ret = {}
77
79
78
80
# Override the GCLOUD_PROJECT and the alias.
79
- env_key = TEST_CONFIG [" gcloud_project_env" ]
81
+ env_key = TEST_CONFIG [' gcloud_project_env' ]
80
82
# This should error out if not set.
81
- ret [" GOOGLE_CLOUD_PROJECT" ] = os .environ [env_key ]
83
+ ret [' GOOGLE_CLOUD_PROJECT' ] = os .environ [env_key ]
82
84
83
85
# Apply user supplied envs.
84
- ret .update (TEST_CONFIG [" envs" ])
86
+ ret .update (TEST_CONFIG [' envs' ])
85
87
return ret
86
88
87
89
@@ -90,14 +92,11 @@ def get_pytest_env_vars() -> Dict[str, str]:
90
92
ALL_VERSIONS = ["3.6" , "3.7" , "3.8" , "3.9" ]
91
93
92
94
# Any default versions that should be ignored.
93
- IGNORED_VERSIONS = TEST_CONFIG [" ignored_versions" ]
95
+ IGNORED_VERSIONS = TEST_CONFIG [' ignored_versions' ]
94
96
95
97
TESTED_VERSIONS = sorted ([v for v in ALL_VERSIONS if v not in IGNORED_VERSIONS ])
96
98
97
- INSTALL_LIBRARY_FROM_SOURCE = os .environ .get ("INSTALL_LIBRARY_FROM_SOURCE" , False ) in (
98
- "True" ,
99
- "true" ,
100
- )
99
+ INSTALL_LIBRARY_FROM_SOURCE = os .environ .get ("INSTALL_LIBRARY_FROM_SOURCE" , False ) in ("True" , "true" )
101
100
#
102
101
# Style Checks
103
102
#
@@ -142,7 +141,7 @@ def _determine_local_import_names(start_dir: str) -> List[str]:
142
141
143
142
@nox .session
144
143
def lint (session : nox .sessions .Session ) -> None :
145
- if not TEST_CONFIG [" enforce_type_hints" ]:
144
+ if not TEST_CONFIG [' enforce_type_hints' ]:
146
145
session .install ("flake8" , "flake8-import-order" )
147
146
else :
148
147
session .install ("flake8" , "flake8-import-order" , "flake8-annotations" )
@@ -151,11 +150,9 @@ def lint(session: nox.sessions.Session) -> None:
151
150
args = FLAKE8_COMMON_ARGS + [
152
151
"--application-import-names" ,
153
152
"," .join (local_names ),
154
- "." ,
153
+ "."
155
154
]
156
155
session .run ("flake8" , * args )
157
-
158
-
159
156
#
160
157
# Black
161
158
#
@@ -168,7 +165,6 @@ def blacken(session: nox.sessions.Session) -> None:
168
165
169
166
session .run ("black" , * python_files )
170
167
171
-
172
168
#
173
169
# Sample Tests
174
170
#
@@ -177,9 +173,7 @@ def blacken(session: nox.sessions.Session) -> None:
177
173
PYTEST_COMMON_ARGS = ["--junitxml=sponge_log.xml" ]
178
174
179
175
180
- def _session_tests (
181
- session : nox .sessions .Session , post_install : Callable = None
182
- ) -> None :
176
+ def _session_tests (session : nox .sessions .Session , post_install : Callable = None ) -> None :
183
177
if TEST_CONFIG ["pip_version_override" ]:
184
178
pip_version = TEST_CONFIG ["pip_version_override" ]
185
179
session .install (f"pip=={ pip_version } " )
@@ -209,7 +203,7 @@ def _session_tests(
209
203
# on travis where slow and flaky tests are excluded.
210
204
# See http://doc.pytest.org/en/latest/_modules/_pytest/main.html
211
205
success_codes = [0 , 5 ],
212
- env = get_pytest_env_vars (),
206
+ env = get_pytest_env_vars ()
213
207
)
214
208
215
209
@@ -219,9 +213,9 @@ def py(session: nox.sessions.Session) -> None:
219
213
if session .python in TESTED_VERSIONS :
220
214
_session_tests (session )
221
215
else :
222
- session .skip (
223
- "SKIPPED: {} tests are disabled for this sample." . format ( session .python )
224
- )
216
+ session .skip ("SKIPPED: {} tests are disabled for this sample." . format (
217
+ session .python
218
+ ))
225
219
226
220
227
221
#
0 commit comments