From ab8cc79cbbc711676997db954753169c45a8244b Mon Sep 17 00:00:00 2001 From: ohmayr Date: Wed, 12 Nov 2025 09:11:23 +0000 Subject: [PATCH 01/13] chore: update credentials file unit tests --- tests/asyncio/test_grpc_helpers_async.py | 32 ++++++++------- .../test_operations_rest_client.py | 39 ++++++++++++------- tests/unit/test_client_options.py | 35 +++++++++-------- tests/unit/test_grpc_helpers.py | 28 +++++++------ tests/unit/test_python_version_support.py | 20 ++++++---- 5 files changed, 89 insertions(+), 65 deletions(-) diff --git a/tests/asyncio/test_grpc_helpers_async.py b/tests/asyncio/test_grpc_helpers_async.py index aa8d5d10b..85ed76026 100644 --- a/tests/asyncio/test_grpc_helpers_async.py +++ b/tests/asyncio/test_grpc_helpers_async.py @@ -522,11 +522,12 @@ def test_create_channel_explicit_with_duplicate_credentials(): target = "example:443" with pytest.raises(exceptions.DuplicateCredentialArgs) as excinfo: - grpc_helpers_async.create_channel( - target, - credentials_file="credentials.json", - credentials=mock.sentinel.credentials, - ) + with pytest.warns(DeprecationWarning): + grpc_helpers_async.create_channel( + target, + credentials_file="credentials.json", + credentials=mock.sentinel.credentials, + ) assert "mutually exclusive" in str(excinfo.value) @@ -641,9 +642,10 @@ def test_create_channel_with_credentials_file( credentials_file = "/path/to/credentials/file.json" composite_creds = composite_creds_call.return_value - channel = grpc_helpers_async.create_channel( - target, credentials_file=credentials_file - ) + with pytest.warns(DeprecationWarning): + channel = grpc_helpers_async.create_channel( + target, credentials_file=credentials_file + ) google.auth.load_credentials_from_file.assert_called_once_with( credentials_file, scopes=None, default_scopes=None @@ -670,9 +672,10 @@ def test_create_channel_with_credentials_file_and_scopes( credentials_file = "/path/to/credentials/file.json" composite_creds = composite_creds_call.return_value - channel = grpc_helpers_async.create_channel( - target, credentials_file=credentials_file, scopes=scopes - ) + with pytest.warns(DeprecationWarning): + channel = grpc_helpers_async.create_channel( + target, credentials_file=credentials_file, scopes=scopes + ) google.auth.load_credentials_from_file.assert_called_once_with( credentials_file, scopes=scopes, default_scopes=None @@ -699,9 +702,10 @@ def test_create_channel_with_credentials_file_and_default_scopes( credentials_file = "/path/to/credentials/file.json" composite_creds = composite_creds_call.return_value - channel = grpc_helpers_async.create_channel( - target, credentials_file=credentials_file, default_scopes=default_scopes - ) + with pytest.warns(DeprecationWarning): + channel = grpc_helpers_async.create_channel( + target, credentials_file=credentials_file, default_scopes=default_scopes + ) google.auth.load_credentials_from_file.assert_called_once_with( credentials_file, scopes=None, default_scopes=default_scopes diff --git a/tests/unit/operations_v1/test_operations_rest_client.py b/tests/unit/operations_v1/test_operations_rest_client.py index 4e8ef4073..bc1ae4d6a 100644 --- a/tests/unit/operations_v1/test_operations_rest_client.py +++ b/tests/unit/operations_v1/test_operations_rest_client.py @@ -369,7 +369,8 @@ def test_operations_client_client_options( ) # Check the case credentials_file is provided - options = client_options.ClientOptions(credentials_file="credentials.json") + with pytest.warns(DeprecationWarning): + options = client_options.ClientOptions(credentials_file="credentials.json") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -539,7 +540,8 @@ def test_operations_client_client_options_credentials_file( client_class, transport_class, transport_name ): # Check the case credentials file is provided. - options = client_options.ClientOptions(credentials_file="credentials.json") + with pytest.warns(DeprecationWarning): + options = client_options.ClientOptions(credentials_file="credentials.json") if "async" in str(client_class): # TODO(): Add support for credentials file to async REST transport. with pytest.raises(core_exceptions.AsyncRestUnsupportedParameterError): @@ -570,10 +572,17 @@ def test_operations_client_client_options_credentials_file( return_value=(mock.sentinel.credentials, mock.sentinel.project), ) def test_list_operations_rest(google_auth_default, credentials_file): - sync_transport = transports.rest.OperationsRestTransport( - credentials_file=credentials_file, - http_options=HTTP_OPTIONS, - ) + if credentials_file is not None: + with pytest.warns(DeprecationWarning): + sync_transport = transports.rest.OperationsRestTransport( + credentials_file=credentials_file, + http_options=HTTP_OPTIONS, + ) + else: + sync_transport = transports.rest.OperationsRestTransport( + credentials_file=credentials_file, + http_options=HTTP_OPTIONS, + ) client = AbstractOperationsClient(transport=sync_transport) @@ -1130,10 +1139,11 @@ def test_transport_adc(client_class, transport_class, credentials): def test_operations_base_transport_error(): # Passing both a credentials object and credentials_file should raise an error with pytest.raises(core_exceptions.DuplicateCredentialArgs): - transports.OperationsTransport( - credentials=ga_credentials.AnonymousCredentials(), - credentials_file="credentials.json", - ) + with pytest.warns(DeprecationWarning): + transports.OperationsTransport( + credentials=ga_credentials.AnonymousCredentials(), + credentials_file="credentials.json", + ) def test_operations_base_transport(): @@ -1171,10 +1181,11 @@ def test_operations_base_transport_with_credentials_file(): ) as Transport: Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transports.OperationsTransport( - credentials_file="credentials.json", - quota_project_id="octopus", - ) + with pytest.warns(DeprecationWarning): + transports.OperationsTransport( + credentials_file="credentials.json", + quota_project_id="octopus", + ) load_creds.assert_called_once_with( "credentials.json", scopes=None, diff --git a/tests/unit/test_client_options.py b/tests/unit/test_client_options.py index 396d66271..adf3b8442 100644 --- a/tests/unit/test_client_options.py +++ b/tests/unit/test_client_options.py @@ -27,19 +27,19 @@ def get_client_encrypted_cert(): def test_constructor(): - - options = client_options.ClientOptions( - api_endpoint="foo.googleapis.com", - client_cert_source=get_client_cert, - quota_project_id="quote-proj", - credentials_file="path/to/credentials.json", - scopes=[ - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/cloud-platform.read-only", - ], - api_audience="foo2.googleapis.com", - universe_domain="googleapis.com", - ) + with pytest.warns(DeprecationWarning): + options = client_options.ClientOptions( + api_endpoint="foo.googleapis.com", + client_cert_source=get_client_cert, + quota_project_id="quote-proj", + credentials_file="path/to/credentials.json", + scopes=[ + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/cloud-platform.read-only", + ], + api_audience="foo2.googleapis.com", + universe_domain="googleapis.com", + ) assert options.api_endpoint == "foo.googleapis.com" assert options.client_cert_source() == (b"cert", b"key") @@ -102,10 +102,11 @@ def test_constructor_with_api_key(): def test_constructor_with_both_api_key_and_credentials_file(): with pytest.raises(ValueError): - client_options.ClientOptions( - api_key="api-key", - credentials_file="path/to/credentials.json", - ) + with pytest.warns(DeprecationWarning): + client_options.ClientOptions( + api_key="api-key", + credentials_file="path/to/credentials.json", + ) def test_from_dict(): diff --git a/tests/unit/test_grpc_helpers.py b/tests/unit/test_grpc_helpers.py index 8de9d8c0b..f0ea38a4f 100644 --- a/tests/unit/test_grpc_helpers.py +++ b/tests/unit/test_grpc_helpers.py @@ -581,11 +581,12 @@ def test_create_channel_explicit_with_duplicate_credentials(): target = "example.com:443" with pytest.raises(exceptions.DuplicateCredentialArgs): - grpc_helpers.create_channel( - target, - credentials_file="credentials.json", - credentials=mock.sentinel.credentials, - ) + with pytest.warns(DeprecationWarning): + grpc_helpers.create_channel( + target, + credentials_file="credentials.json", + credentials=mock.sentinel.credentials, + ) @mock.patch("grpc.compute_engine_channel_credentials") @@ -710,7 +711,8 @@ def test_create_channel_with_credentials_file( credentials_file = "/path/to/credentials/file.json" composite_creds = composite_creds_call.return_value - channel = grpc_helpers.create_channel(target, credentials_file=credentials_file) + with pytest.warns(DeprecationWarning): + channel = grpc_helpers.create_channel(target, credentials_file=credentials_file) google.auth.load_credentials_from_file.assert_called_once_with( credentials_file, scopes=None, default_scopes=None @@ -742,9 +744,10 @@ def test_create_channel_with_credentials_file_and_scopes( credentials_file = "/path/to/credentials/file.json" composite_creds = composite_creds_call.return_value - channel = grpc_helpers.create_channel( - target, credentials_file=credentials_file, scopes=scopes - ) + with pytest.warns(DeprecationWarning): + channel = grpc_helpers.create_channel( + target, credentials_file=credentials_file, scopes=scopes + ) google.auth.load_credentials_from_file.assert_called_once_with( credentials_file, scopes=scopes, default_scopes=None @@ -776,9 +779,10 @@ def test_create_channel_with_credentials_file_and_default_scopes( credentials_file = "/path/to/credentials/file.json" composite_creds = composite_creds_call.return_value - channel = grpc_helpers.create_channel( - target, credentials_file=credentials_file, default_scopes=default_scopes - ) + with pytest.warns(DeprecationWarning): + channel = grpc_helpers.create_channel( + target, credentials_file=credentials_file, default_scopes=default_scopes + ) load_credentials_from_file.assert_called_once_with( credentials_file, scopes=None, default_scopes=default_scopes diff --git a/tests/unit/test_python_version_support.py b/tests/unit/test_python_version_support.py index c38160b78..64c93ff51 100644 --- a/tests/unit/test_python_version_support.py +++ b/tests/unit/test_python_version_support.py @@ -178,17 +178,20 @@ def test_override_gapic_end_only(): "google.api_core._python_version_support.PYTHON_VERSION_INFO", {version_tuple: overridden_info}, ): - result_before_boundary = check_python_version( - today=custom_gapic_end + datetime.timedelta(days=-1) - ) + with pytest.warns(FutureWarning): + result_before_boundary = check_python_version( + today=custom_gapic_end + datetime.timedelta(days=-1) + ) assert result_before_boundary == PythonVersionStatus.PYTHON_VERSION_EOL - result_at_boundary = check_python_version(today=custom_gapic_end) + with pytest.warns(FutureWarning): + result_at_boundary = check_python_version(today=custom_gapic_end) assert result_at_boundary == PythonVersionStatus.PYTHON_VERSION_EOL - result_after_boundary = check_python_version( - today=custom_gapic_end + datetime.timedelta(days=1) - ) + with pytest.warns(FutureWarning): + result_after_boundary = check_python_version( + today=custom_gapic_end + datetime.timedelta(days=1) + ) assert ( result_after_boundary == PythonVersionStatus.PYTHON_VERSION_UNSUPPORTED ) @@ -217,7 +220,8 @@ def test_override_gapic_deprecation_only(): result_before_boundary == PythonVersionStatus.PYTHON_VERSION_SUPPORTED ) - result_at_boundary = check_python_version(today=custom_gapic_dep) + with pytest.warns(FutureWarning): + result_at_boundary = check_python_version(today=custom_gapic_dep) assert result_at_boundary == PythonVersionStatus.PYTHON_VERSION_DEPRECATED From 73e722b17e1bec2b41e70558ab2ce547d19b68e9 Mon Sep 17 00:00:00 2001 From: ohmayr Date: Wed, 12 Nov 2025 09:33:07 +0000 Subject: [PATCH 02/13] fix async tests --- .../operations_v1/test_operations_rest_client.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tests/unit/operations_v1/test_operations_rest_client.py b/tests/unit/operations_v1/test_operations_rest_client.py index bc1ae4d6a..18aeeab34 100644 --- a/tests/unit/operations_v1/test_operations_rest_client.py +++ b/tests/unit/operations_v1/test_operations_rest_client.py @@ -543,9 +543,19 @@ def test_operations_client_client_options_credentials_file( with pytest.warns(DeprecationWarning): options = client_options.ClientOptions(credentials_file="credentials.json") if "async" in str(client_class): - # TODO(): Add support for credentials file to async REST transport. - with pytest.raises(core_exceptions.AsyncRestUnsupportedParameterError): - client_class(client_options=options, transport=transport_name) + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) else: with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None From 9be30b50f2a83e2687e87ce0b3d7698aacdac341 Mon Sep 17 00:00:00 2001 From: ohmayr Date: Wed, 12 Nov 2025 10:11:41 +0000 Subject: [PATCH 03/13] fix warnings for wo_grpc nox session --- noxfile.py | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/noxfile.py b/noxfile.py index 04347a4f3..dcbb1bcbb 100644 --- a/noxfile.py +++ b/noxfile.py @@ -159,12 +159,19 @@ def default(session, install_grpc=True, prerelease=False, install_async_rest=Fal if not pathlib.Path(constraints_file).exists(): constraints_file = f"{constraints_dir}/constraints-{session.python}.txt" - session.install( - "-e", - lib_with_extras, - "-c", - constraints_file, - ) + if not install_grpc and not install_async_rest: + session.install( + "google-api-core", + "-c", + constraints_file, + ) + else: + session.install( + "-e", + lib_with_extras, + "-c", + constraints_file, + ) # Print out package versions of dependencies session.run( @@ -185,6 +192,15 @@ def default(session, install_grpc=True, prerelease=False, install_async_rest=Fal "python", "-m", "pytest", + ] + if not install_grpc and not install_async_rest: + pytest_args.extend(["-W", "ignore::FutureWarning"]) + + pytest_args.extend([ + # We use filterwarnings to ignore warnings that are out of our control, + # but we want to make sure that our own code does not generate warnings. + "-m", + "not filterwarnings", *( # Helpful for running a single test or testfile. session.posargs @@ -201,7 +217,7 @@ def default(session, install_grpc=True, prerelease=False, install_async_rest=Fal os.path.join("tests", "unit"), ] ), - ] + ]) session.install("asyncmock", "pytest-asyncio") From f3f3a44ddbf32cae0d2caa6ed707540b8c38fe6a Mon Sep 17 00:00:00 2001 From: ohmayr Date: Wed, 12 Nov 2025 10:28:58 +0000 Subject: [PATCH 04/13] ignore future warnings --- noxfile.py | 70 +++++++++++------------ tests/unit/test_python_version_support.py | 20 +++---- 2 files changed, 40 insertions(+), 50 deletions(-) diff --git a/noxfile.py b/noxfile.py index dcbb1bcbb..11d8f4e75 100644 --- a/noxfile.py +++ b/noxfile.py @@ -159,19 +159,12 @@ def default(session, install_grpc=True, prerelease=False, install_async_rest=Fal if not pathlib.Path(constraints_file).exists(): constraints_file = f"{constraints_dir}/constraints-{session.python}.txt" - if not install_grpc and not install_async_rest: - session.install( - "google-api-core", - "-c", - constraints_file, - ) - else: - session.install( - "-e", - lib_with_extras, - "-c", - constraints_file, - ) + session.install( + "-e", + lib_with_extras, + "-c", + constraints_file, + ) # Print out package versions of dependencies session.run( @@ -193,31 +186,32 @@ def default(session, install_grpc=True, prerelease=False, install_async_rest=Fal "-m", "pytest", ] - if not install_grpc and not install_async_rest: - pytest_args.extend(["-W", "ignore::FutureWarning"]) - - pytest_args.extend([ - # We use filterwarnings to ignore warnings that are out of our control, - # but we want to make sure that our own code does not generate warnings. - "-m", - "not filterwarnings", - *( - # Helpful for running a single test or testfile. - session.posargs - or [ - "--quiet", - "--cov=google.api_core", - "--cov=tests.unit", - "--cov-append", - "--cov-config=.coveragerc", - "--cov-report=", - "--cov-fail-under=0", - # Running individual tests with parallelism enabled is usually not helpful. - "-n=auto", - os.path.join("tests", "unit"), - ] - ), - ]) + pytest_args.extend(["-W", "ignore::FutureWarning"]) + + pytest_args.extend( + [ + # We use filterwarnings to ignore warnings that are out of our control, + # but we want to make sure that our own code does not generate warnings. + "-m", + "not filterwarnings", + *( + # Helpful for running a single test or testfile. + session.posargs + or [ + "--quiet", + "--cov=google.api_core", + "--cov=tests.unit", + "--cov-append", + "--cov-config=.coveragerc", + "--cov-report=", + "--cov-fail-under=0", + # Running individual tests with parallelism enabled is usually not helpful. + "-n=auto", + os.path.join("tests", "unit"), + ] + ), + ] + ) session.install("asyncmock", "pytest-asyncio") diff --git a/tests/unit/test_python_version_support.py b/tests/unit/test_python_version_support.py index 64c93ff51..c38160b78 100644 --- a/tests/unit/test_python_version_support.py +++ b/tests/unit/test_python_version_support.py @@ -178,20 +178,17 @@ def test_override_gapic_end_only(): "google.api_core._python_version_support.PYTHON_VERSION_INFO", {version_tuple: overridden_info}, ): - with pytest.warns(FutureWarning): - result_before_boundary = check_python_version( - today=custom_gapic_end + datetime.timedelta(days=-1) - ) + result_before_boundary = check_python_version( + today=custom_gapic_end + datetime.timedelta(days=-1) + ) assert result_before_boundary == PythonVersionStatus.PYTHON_VERSION_EOL - with pytest.warns(FutureWarning): - result_at_boundary = check_python_version(today=custom_gapic_end) + result_at_boundary = check_python_version(today=custom_gapic_end) assert result_at_boundary == PythonVersionStatus.PYTHON_VERSION_EOL - with pytest.warns(FutureWarning): - result_after_boundary = check_python_version( - today=custom_gapic_end + datetime.timedelta(days=1) - ) + result_after_boundary = check_python_version( + today=custom_gapic_end + datetime.timedelta(days=1) + ) assert ( result_after_boundary == PythonVersionStatus.PYTHON_VERSION_UNSUPPORTED ) @@ -220,8 +217,7 @@ def test_override_gapic_deprecation_only(): result_before_boundary == PythonVersionStatus.PYTHON_VERSION_SUPPORTED ) - with pytest.warns(FutureWarning): - result_at_boundary = check_python_version(today=custom_gapic_dep) + result_at_boundary = check_python_version(today=custom_gapic_dep) assert result_at_boundary == PythonVersionStatus.PYTHON_VERSION_DEPRECATED From 677280ebd840b8bcf0e2520e444db23ceb8efbd5 Mon Sep 17 00:00:00 2001 From: ohmayr Date: Wed, 12 Nov 2025 10:48:18 +0000 Subject: [PATCH 05/13] adjust tolerance to fix the error --- tests/asyncio/gapic/test_method_async.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/asyncio/gapic/test_method_async.py b/tests/asyncio/gapic/test_method_async.py index 3edf8b6d4..40dd168a0 100644 --- a/tests/asyncio/gapic/test_method_async.py +++ b/tests/asyncio/gapic/test_method_async.py @@ -260,7 +260,7 @@ async def test_wrap_method_with_overriding_timeout_as_a_number(): actual_timeout = method.call_args[1]["timeout"] metadata = method.call_args[1]["metadata"] assert metadata == mock.ANY - assert actual_timeout == pytest.approx(22, abs=0.01) + assert actual_timeout == pytest.approx(22, abs=0.05) @pytest.mark.asyncio From 802dd5b1976e38f071940aa4e86ae58c40891209 Mon Sep 17 00:00:00 2001 From: ohmayr Date: Wed, 12 Nov 2025 21:11:52 +0000 Subject: [PATCH 06/13] address PR feedback --- tests/asyncio/test_grpc_helpers_async.py | 12 ++++++++++++ .../operations_v1/test_operations_rest_client.py | 15 +++++++++++++++ tests/unit/test_client_options.py | 6 ++++++ tests/unit/test_grpc_helpers.py | 12 ++++++++++++ 4 files changed, 45 insertions(+) diff --git a/tests/asyncio/test_grpc_helpers_async.py b/tests/asyncio/test_grpc_helpers_async.py index 85ed76026..ea7ffa7e7 100644 --- a/tests/asyncio/test_grpc_helpers_async.py +++ b/tests/asyncio/test_grpc_helpers_async.py @@ -522,6 +522,9 @@ def test_create_channel_explicit_with_duplicate_credentials(): target = "example:443" with pytest.raises(exceptions.DuplicateCredentialArgs) as excinfo: + # The `credentials_file` argument is deprecated by + # the Google Cloud Auth library (`google-auth`), which is the + # upstream dependency responsible for handling authentication. with pytest.warns(DeprecationWarning): grpc_helpers_async.create_channel( target, @@ -643,6 +646,9 @@ def test_create_channel_with_credentials_file( composite_creds = composite_creds_call.return_value with pytest.warns(DeprecationWarning): + # The `credentials_file` argument is deprecated by + # the Google Cloud Auth library (`google-auth`), which is the + # upstream dependency responsible for handling authentication. channel = grpc_helpers_async.create_channel( target, credentials_file=credentials_file ) @@ -673,6 +679,9 @@ def test_create_channel_with_credentials_file_and_scopes( composite_creds = composite_creds_call.return_value with pytest.warns(DeprecationWarning): + # The `credentials_file` argument is deprecated by + # the Google Cloud Auth library (`google-auth`), which is the + # upstream dependency responsible for handling authentication. channel = grpc_helpers_async.create_channel( target, credentials_file=credentials_file, scopes=scopes ) @@ -703,6 +712,9 @@ def test_create_channel_with_credentials_file_and_default_scopes( composite_creds = composite_creds_call.return_value with pytest.warns(DeprecationWarning): + # The `credentials_file` argument is deprecated by + # the Google Cloud Auth library (`google-auth`), which is the + # upstream dependency responsible for handling authentication. channel = grpc_helpers_async.create_channel( target, credentials_file=credentials_file, default_scopes=default_scopes ) diff --git a/tests/unit/operations_v1/test_operations_rest_client.py b/tests/unit/operations_v1/test_operations_rest_client.py index 18aeeab34..7fb26e18f 100644 --- a/tests/unit/operations_v1/test_operations_rest_client.py +++ b/tests/unit/operations_v1/test_operations_rest_client.py @@ -370,6 +370,9 @@ def test_operations_client_client_options( # Check the case credentials_file is provided with pytest.warns(DeprecationWarning): + # The `credentials_file` argument is deprecated by + # the Google Cloud Auth library (`google-auth`), which is the + # upstream dependency responsible for handling authentication. options = client_options.ClientOptions(credentials_file="credentials.json") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None @@ -541,6 +544,9 @@ def test_operations_client_client_options_credentials_file( ): # Check the case credentials file is provided. with pytest.warns(DeprecationWarning): + # The `credentials_file` argument is deprecated by + # the Google Cloud Auth library (`google-auth`), which is the + # upstream dependency responsible for handling authentication. options = client_options.ClientOptions(credentials_file="credentials.json") if "async" in str(client_class): with mock.patch.object(transport_class, "__init__") as patched: @@ -584,6 +590,9 @@ def test_operations_client_client_options_credentials_file( def test_list_operations_rest(google_auth_default, credentials_file): if credentials_file is not None: with pytest.warns(DeprecationWarning): + # The `credentials_file` argument is deprecated by + # the Google Cloud Auth library (`google-auth`), which is the + # upstream dependency responsible for handling authentication. sync_transport = transports.rest.OperationsRestTransport( credentials_file=credentials_file, http_options=HTTP_OPTIONS, @@ -1150,6 +1159,9 @@ def test_operations_base_transport_error(): # Passing both a credentials object and credentials_file should raise an error with pytest.raises(core_exceptions.DuplicateCredentialArgs): with pytest.warns(DeprecationWarning): + # The `credentials_file` argument is deprecated by + # the Google Cloud Auth library (`google-auth`), which is the + # upstream dependency responsible for handling authentication. transports.OperationsTransport( credentials=ga_credentials.AnonymousCredentials(), credentials_file="credentials.json", @@ -1192,6 +1204,9 @@ def test_operations_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) with pytest.warns(DeprecationWarning): + # The `credentials_file` argument is deprecated by + # the Google Cloud Auth library (`google-auth`), which is the + # upstream dependency responsible for handling authentication. transports.OperationsTransport( credentials_file="credentials.json", quota_project_id="octopus", diff --git a/tests/unit/test_client_options.py b/tests/unit/test_client_options.py index adf3b8442..0dccd9d99 100644 --- a/tests/unit/test_client_options.py +++ b/tests/unit/test_client_options.py @@ -28,6 +28,9 @@ def get_client_encrypted_cert(): def test_constructor(): with pytest.warns(DeprecationWarning): + # The `credentials_file` argument is deprecated by + # the Google Cloud Auth library (`google-auth`), which is the + # upstream dependency responsible for handling authentication. options = client_options.ClientOptions( api_endpoint="foo.googleapis.com", client_cert_source=get_client_cert, @@ -103,6 +106,9 @@ def test_constructor_with_api_key(): def test_constructor_with_both_api_key_and_credentials_file(): with pytest.raises(ValueError): with pytest.warns(DeprecationWarning): + # The `credentials_file` argument is deprecated by + # the Google Cloud Auth library (`google-auth`), which is the + # upstream dependency responsible for handling authentication. client_options.ClientOptions( api_key="api-key", credentials_file="path/to/credentials.json", diff --git a/tests/unit/test_grpc_helpers.py b/tests/unit/test_grpc_helpers.py index f0ea38a4f..9d7bb9c04 100644 --- a/tests/unit/test_grpc_helpers.py +++ b/tests/unit/test_grpc_helpers.py @@ -582,6 +582,9 @@ def test_create_channel_explicit_with_duplicate_credentials(): with pytest.raises(exceptions.DuplicateCredentialArgs): with pytest.warns(DeprecationWarning): + # The `credentials_file` argument is deprecated by + # the Google Cloud Auth library (`google-auth`), which is the + # upstream dependency responsible for handling authentication. grpc_helpers.create_channel( target, credentials_file="credentials.json", @@ -712,6 +715,9 @@ def test_create_channel_with_credentials_file( composite_creds = composite_creds_call.return_value with pytest.warns(DeprecationWarning): + # The `credentials_file` argument is deprecated by + # the Google Cloud Auth library (`google-auth`), which is the + # upstream dependency responsible for handling authentication. channel = grpc_helpers.create_channel(target, credentials_file=credentials_file) google.auth.load_credentials_from_file.assert_called_once_with( @@ -745,6 +751,9 @@ def test_create_channel_with_credentials_file_and_scopes( composite_creds = composite_creds_call.return_value with pytest.warns(DeprecationWarning): + # The `credentials_file` argument is deprecated by + # the Google Cloud Auth library (`google-auth`), which is the + # upstream dependency responsible for handling authentication. channel = grpc_helpers.create_channel( target, credentials_file=credentials_file, scopes=scopes ) @@ -780,6 +789,9 @@ def test_create_channel_with_credentials_file_and_default_scopes( composite_creds = composite_creds_call.return_value with pytest.warns(DeprecationWarning): + # The `credentials_file` argument is deprecated by + # the Google Cloud Auth library (`google-auth`), which is the + # upstream dependency responsible for handling authentication. channel = grpc_helpers.create_channel( target, credentials_file=credentials_file, default_scopes=default_scopes ) From de6c35f8c3446d79ce19f50c90199960ffbb0709 Mon Sep 17 00:00:00 2001 From: ohmayr Date: Wed, 12 Nov 2025 21:31:09 +0000 Subject: [PATCH 07/13] address PR feedback --- noxfile.py | 42 ++++++++++++++++-------------------------- pytest.ini | 4 ++++ 2 files changed, 20 insertions(+), 26 deletions(-) create mode 100644 pytest.ini diff --git a/noxfile.py b/noxfile.py index 11d8f4e75..04347a4f3 100644 --- a/noxfile.py +++ b/noxfile.py @@ -185,33 +185,23 @@ def default(session, install_grpc=True, prerelease=False, install_async_rest=Fal "python", "-m", "pytest", + *( + # Helpful for running a single test or testfile. + session.posargs + or [ + "--quiet", + "--cov=google.api_core", + "--cov=tests.unit", + "--cov-append", + "--cov-config=.coveragerc", + "--cov-report=", + "--cov-fail-under=0", + # Running individual tests with parallelism enabled is usually not helpful. + "-n=auto", + os.path.join("tests", "unit"), + ] + ), ] - pytest_args.extend(["-W", "ignore::FutureWarning"]) - - pytest_args.extend( - [ - # We use filterwarnings to ignore warnings that are out of our control, - # but we want to make sure that our own code does not generate warnings. - "-m", - "not filterwarnings", - *( - # Helpful for running a single test or testfile. - session.posargs - or [ - "--quiet", - "--cov=google.api_core", - "--cov=tests.unit", - "--cov-append", - "--cov-config=.coveragerc", - "--cov-report=", - "--cov-fail-under=0", - # Running individual tests with parallelism enabled is usually not helpful. - "-n=auto", - os.path.join("tests", "unit"), - ] - ), - ] - ) session.install("asyncmock", "pytest-asyncio") diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 000000000..6523b55d2 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,4 @@ +[pytest] +filterwarnings = + # Remove after support for Python 3.10 is dropped + ignore:.*You are using a Python version \(3\.10:FutureWarning \ No newline at end of file From 4493d19960ea0f92c736f7f163f813bce9a7061d Mon Sep 17 00:00:00 2001 From: ohmayr Date: Wed, 12 Nov 2025 21:32:54 +0000 Subject: [PATCH 08/13] fix lint --- tests/asyncio/test_grpc_helpers_async.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/asyncio/test_grpc_helpers_async.py b/tests/asyncio/test_grpc_helpers_async.py index ea7ffa7e7..3fffd070b 100644 --- a/tests/asyncio/test_grpc_helpers_async.py +++ b/tests/asyncio/test_grpc_helpers_async.py @@ -681,7 +681,7 @@ def test_create_channel_with_credentials_file_and_scopes( with pytest.warns(DeprecationWarning): # The `credentials_file` argument is deprecated by # the Google Cloud Auth library (`google-auth`), which is the - # upstream dependency responsible for handling authentication. + # upstream dependency responsible for handling authentication. channel = grpc_helpers_async.create_channel( target, credentials_file=credentials_file, scopes=scopes ) From df5100b51369c092ddf365a0f1988855590b40f0 Mon Sep 17 00:00:00 2001 From: ohmayr Date: Wed, 12 Nov 2025 21:40:48 +0000 Subject: [PATCH 09/13] move warning to toml --- pyproject.toml | 2 ++ pytest.ini | 4 ---- 2 files changed, 2 insertions(+), 4 deletions(-) delete mode 100644 pytest.ini diff --git a/pyproject.toml b/pyproject.toml index 0132afe05..f1c243f59 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -110,4 +110,6 @@ filterwarnings = [ "ignore:There is no current event loop:DeprecationWarning", # Remove after support for Python 3.7 is dropped "ignore:After January 1, 2024, new releases of this library will drop support for Python 3.7:DeprecationWarning", + # Remove after support for Python 3.10 is dropped + "ignore:.*You are using a Python version \(3\.10:FutureWarning", ] diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index 6523b55d2..000000000 --- a/pytest.ini +++ /dev/null @@ -1,4 +0,0 @@ -[pytest] -filterwarnings = - # Remove after support for Python 3.10 is dropped - ignore:.*You are using a Python version \(3\.10:FutureWarning \ No newline at end of file From e588fe22a37c7ee72e8827b51e6abc765b3d319d Mon Sep 17 00:00:00 2001 From: ohmayr Date: Wed, 12 Nov 2025 22:09:44 +0000 Subject: [PATCH 10/13] fix formatting --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index f1c243f59..ed2866fb7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -111,5 +111,5 @@ filterwarnings = [ # Remove after support for Python 3.7 is dropped "ignore:After January 1, 2024, new releases of this library will drop support for Python 3.7:DeprecationWarning", # Remove after support for Python 3.10 is dropped - "ignore:.*You are using a Python version \(3\.10:FutureWarning", + "ignore:.*You are using a Python version \\(3\\.10:FutureWarning", ] From 2112aa4b31b1e93802b8b9b6cd9a8d34686be436 Mon Sep 17 00:00:00 2001 From: ohmayr Date: Wed, 12 Nov 2025 22:19:47 +0000 Subject: [PATCH 11/13] ignore warning for 3.11 --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index ed2866fb7..dc0924e67 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -112,4 +112,6 @@ filterwarnings = [ "ignore:After January 1, 2024, new releases of this library will drop support for Python 3.7:DeprecationWarning", # Remove after support for Python 3.10 is dropped "ignore:.*You are using a Python version \\(3\\.10:FutureWarning", + # Remove after support for Python 3.11 is dropped + "ignore:.*You are using a Python version \\(3\\.11:FutureWarning", ] From 020247987656976bab3462a62061680dcd986807 Mon Sep 17 00:00:00 2001 From: ohmayr Date: Wed, 12 Nov 2025 22:31:05 +0000 Subject: [PATCH 12/13] wip --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index dc0924e67..9943c2916 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -111,7 +111,7 @@ filterwarnings = [ # Remove after support for Python 3.7 is dropped "ignore:After January 1, 2024, new releases of this library will drop support for Python 3.7:DeprecationWarning", # Remove after support for Python 3.10 is dropped - "ignore:.*You are using a Python version \\(3\\.10:FutureWarning", + "ignore:.*You are using a.* Python version \\(3\\.10:FutureWarning", # Remove after support for Python 3.11 is dropped - "ignore:.*You are using a Python version \\(3\\.11:FutureWarning", + "ignore:.*You are using a.* Python version \\(3\\.11:FutureWarning", ] From 93e3779a609a2d85c168ab8c32fc8ed72633b336 Mon Sep 17 00:00:00 2001 From: ohmayr Date: Wed, 12 Nov 2025 23:06:38 +0000 Subject: [PATCH 13/13] ignore future warning for 3.12 --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 9943c2916..037e20b2d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -114,4 +114,6 @@ filterwarnings = [ "ignore:.*You are using a.* Python version \\(3\\.10:FutureWarning", # Remove after support for Python 3.11 is dropped "ignore:.*You are using a.* Python version \\(3\\.11:FutureWarning", + # Remove after support for Python 3.12 is dropped + "ignore:.*You are using a.* Python version \\(3\\.12:FutureWarning", ]