1414# See the License for the specific language governing permissions and
1515# limitations under the License.
1616
17+
1718# Generated by synthtool. DO NOT EDIT!
1819
1920from __future__ import absolute_import
6465SYSTEM_TEST_STANDARD_DEPENDENCIES : List [str ] = [
6566 "mock" ,
6667 "pytest" ,
68+ "pytest-asyncio" ,
6769 "google-cloud-testutils" ,
6870]
6971SYSTEM_TEST_EXTERNAL_DEPENDENCIES : List [str ] = []
@@ -217,9 +219,8 @@ def unit(session, protobuf_implementation):
217219 session .install ("protobuf<4" )
218220
219221 # Run py.test against the unit tests.
220- session . run (
222+ args = [
221223 "py.test" ,
222- "--quiet" ,
223224 "-s" ,
224225 f"--junitxml=unit_{ session .python } _sponge_log.xml" ,
225226 "--cov=google" ,
@@ -228,8 +229,13 @@ def unit(session, protobuf_implementation):
228229 "--cov-config=.coveragerc" ,
229230 "--cov-report=" ,
230231 "--cov-fail-under=0" ,
231- os .path .join ("tests" , "unit" ),
232- * session .posargs ,
232+ ]
233+ if not session .posargs :
234+ args .append (os .path .join ("tests" , "unit" ))
235+ args .extend (session .posargs )
236+
237+ session .run (
238+ * args ,
233239 env = {
234240 "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION" : protobuf_implementation ,
235241 },
@@ -362,25 +368,67 @@ def system(session, protobuf_implementation, database_dialect):
362368
363369 # Run py.test against the system tests.
364370 if system_test_exists :
365- session . run (
371+ args = [
366372 "py.test" ,
367373 "--quiet" ,
374+ "-o" ,
375+ "asyncio_mode=auto" ,
368376 f"--junitxml=system_{ session .python } _sponge_log.xml" ,
369- system_test_path ,
370- * session .posargs ,
377+ ]
378+ if not session .posargs :
379+ args .append (system_test_path )
380+ args .extend (session .posargs )
381+
382+ session .run (
383+ * args ,
371384 env = {
372385 "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION" : protobuf_implementation ,
373386 "SPANNER_DATABASE_DIALECT" : database_dialect ,
374387 "SKIP_BACKUP_TESTS" : "true" ,
375388 },
376389 )
377390 elif system_test_folder_exists :
391+ # Run sync tests
392+ sync_args = [
393+ "py.test" ,
394+ "--quiet" ,
395+ "-o" ,
396+ "asyncio_mode=auto" ,
397+ f"--junitxml=system_{ session .python } _sync_sponge_log.xml" ,
398+ ]
399+ if not session .posargs :
400+ sync_args .append (os .path .join ("tests" , "system" ))
401+ sync_args .append ("--ignore=tests/system/_async" )
402+ else :
403+ sync_args .extend (session .posargs )
404+
378405 session .run (
406+ * sync_args ,
407+ env = {
408+ "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION" : protobuf_implementation ,
409+ "SPANNER_DATABASE_DIALECT" : database_dialect ,
410+ "SKIP_BACKUP_TESTS" : "true" ,
411+ },
412+ )
413+
414+ # Run async tests
415+ async_args = [
379416 "py.test" ,
380417 "--quiet" ,
381- f"--junitxml=system_{ session .python } _sponge_log.xml" ,
382- system_test_folder_path ,
383- * session .posargs ,
418+ "-o" ,
419+ "asyncio_mode=auto" ,
420+ f"--junitxml=system_{ session .python } _async_sponge_log.xml" ,
421+ ]
422+ if not session .posargs :
423+ async_args .append (os .path .join ("tests" , "system" , "_async" ))
424+ else :
425+ # If posargs are provided, only run if they match async tests
426+ # or just skip if they were already run in sync.
427+ # For simplicity, we only run async folder if no posargs.
428+ return
429+
430+ session .run (
431+ * async_args ,
384432 env = {
385433 "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION" : protobuf_implementation ,
386434 "SPANNER_DATABASE_DIALECT" : database_dialect ,
@@ -551,6 +599,10 @@ def prerelease_deps(session, protobuf_implementation, database_dialect):
551599 "google-cloud-testutils" ,
552600 # dependencies of google-cloud-testutils"
553601 "click" ,
602+ # dependency of google-auth
603+ "cffi" ,
604+ "cryptography" ,
605+ "cachetools" ,
554606 ]
555607
556608 for dep in prerel_deps :
@@ -589,6 +641,8 @@ def prerelease_deps(session, protobuf_implementation, database_dialect):
589641 session .run (
590642 "py.test" ,
591643 "--verbose" ,
644+ "-o" ,
645+ "asyncio_mode=auto" ,
592646 f"--junitxml=system_{ session .python } _sponge_log.xml" ,
593647 system_test_path ,
594648 * session .posargs ,
@@ -602,6 +656,8 @@ def prerelease_deps(session, protobuf_implementation, database_dialect):
602656 session .run (
603657 "py.test" ,
604658 "--verbose" ,
659+ "-o" ,
660+ "asyncio_mode=auto" ,
605661 f"--junitxml=system_{ session .python } _sponge_log.xml" ,
606662 system_test_folder_path ,
607663 * session .posargs ,
@@ -611,3 +667,10 @@ def prerelease_deps(session, protobuf_implementation, database_dialect):
611667 "SKIP_BACKUP_TESTS" : "true" ,
612668 },
613669 )
670+
671+
672+ @nox .session (python = DEFAULT_PYTHON_VERSION )
673+ def generate (session ):
674+ """Regenerate synchronous code from asynchronous code."""
675+ session .install ("black" , "autoflake" )
676+ session .run ("python" , ".cross_sync/generate.py" , "google/cloud/spanner_v1" )
0 commit comments