def test_on_success_is_called_after_successful_pass(self): numbers_list = [] with transaction_signals(): on_success(lambda: add_number(numbers_list, 0)) assert_equal(len(numbers_list), 0) assert_equal(len(numbers_list), 1)
def test_on_success_is_not_called_after_not_successful_pass(self): numbers_list = [] try: with transaction_signals(): on_success(lambda: add_number(numbers_list, 0)) assert_equal(len(numbers_list), 0) raise Exception() except Exception: pass assert_equal(len(numbers_list), 0)
def test_on_success_inheritance(self): numbers_list = [] with transaction_signals(): with transaction_signals(): on_success(lambda: add_number(numbers_list, 0)) assert_equal(len(numbers_list), 0) assert_equal(len(numbers_list), 0) try: with transaction_signals(): on_success(lambda: add_number(numbers_list, 1)) assert_equal(len(numbers_list), 0) raise Exception() except Exception: pass on_success(lambda: add_number(numbers_list, 2)) assert_equal(len(numbers_list), 0) assert_equal(numbers_list, [0, 2])
def _handle(self, instance, **kwargs): on_success(InstanceOneTimeOnSuccessHandlerCallable(self, instance), using=self.using)
def _handle(self, instance, **kwargs): on_success(lambda: self.handle(instance, **kwargs), using=self.using)