Skip to content
This repository has been archived by the owner on Jun 28, 2022. It is now read-only.

PendingDeprecationWarning spew from generated tests #2389

Closed
tseaver opened this issue Oct 18, 2018 · 1 comment
Closed

PendingDeprecationWarning spew from generated tests #2389

tseaver opened this issue Oct 18, 2018 · 1 comment
Assignees
Labels
lang: python Issues specific to Python. priority: p2 Moderately-important priority. Fix may not be included in next release. Test type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. yoshi

Comments

@tseaver
Copy link
Contributor

tseaver commented Oct 18, 2018

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).

@tseaver tseaver added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. lang: python Issues specific to Python. priority: p2 Moderately-important priority. Fix may not be included in next release. Test yoshi labels Oct 18, 2018
@tseaver
Copy link
Contributor Author

tseaver commented Oct 19, 2018

Maybe a dumb question, but why are we planning to deprecate the channel argument to GAPIC clients? Passing in a custom channel is the most straightforward way to achieve things like opencensus interception.

tseaver added a commit that referenced this issue Nov 6, 2018
- Add 'stacklevel=2' to each emitted 'PendingDeprecationWarning'.

- Fix detection of non-default 'client_config' argument (make the default
  'None', and assign in the body).

- Replace deprecation-emitting 'channel=channel' arguments to client
  constructors with mocks of the 'create_channel' utility function.

Closes #2389.
tseaver added a commit to googleapis/google-cloud-python that referenced this issue Nov 19, 2018
Includes fixes from these PRs:

- googleapis/gapic-generator#2407 (closing googleapis/gapic-generator#2389)
- googleapis/gapic-generator#2396 (for #5523 and dupes).

Includes changes to generated tests.

Closes #6502.
tseaver added a commit to googleapis/google-cloud-python that referenced this issue Nov 19, 2018
Includes fixes from these PRs:

- googleapis/gapic-generator#2407 (closing googleapis/gapic-generator#2389)
- googleapis/gapic-generator#2396 (for #5523 and dupes).

Includes changes to *all* generated tests.

Removes now-spurious docstring fixups.

Closes #6507.
tseaver added a commit to googleapis/google-cloud-python that referenced this issue Nov 19, 2018
Includes fixes from these PRs:

- googleapis/gapic-generator#2407 (closing googleapis/gapic-generator#2389)
- googleapis/gapic-generator#2396 (for #5523 and dupes).

Includes changes to generated tests.

Removes now-spurious docstring fixups.

Closes #6511.
tseaver added a commit to googleapis/google-cloud-python that referenced this issue Nov 19, 2018
Includes fixes from these PRs:

- googleapis/gapic-generator#2407 (closing googleapis/gapic-generator#2389)
- googleapis/gapic-generator#2396 (for #5523 and dupes).

Includes changes to generated tests.

Closes #6512.
busunkim96 pushed a commit to googleapis/python-videointelligence that referenced this issue Dec 19, 2019
Includes fixes from these PRs:

- googleapis/gapic-generator#2407 (closing googleapis/gapic-generator#2389)
- googleapis/gapic-generator#2396 (for #5523 and dupes).

Includes changes to generated tests.

Closes #6512.
crwilcox pushed a commit to googleapis/python-spanner that referenced this issue Jan 31, 2020
Includes fixes from these PRs:

- googleapis/gapic-generator#2407 (closing googleapis/gapic-generator#2389)
- googleapis/gapic-generator#2396 (for #5523 and dupes).

Includes changes to *all* generated tests.

Removes now-spurious docstring fixups.

Closes #6507.
crwilcox pushed a commit to googleapis/python-trace that referenced this issue Feb 1, 2020
Includes fixes from these PRs:

- googleapis/gapic-generator#2407 (closing googleapis/gapic-generator#2389)
- googleapis/gapic-generator#2396 (for #5523 and dupes).

Includes changes to generated tests.

Removes now-spurious docstring fixups.

Closes #6511.
busunkim96 pushed a commit to googleapis/python-oslogin that referenced this issue Feb 5, 2020
Includes fixes from these PRs:

- googleapis/gapic-generator#2407 (closing googleapis/gapic-generator#2389)
- googleapis/gapic-generator#2396 (for #5523 and dupes).

Includes changes to generated tests.

Closes #6502.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lang: python Issues specific to Python. priority: p2 Moderately-important priority. Fix may not be included in next release. Test type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. yoshi
Projects
None yet
Development

No branches or pull requests

2 participants