def _test_assertex(self, global_env): if not self.setting.assertex_list: if self.exception is not None: # assertexが設定されずに例外が起きた場合はそのまま上に投げる raise self.exception else: # assertexが設定されずに例外も起きない場合は何もしない return else: # assertex が設定されたが、例外が起きていない場合 if self.exception is None: raise AssertionFailed("Exception not raised", [{"got": "exception not exists", "expect": "Exception"}], 0) wrap_exception = wrap(self.exception.original, self.cmp_log) variables = dict(global_env) variables.update({ "ex": wrap_exception, "this": wrap(self.__dict__, self.cmp_log)}) for assert_index, assert_str in enumerate(self.setting.assertex_list): self.cmp_log.clear() if not assert_test(assert_str, variables): raise AssertionFailed(assert_str, self.cmp_log.log_list, assert_index)
def _test_assert(self, global_env): if not self.setting.assert_list: return variables = dict(global_env) variables.update({ "res": wrap(self.result, self.cmp_log), "this": wrap(self.__dict__, self.cmp_log)}) for assert_index, assert_str in enumerate(self.setting.assert_list): self.cmp_log.clear() if not assert_test(assert_str, variables): raise AssertionFailed(assert_str, self.cmp_log.log_list, assert_index)