Added a test for model pre/post_init signals.
This commit is contained in:
parent
f1783ee479
commit
f957e2b04c
|
@ -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 = []
|
||||
|
||||
|
|
Loading…
Reference in New Issue