@@ -207,6 +207,45 @@ def place_before(path, text, *before_text, escape=None):
207
207
escape = "()" ,
208
208
)
209
209
210
+
211
+ mockserver_test = """
212
+ @nox.session(python=DEFAULT_MOCK_SERVER_TESTS_PYTHON_VERSION)
213
+ def mockserver(session):
214
+ # Install all test dependencies, then install this package in-place.
215
+
216
+ constraints_path = str(
217
+ CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
218
+ )
219
+ # install_unittest_dependencies(session, "-c", constraints_path)
220
+ standard_deps = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_DEPENDENCIES
221
+ session.install(*standard_deps, "-c", constraints_path)
222
+ session.install("-e", ".", "-c", constraints_path)
223
+
224
+ # Run py.test against the mockserver tests.
225
+ session.run(
226
+ "py.test",
227
+ "--quiet",
228
+ f"--junitxml=unit_{session.python}_sponge_log.xml",
229
+ "--cov=google",
230
+ "--cov=tests/unit",
231
+ "--cov-append",
232
+ "--cov-config=.coveragerc",
233
+ "--cov-report=",
234
+ "--cov-fail-under=0",
235
+ os.path.join("tests", "mockserver_tests"),
236
+ *session.posargs,
237
+ )
238
+
239
+
240
+ """
241
+
242
+ place_before (
243
+ "noxfile.py" ,
244
+ "def install_systemtest_dependencies(session, *constraints):" ,
245
+ mockserver_test ,
246
+ escape = "()" ,
247
+ )
248
+
210
249
skip_tests_if_env_var_not_set = """# Sanity check: Only run tests if the environment variable is set.
211
250
if not os.environ.get("GOOGLE_APPLICATION_CREDENTIALS", "") and not os.environ.get(
212
251
"SPANNER_EMULATOR_HOST", ""
0 commit comments