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