@@ -383,28 +383,15 @@ def docfx(session):
383383def prerelease_deps (session ):
384384 """Run all tests with prerelease versions of dependencies installed."""
385385
386- prerel_deps = [
387- "protobuf" ,
388- "googleapis-common-protos" ,
389- "google-auth" ,
390- "grpcio" ,
391- "grpcio-status" ,
392- "google-api-core" ,
393- "proto-plus" ,
394- # dependencies of google-auth
395- "cryptography" ,
396- "pyasn1" ,
397- ]
398-
399- for dep in prerel_deps :
400- session .install ("--pre" , "--no-deps" , "--upgrade" , dep )
401-
402- # Remaining dependencies
403- other_deps = ["requests" ]
404- session .install (* other_deps )
405-
386+ # Install all dependencies
387+ session .install ("-e" , ".[all, tests, tracing]" )
406388 session .install (* UNIT_TEST_STANDARD_DEPENDENCIES )
407- session .install (* SYSTEM_TEST_STANDARD_DEPENDENCIES )
389+ system_deps_all = (
390+ SYSTEM_TEST_STANDARD_DEPENDENCIES
391+ + SYSTEM_TEST_EXTERNAL_DEPENDENCIES
392+ + SYSTEM_TEST_EXTRAS
393+ )
394+ session .install (* system_deps_all )
408395
409396 # Because we test minimum dependency versions on the minimum Python
410397 # version, the first version we test with in the unit tests sessions has a
@@ -418,19 +405,44 @@ def prerelease_deps(session):
418405 constraints_text = constraints_file .read ()
419406
420407 # Ignore leading whitespace and comment lines.
421- deps = [
408+ constraints_deps = [
422409 match .group (1 )
423410 for match in re .finditer (
424411 r"^\s*(\S+)(?===\S+)" , constraints_text , flags = re .MULTILINE
425412 )
426413 ]
427414
428- # Don't overwrite prerelease packages.
429- deps = [dep for dep in deps if dep not in prerel_deps ]
430- # We use --no-deps to ensure that pre-release versions aren't overwritten
431- # by the version ranges in setup.py.
432- session .install (* deps )
433- session .install ("--no-deps" , "-e" , ".[all]" )
415+ session .install (* constraints_deps )
416+
417+ if os .path .exists ("samples/snippets/requirements.txt" ):
418+ session .install ("-r" , "samples/snippets/requirements.txt" )
419+
420+ if os .path .exists ("samples/snippets/requirements-test.txt" ):
421+ session .install ("-r" , "samples/snippets/requirements-test.txt" )
422+
423+ prerel_deps = [
424+ "protobuf" ,
425+ # dependency of grpc
426+ "six" ,
427+ "googleapis-common-protos" ,
428+ "grpcio" ,
429+ "grpcio-status" ,
430+ "google-api-core" ,
431+ "proto-plus" ,
432+ "google-cloud-testutils" ,
433+ # dependencies of google-cloud-testutils"
434+ "click" ,
435+ ]
436+
437+ for dep in prerel_deps :
438+ session .install ("--pre" , "--no-deps" , "--upgrade" , dep )
439+
440+ # Remaining dependencies
441+ other_deps = [
442+ "requests" ,
443+ "google-auth" ,
444+ ]
445+ session .install (* other_deps )
434446
435447 # Print out prerelease package versions
436448 session .run (
@@ -439,5 +451,16 @@ def prerelease_deps(session):
439451 session .run ("python" , "-c" , "import grpc; print(grpc.__version__)" )
440452
441453 session .run ("py.test" , "tests/unit" )
442- session .run ("py.test" , "tests/system" )
443- session .run ("py.test" , "samples/snippets" )
454+
455+ system_test_path = os .path .join ("tests" , "system.py" )
456+ system_test_folder_path = os .path .join ("tests" , "system" )
457+
458+ # Only run system tests if found.
459+ if os .path .exists (system_test_path ) or os .path .exists (system_test_folder_path ):
460+ session .run ("py.test" , "tests/system" )
461+
462+ snippets_test_path = os .path .join ("samples" , "snippets" )
463+
464+ # Only run samples tests if found.
465+ if os .path .exists (snippets_test_path ):
466+ session .run ("py.test" , "samples/snippets" )
0 commit comments