Skip to content

Commit 4a466b9

Browse files
authored
fix: Fix signal test failures in Django 5.2. (#37193)
1 parent 5a7bae6 commit 4a466b9

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

common/test/utils.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,14 @@ def assert_signal_sent(self, module, signal, *args, **kwargs):
8585
8686
"""
8787
with patch.object(module, signal, new=Signal()) as mock_signal:
88-
def handler(*args, **kwargs): # pylint: disable=unused-argument
88+
mock_handler = Mock()
89+
# Wrap the mock in a real callable so inspect.iscoroutinefunction() works
90+
91+
def handler(*h_args, **h_kwargs):
8992
"""No-op signal handler."""
90-
pass # lint-amnesty, pylint: disable=unnecessary-pass
91-
mock_handler = Mock(spec=handler)
92-
mock_signal.connect(mock_handler)
93+
return mock_handler(*h_args, **h_kwargs)
94+
95+
mock_signal.connect(handler)
9396
yield
9497
assert mock_handler.called
9598
mock_args, mock_kwargs = mock_handler.call_args

0 commit comments

Comments
 (0)