Skip to content
This repository was archived by the owner on Jul 13, 2025. It is now read-only.
This repository was archived by the owner on Jul 13, 2025. It is now read-only.

PendingDeprecationWarning spew from generated tests #2389

@tseaver

Description

@tseaver

Running unit tests for almost any GAPIC-generated package yields a spew of the following:

...firestore/google/cloud/firestore_v1beta1/gapic/firestore_client.py:182: PendingDeprecationWarning: The `client_config` argument is deprecated.
  PendingDeprecationWarning)

and:

.../firestore/google/cloud/firestore_v1beta1/gapic/firestore_client.py:186: PendingDeprecationWarning: The `channel` argument is deprecated; use `transport` instead.
  '`transport` instead.', PendingDeprecationWarning)

I added a stacklevel=2 argument to both of those warnings (which should be in the generated code anyway).
It turns out that the test for the first one is bogus: literally every invocation triggers it!

    def __init__(self,
                 transport=None,
                 channel=None,
                 credentials=None,
                 client_config=firestore_client_config.config,
                 client_info=None):
        ...
        # Raise deprecation warnings for things we want to go away.
        if client_config:
            warnings.warn('The `client_config` argument is deprecated.',
                          PendingDeprecationWarning, stacklevel=2)

For the second, most the warnings were coming from generated tests!

.../firestore/tests/unit/gapic/v1beta1/test_firestore_client_v1beta1.py:541: PendingDeprecationWarning: The `channel` argument is deprecated; use `transport` instead.
  client = firestore_client.FirestoreClient(channel=channel)

The generator certainly shouldn't be emitting tests which use the deprecated pattern (unless maybe there is one which uses warnings.catch_warnings to test that it is emitted).

Metadata

Metadata

Labels

Testlang: pythonIssues specific to Python.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.yoshi

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions