mirror of
https://github.com/django/django.git
synced 2024-12-23 09:36:06 +00:00
25 lines
649 B
Python
25 lines
649 B
Python
import warnings
|
|
|
|
from django.dispatch import Signal
|
|
from django.test import SimpleTestCase
|
|
|
|
a_signal = Signal(providing_args=['val'])
|
|
|
|
|
|
def receiver_1_arg(val, **kwargs):
|
|
return val
|
|
|
|
|
|
class DispatcherTests(SimpleTestCase):
|
|
|
|
def test_disconnect_weak_deprecated(self):
|
|
a_signal.connect(receiver_1_arg)
|
|
with warnings.catch_warnings(record=True) as warns:
|
|
warnings.simplefilter('always')
|
|
a_signal.disconnect(receiver_1_arg, weak=True)
|
|
self.assertEqual(len(warns), 1)
|
|
self.assertEqual(
|
|
str(warns[0].message),
|
|
'Passing `weak` to disconnect has no effect.',
|
|
)
|