From f957e2b04c9844ec849ffab07f8a1a5f10f753ff Mon Sep 17 00:00:00 2001 From: Jay Date: Fri, 21 Nov 2014 16:34:19 +0530 Subject: [PATCH] Added a test for model pre/post_init signals. --- tests/signals/tests.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/signals/tests.py b/tests/signals/tests.py index c5c5b9c5e7..560fd6e8d3 100644 --- a/tests/signals/tests.py +++ b/tests/signals/tests.py @@ -32,6 +32,20 @@ class BaseSignalTest(TestCase): class SignalTests(BaseSignalTest): + def test_model_pre_init_and_post_init(self): + data = [] + + def pre_init_callback(sender, args, **kwargs): + data.append(kwargs['kwargs']) + signals.pre_init.connect(pre_init_callback) + + def post_init_callback(sender, instance, **kwargs): + data.append(instance) + signals.post_init.connect(post_init_callback) + + p1 = Person(first_name="John", last_name="Doe") + self.assertEqual(data, [{}, p1]) + def test_save_signals(self): data = []