Skip to content

Commit

Permalink
fix: unit test failures in https://github.com/googleapis/python-pubsu… (
Browse files Browse the repository at this point in the history
  • Loading branch information
mukund-ananthu committed Feb 8, 2024
1 parent bd0a3bf commit 3c6d128
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 25 deletions.
6 changes: 4 additions & 2 deletions pytest.ini
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
10 changes: 1 addition & 9 deletions tests/unit/pubsub_v1/conftest.py
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
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
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
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
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

0 comments on commit 3c6d128

Please sign in to comment.