diff --git a/tests/signals/tests.py b/tests/signals/tests.py index e0a24ccc6ea..ee4661c93fb 100644 --- a/tests/signals/tests.py +++ b/tests/signals/tests.py @@ -280,6 +280,31 @@ class SignalTests(BaseSignalSetup, TestCase): signals.pre_init.disconnect(callback) ref.assert_not_called() + @isolate_apps('signals', kwarg_name='apps') + def test_disconnect_model(self, apps): + received = [] + + def receiver(**kwargs): + received.append(kwargs) + + class Created(models.Model): + pass + + signals.post_init.connect(receiver, sender=Created, apps=apps) + try: + self.assertIs( + signals.post_init.disconnect(receiver, sender=Created, apps=apps), + True, + ) + self.assertIs( + signals.post_init.disconnect(receiver, sender=Created, apps=apps), + False, + ) + Created() + self.assertEqual(received, []) + finally: + signals.post_init.disconnect(receiver, sender=Created) + class LazyModelRefTests(BaseSignalSetup, SimpleTestCase): def setUp(self):