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
-
54
51
# A dictionary you want to inject into your test. Don't put any
55
52
# secrets here. These values will override predefined values.
56
- ' envs' : {},
53
+ " envs" : {},
57
54
}
58
55
59
56
60
57
try :
61
58
# Ensure we can import noxfile_config in the project's directory.
62
- sys .path .append ('.' )
59
+ sys .path .append ("." )
63
60
from noxfile_config import TEST_CONFIG_OVERRIDE
64
61
except ImportError as e :
65
62
print ("No user noxfile_config found: detail: {}" .format (e ))
@@ -74,12 +71,12 @@ def get_pytest_env_vars() -> Dict[str, str]:
74
71
ret = {}
75
72
76
73
# Override the GCLOUD_PROJECT and the alias.
77
- env_key = TEST_CONFIG [' gcloud_project_env' ]
74
+ env_key = TEST_CONFIG [" gcloud_project_env" ]
78
75
# 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 ]
80
77
81
78
# Apply user supplied envs.
82
- ret .update (TEST_CONFIG [' envs' ])
79
+ ret .update (TEST_CONFIG [" envs" ])
83
80
return ret
84
81
85
82
@@ -88,7 +85,7 @@ def get_pytest_env_vars() -> Dict[str, str]:
88
85
ALL_VERSIONS = ["2.7" , "3.6" , "3.7" , "3.8" , "3.9" ]
89
86
90
87
# Any default versions that should be ignored.
91
- IGNORED_VERSIONS = TEST_CONFIG [' ignored_versions' ]
88
+ IGNORED_VERSIONS = TEST_CONFIG [" ignored_versions" ]
92
89
93
90
TESTED_VERSIONS = sorted ([v for v in ALL_VERSIONS if v not in IGNORED_VERSIONS ])
94
91
@@ -137,7 +134,7 @@ def _determine_local_import_names(start_dir: str) -> List[str]:
137
134
138
135
@nox .session
139
136
def lint (session : nox .sessions .Session ) -> None :
140
- if not TEST_CONFIG [' enforce_type_hints' ]:
137
+ if not TEST_CONFIG [" enforce_type_hints" ]:
141
138
session .install ("flake8" , "flake8-import-order" )
142
139
else :
143
140
session .install ("flake8" , "flake8-import-order" , "flake8-annotations" )
@@ -146,9 +143,11 @@ def lint(session: nox.sessions.Session) -> None:
146
143
args = FLAKE8_COMMON_ARGS + [
147
144
"--application-import-names" ,
148
145
"," .join (local_names ),
149
- "."
146
+ "." ,
150
147
]
151
148
session .run ("flake8" , * args )
149
+
150
+
152
151
#
153
152
# Black
154
153
#
@@ -161,6 +160,7 @@ def blacken(session: nox.sessions.Session) -> None:
161
160
162
161
session .run ("black" , * python_files )
163
162
163
+
164
164
#
165
165
# Sample Tests
166
166
#
@@ -169,7 +169,9 @@ def blacken(session: nox.sessions.Session) -> None:
169
169
PYTEST_COMMON_ARGS = ["--junitxml=sponge_log.xml" ]
170
170
171
171
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 :
173
175
"""Runs py.test for a particular project."""
174
176
if os .path .exists ("requirements.txt" ):
175
177
session .install ("-r" , "requirements.txt" )
@@ -200,9 +202,9 @@ def py(session: nox.sessions.Session) -> None:
200
202
if session .python in TESTED_VERSIONS :
201
203
_session_tests (session )
202
204
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
+ )
206
208
207
209
208
210
#
0 commit comments