Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: unit test failures in https://github.com/googleapis/python-pubsu… #1074

Merged
merged 1 commit into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@ filterwarnings =
ignore:There is no current event loop:DeprecationWarning:grpc.aio._channel
# 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 warning once https://github.com/googleapis/python-pubsub/issues/1067 is fixed
ignore:The return_immediately flag is deprecated and should be set to False.:DeprecationWarning
# Remove warning once https://github.com/googleapis/gapic-generator-python/issues/1938 is fixed
ignore:The return_immediately flag is deprecated and should be set to False.:DeprecationWarning
# Remove warning once https://github.com/googleapis/gapic-generator-python/issues/1939 is fixed
ignore:get_mtls_endpoint_and_cert_source is deprecated.:DeprecationWarning
parthea marked this conversation as resolved.
Show resolved Hide resolved
10 changes: 1 addition & 9 deletions tests/unit/pubsub_v1/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,8 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import sys

import google.auth.credentials

# special case python < 3.8
if sys.version_info.major == 3 and sys.version_info.minor < 8:
import mock
else:
from unittest import mock

import pytest


Expand All @@ -30,4 +22,4 @@ def creds():
Provide test creds to unit tests so that they can run without
GOOGLE_APPLICATION_CREDENTIALS set.
"""
yield mock.Mock(spec=google.auth.credentials.Credentials)
yield google.auth.credentials.AnonymousCredentials()
9 changes: 1 addition & 8 deletions tests/unit/pubsub_v1/publisher/batch/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,7 @@
# limitations under the License.

from __future__ import absolute_import
import sys

# special case python < 3.8
if sys.version_info.major == 3 and sys.version_info.minor < 8:
import mock
else:
from unittest import mock

from google.auth import credentials
from google.cloud.pubsub_v1 import publisher
Expand All @@ -38,8 +32,7 @@ def create_batch(status, settings=types.BatchSettings()):
Returns:
~.pubsub_v1.publisher.batch.thread.Batch: The batch object
"""
creds = mock.Mock(spec=credentials.Credentials)
client = publisher.Client(credentials=creds)
client = publisher.Client(credentials=credentials.AnonymousCredentials())
batch = Batch(client, "topic_name", settings)
batch._status = status
return batch
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/pubsub_v1/publisher/batch/test_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@


def create_client():
creds = mock.Mock(spec=credentials.Credentials)
return publisher.Client(credentials=creds)
return publisher.Client(credentials=credentials.AnonymousCredentials())


def create_batch(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ def create_message():


def create_client():
creds = mock.Mock(spec=credentials.Credentials)
return publisher.Client(credentials=creds)
return publisher.Client(credentials=credentials.AnonymousCredentials())


def create_ordered_sequencer(client):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ def create_message():


def create_client():
creds = mock.Mock(spec=credentials.Credentials)
return publisher.Client(credentials=creds)
return publisher.Client(credentials=credentials.AnonymousCredentials())


def test_stop():
Expand Down