Skip to content
This repository was archived by the owner on Mar 9, 2026. It is now read-only.
This repository was archived by the owner on Mar 9, 2026. It is now read-only.

test_resume_publish failed with mock==5.0.1 #840

Description

@parthea

See build failure here.

Stack trace

_____________________________ test_resume_publish ______________________________

creds = <Mock spec='Credentials' id='1406[34](https://github.com/googleapis/python-pubsub/actions/runs/3876452107/jobs/6610366435#step:5:35)993473040'>

    def test_resume_publish(creds):
        publisher_options = types.PublisherOptions(enable_message_ordering=True)
        client = publisher.Client(publisher_options=publisher_options, credentials=creds)
    
        topic = "topic"
        ordering_key = "ord_key"
        sequencer = mock.Mock(spec=ordered_sequencer.OrderedSequencer)
        client._set_sequencer(topic=topic, sequencer=sequencer, ordering_key=ordering_key)
    
        client.resume_publish(topic, ordering_key)
>       assert sequencer.unpause.called_once()

tests/unit/pubsub_v1/publisher/test_publisher_client.py:639: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <Mock name='mock.unpause' id='1406[35](https://github.com/googleapis/python-pubsub/actions/runs/3876452107/jobs/6610366435#step:5:36)0020[41](https://github.com/googleapis/python-pubsub/actions/runs/3876452107/jobs/6610366435#step:5:42)[48](https://github.com/googleapis/python-pubsub/actions/runs/3876452107/jobs/6610366435#step:5:49)8'>, name = 'called_once'

    def __getattr__(self, name):
        if name in {'_mock_methods', '_mock_unsafe'}:
            raise AttributeError(name)
        elif self._mock_methods is not None:
            if name not in self._mock_methods or name in _all_magics:
                raise AttributeError("Mock object has no attribute %r" % name)
        elif _is_magic(name):
            raise AttributeError(name)
        if not self._mock_unsafe and (not self._mock_methods or name not in self._mock_methods):
            if name.startswith(('assert', 'assret', 'asert', 'aseert', 'assrt')) or name in _ATTRIB_DENY_LIST:
                raise AttributeError(
>                   f"{name!r} is not a valid assertion. Use a spec "
                    f"for the mock if {name!r} is meant to be an attribute.")
E               AttributeError: 'called_once' is not a valid assertion. Use a spec for the mock if 'called_once' is meant to be an attribute.

.nox/unit-3-7/lib/python3.7/site-packages/mock/mock.py:6[61](https://github.com/googleapis/python-pubsub/actions/runs/3876452107/jobs/6610366435#step:5:62): AttributeError

Metadata

Metadata

Assignees

Labels

api: pubsubIssues related to the googleapis/python-pubsub API.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions