def test_leaves_some_other_signals_alone(self): self.assertNotEqual(0, len(post_save.receivers)) old_pre_values = pre_save.receivers with NoReceivers(post_save): self.assertItemsEqual(old_pre_values, pre_save.receivers)
def test_clears_and_restores_signal(self): # post_save already has some receivers on it, but make sure. self.assertNotEqual(0, len(post_save.receivers)) old_values = list(post_save.receivers) with NoReceivers(post_save): self.assertEqual([], post_save.receivers) self.assertItemsEqual(old_values, post_save.receivers)
def test_clears_and_restores_many_signals(self): self.assertNotEqual(0, len(post_save.receivers)) self.assertNotEqual(0, len(pre_save.receivers)) old_pre_values = pre_save.receivers old_post_values = post_save.receivers with NoReceivers((post_save, pre_save)): self.assertEqual([], post_save.receivers) self.assertEqual([], pre_save.receivers) self.assertItemsEqual(old_pre_values, pre_save.receivers) self.assertItemsEqual(old_post_values, post_save.receivers)