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