3939
4040TEST_CONFIG = {
4141 # You can opt out from the test for specific Python versions.
42- "ignored_versions" : [],
42+ 'ignored_versions' : [],
43+
4344 # Old samples are opted out of enforcing Python type hints
4445 # All new samples should feature them
45- "enforce_type_hints" : False ,
46+ 'enforce_type_hints' : False ,
47+
4648 # An envvar key for determining the project id to use. Change it
4749 # to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a
4850 # build specific Cloud project. You can also use your own string
4951 # to use your own Cloud project.
50- " gcloud_project_env" : " GOOGLE_CLOUD_PROJECT" ,
52+ ' gcloud_project_env' : ' GOOGLE_CLOUD_PROJECT' ,
5153 # 'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT',
5254 # If you need to use a specific version of pip,
5355 # change pip_version_override to the string representation
5456 # of the version number, for example, "20.2.4"
5557 "pip_version_override" : None ,
5658 # A dictionary you want to inject into your test. Don't put any
5759 # secrets here. These values will override predefined values.
58- " envs" : {},
60+ ' envs' : {},
5961}
6062
6163
6264try :
6365 # Ensure we can import noxfile_config in the project's directory.
64- sys .path .append ("." )
66+ sys .path .append ('.' )
6567 from noxfile_config import TEST_CONFIG_OVERRIDE
6668except ImportError as e :
6769 print ("No user noxfile_config found: detail: {}" .format (e ))
@@ -76,12 +78,12 @@ def get_pytest_env_vars() -> Dict[str, str]:
7678 ret = {}
7779
7880 # Override the GCLOUD_PROJECT and the alias.
79- env_key = TEST_CONFIG [" gcloud_project_env" ]
81+ env_key = TEST_CONFIG [' gcloud_project_env' ]
8082 # 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 ]
8284
8385 # Apply user supplied envs.
84- ret .update (TEST_CONFIG [" envs" ])
86+ ret .update (TEST_CONFIG [' envs' ])
8587 return ret
8688
8789
@@ -90,14 +92,11 @@ def get_pytest_env_vars() -> Dict[str, str]:
9092ALL_VERSIONS = ["3.6" , "3.7" , "3.8" , "3.9" ]
9193
9294# Any default versions that should be ignored.
93- IGNORED_VERSIONS = TEST_CONFIG [" ignored_versions" ]
95+ IGNORED_VERSIONS = TEST_CONFIG [' ignored_versions' ]
9496
9597TESTED_VERSIONS = sorted ([v for v in ALL_VERSIONS if v not in IGNORED_VERSIONS ])
9698
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" )
101100#
102101# Style Checks
103102#
@@ -142,7 +141,7 @@ def _determine_local_import_names(start_dir: str) -> List[str]:
142141
143142@nox .session
144143def lint (session : nox .sessions .Session ) -> None :
145- if not TEST_CONFIG [" enforce_type_hints" ]:
144+ if not TEST_CONFIG [' enforce_type_hints' ]:
146145 session .install ("flake8" , "flake8-import-order" )
147146 else :
148147 session .install ("flake8" , "flake8-import-order" , "flake8-annotations" )
@@ -151,11 +150,9 @@ def lint(session: nox.sessions.Session) -> None:
151150 args = FLAKE8_COMMON_ARGS + [
152151 "--application-import-names" ,
153152 "," .join (local_names ),
154- "." ,
153+ "."
155154 ]
156155 session .run ("flake8" , * args )
157-
158-
159156#
160157# Black
161158#
@@ -168,7 +165,6 @@ def blacken(session: nox.sessions.Session) -> None:
168165
169166 session .run ("black" , * python_files )
170167
171-
172168#
173169# Sample Tests
174170#
@@ -177,9 +173,7 @@ def blacken(session: nox.sessions.Session) -> None:
177173PYTEST_COMMON_ARGS = ["--junitxml=sponge_log.xml" ]
178174
179175
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 :
183177 if TEST_CONFIG ["pip_version_override" ]:
184178 pip_version = TEST_CONFIG ["pip_version_override" ]
185179 session .install (f"pip=={ pip_version } " )
@@ -209,7 +203,7 @@ def _session_tests(
209203 # on travis where slow and flaky tests are excluded.
210204 # See http://doc.pytest.org/en/latest/_modules/_pytest/main.html
211205 success_codes = [0 , 5 ],
212- env = get_pytest_env_vars (),
206+ env = get_pytest_env_vars ()
213207 )
214208
215209
@@ -219,9 +213,9 @@ def py(session: nox.sessions.Session) -> None:
219213 if session .python in TESTED_VERSIONS :
220214 _session_tests (session )
221215 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+ ))
225219
226220
227221#
0 commit comments