File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed
Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change 22import subprocess
33from collections import namedtuple
44from contextlib import contextmanager
5+ from unittest .mock import patch
56from urllib .parse import urlparse
67
78import freezegun
@@ -267,13 +268,14 @@ def set_config_values(app, dict):
267268
268269@contextmanager
269270def _with_message_group_id (task , value ):
270- """Simulate broker having set message_group_id on the task"""
271- task .message_group_id = value
272- try :
271+ """Simulate broker having set message_group_id on the task.
272+
273+ Patches at class level so it works when message_group_id is a read-only
274+ property (e.g. from Celery SQS transport in CI).
275+ """
276+ real_task = task ._get_current_object () if hasattr (task , "_get_current_object" ) else task
277+ with patch .object (type (real_task ), "message_group_id" , value , create = True ):
273278 yield
274- finally :
275- if hasattr (task , "message_group_id" ):
276- del task .message_group_id
277279
278280
279281class Matcher :
You can’t perform that action at this time.
0 commit comments