@@ -39,31 +39,29 @@ BLACK_VERSION = "black==19.10b0"
3939
4040TEST_CONFIG = {
4141 # You can opt out from the test for specific Python versions.
42- 'ignored_versions': [],
43-
42+ "ignored_versions": [],
4443 # Old samples are opted out of enforcing Python type hints
4544 # All new samples should feature them
46- 'enforce_type_hints': False,
47-
45+ "enforce_type_hints": False,
4846 # An envvar key for determining the project id to use. Change it
4947 # to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a
5048 # build specific Cloud project. You can also use your own string
5149 # to use your own Cloud project.
52- ' gcloud_project_env': ' GOOGLE_CLOUD_PROJECT' ,
50+ " gcloud_project_env": " GOOGLE_CLOUD_PROJECT" ,
5351 # 'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT',
5452 # If you need to use a specific version of pip,
5553 # change pip_version_override to the string representation
5654 # of the version number, for example, "20.2.4"
5755 "pip_version_override": None,
5856 # A dictionary you want to inject into your test. Don't put any
5957 # secrets here. These values will override predefined values.
60- ' envs' : {},
58+ " envs" : {},
6159}
6260
6361
6462try:
6563 # Ensure we can import noxfile_config in the project's directory.
66- sys.path.append('.' )
64+ sys.path.append("." )
6765 from noxfile_config import TEST_CONFIG_OVERRIDE
6866except ImportError as e:
6967 print("No user noxfile_config found: detail: {}".format(e))
@@ -78,12 +76,12 @@ def get_pytest_env_vars() -> Dict[str, str]:
7876 ret = {}
7977
8078 # Override the GCLOUD_PROJECT and the alias.
81- env_key = TEST_CONFIG[' gcloud_project_env' ]
79+ env_key = TEST_CONFIG[" gcloud_project_env" ]
8280 # This should error out if not set.
83- ret[' GOOGLE_CLOUD_PROJECT' ] = os.environ[env_key]
81+ ret[" GOOGLE_CLOUD_PROJECT" ] = os.environ[env_key]
8482
8583 # Apply user supplied envs.
86- ret.update(TEST_CONFIG[' envs' ])
84+ ret.update(TEST_CONFIG[" envs" ])
8785 return ret
8886
8987
@@ -92,11 +90,14 @@ def get_pytest_env_vars() -> Dict[str, str]:
9290ALL_VERSIONS = ["3.6", "3.7", "3.8", "3.9"]
9391
9492# Any default versions that should be ignored.
95- IGNORED_VERSIONS = TEST_CONFIG[' ignored_versions' ]
93+ IGNORED_VERSIONS = TEST_CONFIG[" ignored_versions" ]
9694
9795TESTED_VERSIONS = sorted([v for v in ALL_VERSIONS if v not in IGNORED_VERSIONS])
9896
99- INSTALL_LIBRARY_FROM_SOURCE = os.environ.get("INSTALL_LIBRARY_FROM_SOURCE", False) in ("True", "true")
97+ INSTALL_LIBRARY_FROM_SOURCE = os.environ.get("INSTALL_LIBRARY_FROM_SOURCE", False) in (
98+ "True",
99+ "true",
100+ )
100101#
101102# Style Checks
102103#
@@ -141,7 +142,7 @@ FLAKE8_COMMON_ARGS = [
141142
142143@nox.session
143144def lint(session: nox.sessions.Session) -> None:
144- if not TEST_CONFIG[' enforce_type_hints' ]:
145+ if not TEST_CONFIG[" enforce_type_hints" ]:
145146 session.install("flake8", "flake8-import-order")
146147 else:
147148 session.install("flake8", "flake8-import-order", "flake8-annotations")
@@ -150,9 +151,11 @@ def lint(session: nox.sessions.Session) -> None:
150151 args = FLAKE8_COMMON_ARGS + [
151152 "--application-import-names",
152153 ",".join(local_names),
153- "."
154+ ".",
154155 ]
155156 session.run("flake8", *args)
157+
158+
156159#
157160# Black
158161#
@@ -165,6 +168,7 @@ def blacken(session: nox.sessions.Session) -> None:
165168
166169 session.run("black", *python_files)
167170
171+
168172#
169173# Sample Tests
170174#
@@ -173,7 +177,9 @@ def blacken(session: nox.sessions.Session) -> None:
173177PYTEST_COMMON_ARGS = ["--junitxml=sponge_log.xml"]
174178
175179
176- def _session_tests(session: nox.sessions.Session, post_install: Callable = None) -> None:
180+ def _session_tests(
181+ session: nox.sessions.Session, post_install: Callable = None
182+ ) -> None:
177183 if TEST_CONFIG["pip_version_override"]:
178184 pip_version = TEST_CONFIG["pip_version_override"]
179185 session.install(f"pip=={pip_version}")
@@ -203,7 +209,7 @@ def _session_tests(session: nox.sessions.Session, post_install: Callable = None)
203209 # on travis where slow and flaky tests are excluded.
204210 # See http://doc.pytest.org/en/latest/_modules/_pytest/main.html
205211 success_codes=[0, 5],
206- env=get_pytest_env_vars()
212+ env=get_pytest_env_vars(),
207213 )
208214
209215
@@ -213,9 +219,9 @@ def py(session: nox.sessions.Session) -> None:
213219 if session.python in TESTED_VERSIONS:
214220 _session_tests(session)
215221 else:
216- session.skip("SKIPPED: {} tests are disabled for this sample.".format(
217- session.python
218- ))
222+ session.skip(
223+ "SKIPPED: {} tests are disabled for this sample.".format( session.python)
224+ )
219225
220226
221227#
0 commit comments