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