MCPcopy Index your code
hub / github.com/googleapis/google-api-python-client / _session_tests

Function _session_tests

samples/compute/noxfile.py:186–239  ·  view source on GitHub ↗
(
    session: nox.sessions.Session, post_install: Callable = None
)

Source from the content-addressed store, hash-verified

184
185
186def _session_tests(
187 session: nox.sessions.Session, post_install: Callable = None
188) -> None:
189 # check for presence of tests
190 test_list = glob.glob("**/*_test.py", recursive=True) + glob.glob(
191 "**/test_*.py", recursive=True
192 )
193 test_list.extend(glob.glob("**/tests", recursive=True))
194
195 if len(test_list) == 0:
196 print("No tests found, skipping directory.")
197 return
198
199 if TEST_CONFIG["pip_version_override"]:
200 pip_version = TEST_CONFIG["pip_version_override"]
201 session.install(f"pip=={pip_version}")
202 """Runs py.test for a particular project."""
203 concurrent_args = []
204 if os.path.exists("requirements.txt"):
205 if os.path.exists("constraints.txt"):
206 session.install("-r", "requirements.txt", "-c", "constraints.txt")
207 else:
208 session.install("-r", "requirements.txt")
209 with open("requirements.txt") as rfile:
210 packages = rfile.read()
211
212 if os.path.exists("requirements-test.txt"):
213 if os.path.exists("constraints-test.txt"):
214 session.install("-r", "requirements-test.txt", "-c", "constraints-test.txt")
215 else:
216 session.install("-r", "requirements-test.txt")
217 with open("requirements-test.txt") as rtfile:
218 packages += rtfile.read()
219
220 if INSTALL_LIBRARY_FROM_SOURCE:
221 session.install("-e", _get_repo_root())
222
223 if post_install:
224 post_install(session)
225
226 if "pytest-parallel" in packages:
227 concurrent_args.extend(["--workers", "auto", "--tests-per-worker", "auto"])
228 elif "pytest-xdist" in packages:
229 concurrent_args.extend(["-n", "auto"])
230
231 session.run(
232 "pytest",
233 *(PYTEST_COMMON_ARGS + session.posargs + concurrent_args),
234 # Pytest will return 5 when no tests are collected. This can happen
235 # on travis where slow and flaky tests are excluded.
236 # See http://doc.pytest.org/en/latest/_modules/_pytest/main.html
237 success_codes=[0, 5],
238 env=get_pytest_env_vars(),
239 )
240
241
242@nox.session(python=ALL_VERSIONS)

Callers 1

pyFunction · 0.85

Calls 3

_get_repo_rootFunction · 0.85
get_pytest_env_varsFunction · 0.85
readMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…