Skip to content

tests: Don't mock received_message_hashes

aszlig requested to merge (removed):fix-connection-mock into gajim_0.16

This fixes the following two test cases from TestChatControlSession in test/unit/test_sessions.py:

  • test_receive_1nocontrol
  • test_receive_2already_has_control

The MockConnection object already defines various attributes from the real Connection object to their corresponding types so that calling code is able to for example iterate on dicts or lists.

Since 40a3f80a, there exists a new received_message_hashes attribute, which is expected to be a list but the default Mock object doesn't define an __iter__ method.

So this leads to the following exception:

Traceback (most recent call last):
  File ".../share/gajim/src/common/ged.py", line 93, in raise_event
    if handler(*args, **kwargs):
  File ".../share/gajim/src/common/connection_handlers.py", line 1137, in _nec_message_received
    conn=self, msg_obj=obj))
  File ".../share/gajim/src/common/nec.py", line 74, in push_incoming_event
    if event_object.generate():
  File ".../share/gajim/src/common/connection_handlers_events.py", line 1468, in generate
    if self.msghash in self.conn.received_message_hashes:
TypeError: argument of type 'instance' is not iterable

Defining received_message_hashes to be a list fixes this.

Merge request reports