3838
3939TEST_CONFIG = {
4040 # You can opt out from the test for specific Python versions.
41- 'ignored_versions' : ["2.7" ],
42-
41+ "ignored_versions" : ["2.7" ],
4342 # Old samples are opted out of enforcing Python type hints
4443 # All new samples should feature them
45- 'enforce_type_hints' : False ,
46-
44+ "enforce_type_hints" : False ,
4745 # An envvar key for determining the project id to use. Change it
4846 # to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a
4947 # build specific Cloud project. You can also use your own string
5048 # to use your own Cloud project.
51- ' gcloud_project_env' : ' GOOGLE_CLOUD_PROJECT' ,
49+ " gcloud_project_env" : " GOOGLE_CLOUD_PROJECT" ,
5250 # 'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT',
53-
5451 # A dictionary you want to inject into your test. Don't put any
5552 # secrets here. These values will override predefined values.
56- ' envs' : {},
53+ " envs" : {},
5754}
5855
5956
6057try :
6158 # Ensure we can import noxfile_config in the project's directory.
62- sys .path .append ('.' )
59+ sys .path .append ("." )
6360 from noxfile_config import TEST_CONFIG_OVERRIDE
6461except ImportError as e :
6562 print ("No user noxfile_config found: detail: {}" .format (e ))
@@ -74,12 +71,12 @@ def get_pytest_env_vars() -> Dict[str, str]:
7471 ret = {}
7572
7673 # Override the GCLOUD_PROJECT and the alias.
77- env_key = TEST_CONFIG [' gcloud_project_env' ]
74+ env_key = TEST_CONFIG [" gcloud_project_env" ]
7875 # This should error out if not set.
79- ret [' GOOGLE_CLOUD_PROJECT' ] = os .environ [env_key ]
76+ ret [" GOOGLE_CLOUD_PROJECT" ] = os .environ [env_key ]
8077
8178 # Apply user supplied envs.
82- ret .update (TEST_CONFIG [' envs' ])
79+ ret .update (TEST_CONFIG [" envs" ])
8380 return ret
8481
8582
@@ -88,7 +85,7 @@ def get_pytest_env_vars() -> Dict[str, str]:
8885ALL_VERSIONS = ["2.7" , "3.6" , "3.7" , "3.8" , "3.9" ]
8986
9087# Any default versions that should be ignored.
91- IGNORED_VERSIONS = TEST_CONFIG [' ignored_versions' ]
88+ IGNORED_VERSIONS = TEST_CONFIG [" ignored_versions" ]
9289
9390TESTED_VERSIONS = sorted ([v for v in ALL_VERSIONS if v not in IGNORED_VERSIONS ])
9491
@@ -137,7 +134,7 @@ def _determine_local_import_names(start_dir: str) -> List[str]:
137134
138135@nox .session
139136def lint (session : nox .sessions .Session ) -> None :
140- if not TEST_CONFIG [' enforce_type_hints' ]:
137+ if not TEST_CONFIG [" enforce_type_hints" ]:
141138 session .install ("flake8" , "flake8-import-order" )
142139 else :
143140 session .install ("flake8" , "flake8-import-order" , "flake8-annotations" )
@@ -146,9 +143,11 @@ def lint(session: nox.sessions.Session) -> None:
146143 args = FLAKE8_COMMON_ARGS + [
147144 "--application-import-names" ,
148145 "," .join (local_names ),
149- "."
146+ "." ,
150147 ]
151148 session .run ("flake8" , * args )
149+
150+
152151#
153152# Black
154153#
@@ -161,6 +160,7 @@ def blacken(session: nox.sessions.Session) -> None:
161160
162161 session .run ("black" , * python_files )
163162
163+
164164#
165165# Sample Tests
166166#
@@ -169,7 +169,9 @@ def blacken(session: nox.sessions.Session) -> None:
169169PYTEST_COMMON_ARGS = ["--junitxml=sponge_log.xml" ]
170170
171171
172- def _session_tests (session : nox .sessions .Session , post_install : Callable = None ) -> None :
172+ def _session_tests (
173+ session : nox .sessions .Session , post_install : Callable = None
174+ ) -> None :
173175 """Runs py.test for a particular project."""
174176 if os .path .exists ("requirements.txt" ):
175177 session .install ("-r" , "requirements.txt" )
@@ -200,9 +202,9 @@ def py(session: nox.sessions.Session) -> None:
200202 if session .python in TESTED_VERSIONS :
201203 _session_tests (session )
202204 else :
203- session .skip ("SKIPPED: {} tests are disabled for this sample." . format (
204- session .python
205- ))
205+ session .skip (
206+ "SKIPPED: {} tests are disabled for this sample." . format ( session .python )
207+ )
206208
207209
208210#
0 commit comments