Skip to content

Commit bb72345

Browse files
committed
chore: test to see if CI tests pass with this
1 parent 91d6414 commit bb72345

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

tests/conftest.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import subprocess
33
from collections import namedtuple
44
from contextlib import contextmanager
5+
from unittest.mock import patch
56
from urllib.parse import urlparse
67

78
import freezegun
@@ -267,13 +268,14 @@ def set_config_values(app, dict):
267268

268269
@contextmanager
269270
def _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

279281
class Matcher:

0 commit comments

Comments
 (0)