From 214331093535f865698b4a6f5fe177a978252b01 Mon Sep 17 00:00:00 2001 From: Jarek Potiuk Date: Sat, 25 Apr 2026 19:26:51 +0200 Subject: [PATCH] Fix Celery worker test mocking real broker after hostname-check refactor `TestWorkerStart::test_worker_started_with_required_arguments` passes `--celery-hostname`, which now hits the throwaway `Celery()` app introduced in #65826. Without mocking that constructor, the test tried to open a real broker connection and failed with `Connection refused` in CI. Patch `Celery` (and `kombu.pools.reset`) the same way the sibling `TestWorkerDuplicateHostnameCheck` tests do. --- .../celery/tests/unit/celery/cli/test_celery_command.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/providers/celery/tests/unit/celery/cli/test_celery_command.py b/providers/celery/tests/unit/celery/cli/test_celery_command.py index a14cadfee1528..99a9506f3d625 100644 --- a/providers/celery/tests/unit/celery/cli/test_celery_command.py +++ b/providers/celery/tests/unit/celery/cli/test_celery_command.py @@ -139,11 +139,15 @@ def setup_class(cls): importlib.reload(cli_parser) cls.parser = cli_parser.get_parser() + @mock.patch("airflow.providers.celery.cli.celery_command.kombu.pools.reset") + @mock.patch("airflow.providers.celery.cli.celery_command.Celery") @mock.patch("airflow.providers.celery.cli.celery_command.setup_locations") @mock.patch("airflow.providers.celery.cli.celery_command.Process") @mock.patch("airflow.providers.celery.executors.celery_executor.app") @conf_vars({("celery", "pool"): "prefork"}) - def test_worker_started_with_required_arguments(self, mock_celery_app, mock_popen, mock_locations): + def test_worker_started_with_required_arguments( + self, mock_celery_app, mock_popen, mock_locations, mock_celery_cls, mock_pools_reset + ): pid_file = "pid_file" mock_locations.return_value = (pid_file, None, None, None) concurrency = "1"