From 9d5772901dd4158897577fbfb4baa3b53dec80ff Mon Sep 17 00:00:00 2001 From: Peter Bieringer Date: Sat, 23 Aug 2025 07:28:35 +0200 Subject: [PATCH] run rabbitmq tests only if module pika is available --- radicale/tests/test_hook_rabbitmq.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/radicale/tests/test_hook_rabbitmq.py b/radicale/tests/test_hook_rabbitmq.py index 42cedfce..a50dfaa2 100644 --- a/radicale/tests/test_hook_rabbitmq.py +++ b/radicale/tests/test_hook_rabbitmq.py @@ -21,6 +21,7 @@ Radicale tests related to hook 'rabbitmq' import logging import os +import pytest from radicale.tests import BaseTest from radicale.tests.helpers import get_file_content @@ -29,6 +30,14 @@ from radicale.tests.helpers import get_file_content class TestHooks(BaseTest): """Tests with hooks.""" + # test for available pika module + try: + import pika + except ImportError: + has_pika = 0 + else: + has_pika = 1 + def setup_method(self) -> None: BaseTest.setup_method(self) rights_file_path = os.path.join(self.colpath, "rights") @@ -63,6 +72,7 @@ permissions: RrWw""") self.configure({"hook": {"type": "rabbitmq", "dryrun": "True"}}) + @pytest.mark.skipif(has_pika == 0, reason="No pika module installed") def test_add_event(self, caplog) -> None: caplog.set_level(logging.WARNING) """Add an event.""" @@ -83,6 +93,7 @@ permissions: RrWw""") if (found is False): raise ValueError("Logging misses expected log line") + @pytest.mark.skipif(has_pika == 0, reason="No pika module installed") def test_delete_event(self, caplog) -> None: caplog.set_level(logging.WARNING) """Delete an event."""