From c2ead35519209329715aab1754422b4d1c7e4f26 Mon Sep 17 00:00:00 2001 From: None Date: Tue, 10 Mar 2026 11:17:41 -0500 Subject: [PATCH] Move test_wait_for_redis.py call Moved inline so mock data is not overwritten --- tests/test_wait_for_redis.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/test_wait_for_redis.py b/tests/test_wait_for_redis.py index 0dd02ba1..82616848 100644 --- a/tests/test_wait_for_redis.py +++ b/tests/test_wait_for_redis.py @@ -40,9 +40,8 @@ class WaitForRedisTests(SimpleTestCase): self.assertTrue(result) mock_client.flushdb.assert_called_once() - @patch('wait_for_redis._flush_non_celery_keys') @patch('wait_for_redis.redis.Redis') - def test_modular_mode_does_not_call_flushdb(self, mock_redis_cls, mock_selective): + def test_modular_mode_does_not_call_flushdb(self, mock_redis_cls): """In modular mode, flushdb must NOT be called — selective flush instead.""" mock_client = MagicMock() mock_client.ping.return_value = True @@ -50,7 +49,9 @@ class WaitForRedisTests(SimpleTestCase): with patch.dict(os.environ, {'DISPATCHARR_ENV': 'modular'}): wait_for_redis = _import_wait_for_redis() - result = wait_for_redis(max_retries=1, retry_interval=0) + # Patch after reload so the mock isn't overwritten by module re-execution + with patch('wait_for_redis._flush_non_celery_keys') as mock_selective: + result = wait_for_redis(max_retries=1, retry_interval=0) self.assertTrue(result) mock_client.flushdb.assert_not_called()