Added a test for model pre/post_init signals.

This commit is contained in:
Jay 2014-11-21 16:34:19 +05:30 committed by Tim Graham
parent f1783ee479
commit f957e2b04c
1 changed files with 14 additions and 0 deletions

View File

@ -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 = []