celery / kombu

Messaging library for Python.
http://kombu.readthedocs.org/
BSD 3-Clause "New" or "Revised" License
2.81k stars 920 forks source link

test_etcd.py skipped and gives error when enabled #2001

Closed FrankK-1234 closed 1 month ago

FrankK-1234 commented 1 month ago

Hi, I'm new with kombu and tried to run the tests via tox (python 3.12). I saw and investigated why etcd is skipped.

The message I saw was: SKIPPED [1] t/unit/transport/test_etcd.py:11: could not import 'etcd': No module named 'etcd'

This is because the module etcd is not in de tox requirements (never added?). A requirements file does exists in requirements/extras/etcd.txt. So added it to (what I think is the most logical file) requirements/test-ci.txt, with '-r extras/etcd.txt'

That resulted in test_etcd being executed however with error on self.patch.

self = <t.unit.transport.test_etcd.test_Etcd object at 0x7f17cdb983e0>

    def setup_method(self):
        self.connection = Mock()
        self.connection.client.transport_options = {}
        self.connection.client.port = 2739
>       self.client = self.patch('etcd.Client').return_value
E       AttributeError: 'test_Etcd' object has no attribute 'patch'

t/unit/transport/test_etcd.py:19: AttributeError

Looking at the code changes it might (not sure) not have been working since it was ported to pytest: Port etcd tests to py.test. I assume the old class 'Case' implemented the patch function.

After changing the patch to patching and the connection setup similar to test_consul.py it passed the test.

I'll prepare and propose a pull request (also my first time).