1414# See the License for the specific language governing permissions and
1515# limitations under the License.
1616
17+ # DO NOT EDIT THIS FILE OUTSIDE OF `.librarian/generator-input`
18+ # The source of truth for this file is `.librarian/generator-input`
19+
20+
1721# Generated by synthtool. DO NOT EDIT!
1822
1923from __future__ import absolute_import
6468SYSTEM_TEST_STANDARD_DEPENDENCIES : List [str ] = [
6569 "mock" ,
6670 "pytest" ,
71+ "pytest-asyncio" ,
6772 "google-cloud-testutils" ,
6873]
6974SYSTEM_TEST_EXTERNAL_DEPENDENCIES : List [str ] = []
@@ -217,9 +222,8 @@ def unit(session, protobuf_implementation):
217222 session .install ("protobuf<4" )
218223
219224 # Run py.test against the unit tests.
220- session . run (
225+ args = [
221226 "py.test" ,
222- "--quiet" ,
223227 "-s" ,
224228 f"--junitxml=unit_{ session .python } _sponge_log.xml" ,
225229 "--cov=google" ,
@@ -228,8 +232,13 @@ def unit(session, protobuf_implementation):
228232 "--cov-config=.coveragerc" ,
229233 "--cov-report=" ,
230234 "--cov-fail-under=0" ,
231- os .path .join ("tests" , "unit" ),
232- * session .posargs ,
235+ ]
236+ if not session .posargs :
237+ args .append (os .path .join ("tests" , "unit" ))
238+ args .extend (session .posargs )
239+
240+ session .run (
241+ * args ,
233242 env = {
234243 "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION" : protobuf_implementation ,
235244 },
@@ -362,25 +371,67 @@ def system(session, protobuf_implementation, database_dialect):
362371
363372 # Run py.test against the system tests.
364373 if system_test_exists :
365- session . run (
374+ args = [
366375 "py.test" ,
367376 "--quiet" ,
377+ "-o" ,
378+ "asyncio_mode=auto" ,
368379 f"--junitxml=system_{ session .python } _sponge_log.xml" ,
369- system_test_path ,
370- * session .posargs ,
380+ ]
381+ if not session .posargs :
382+ args .append (system_test_path )
383+ args .extend (session .posargs )
384+
385+ session .run (
386+ * args ,
371387 env = {
372388 "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION" : protobuf_implementation ,
373389 "SPANNER_DATABASE_DIALECT" : database_dialect ,
374390 "SKIP_BACKUP_TESTS" : "true" ,
375391 },
376392 )
377393 elif system_test_folder_exists :
394+ # Run sync tests
395+ sync_args = [
396+ "py.test" ,
397+ "--quiet" ,
398+ "-o" ,
399+ "asyncio_mode=auto" ,
400+ f"--junitxml=system_{ session .python } _sync_sponge_log.xml" ,
401+ ]
402+ if not session .posargs :
403+ sync_args .append (os .path .join ("tests" , "system" ))
404+ sync_args .append ("--ignore=tests/system/_async" )
405+ else :
406+ sync_args .extend (session .posargs )
407+
378408 session .run (
409+ * sync_args ,
410+ env = {
411+ "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION" : protobuf_implementation ,
412+ "SPANNER_DATABASE_DIALECT" : database_dialect ,
413+ "SKIP_BACKUP_TESTS" : "true" ,
414+ },
415+ )
416+
417+ # Run async tests
418+ async_args = [
379419 "py.test" ,
380420 "--quiet" ,
381- f"--junitxml=system_{ session .python } _sponge_log.xml" ,
382- system_test_folder_path ,
383- * session .posargs ,
421+ "-o" ,
422+ "asyncio_mode=auto" ,
423+ f"--junitxml=system_{ session .python } _async_sponge_log.xml" ,
424+ ]
425+ if not session .posargs :
426+ async_args .append (os .path .join ("tests" , "system" , "_async" ))
427+ else :
428+ # If posargs are provided, only run if they match async tests
429+ # or just skip if they were already run in sync.
430+ # For simplicity, we only run async folder if no posargs.
431+ return
432+
433+ session .run (
434+ * async_args ,
384435 env = {
385436 "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION" : protobuf_implementation ,
386437 "SPANNER_DATABASE_DIALECT" : database_dialect ,
@@ -551,6 +602,10 @@ def prerelease_deps(session, protobuf_implementation, database_dialect):
551602 "google-cloud-testutils" ,
552603 # dependencies of google-cloud-testutils"
553604 "click" ,
605+ # dependency of google-auth
606+ "cffi" ,
607+ "cryptography" ,
608+ "cachetools" ,
554609 ]
555610
556611 for dep in prerel_deps :
@@ -589,6 +644,8 @@ def prerelease_deps(session, protobuf_implementation, database_dialect):
589644 session .run (
590645 "py.test" ,
591646 "--verbose" ,
647+ "-o" ,
648+ "asyncio_mode=auto" ,
592649 f"--junitxml=system_{ session .python } _sponge_log.xml" ,
593650 system_test_path ,
594651 * session .posargs ,
@@ -602,6 +659,8 @@ def prerelease_deps(session, protobuf_implementation, database_dialect):
602659 session .run (
603660 "py.test" ,
604661 "--verbose" ,
662+ "-o" ,
663+ "asyncio_mode=auto" ,
605664 f"--junitxml=system_{ session .python } _sponge_log.xml" ,
606665 system_test_folder_path ,
607666 * session .posargs ,
@@ -611,3 +670,10 @@ def prerelease_deps(session, protobuf_implementation, database_dialect):
611670 "SKIP_BACKUP_TESTS" : "true" ,
612671 },
613672 )
673+
674+
675+ @nox .session (python = DEFAULT_PYTHON_VERSION )
676+ def generate (session ):
677+ """Regenerate synchronous code from asynchronous code."""
678+ session .install ("black" , "autoflake" )
679+ session .run ("python" , ".cross_sync/generate.py" , "google/cloud/spanner_v1" )
0 commit comments