Example #1
0
def run_test(handler):
    in_data, out_data = test_utils.get_dataset()
    global_is_equal_flag = True
    global_msg = ""
    for test_name in in_data:
        hypothesis = handler(in_data[test_name], RANDOM_SEED)
        print(f"test name: {test_name}")
        is_equal_flag, msg = test_utils.compare_structs(
            out_data[test_name],
            hypothesis,
            ignored_keys=["id", "used_phrases"])
        if msg and len(msg.split("`")) == 5:
            _, ground_truth_text, _, hypothesis_text, _ = msg.split("`")
            is_equal_flag, ratio = test_utils.compare_text(
                ground_truth_text, hypothesis_text, 0.80)
            if not is_equal_flag:
                msg = f"{msg} ratio = {ratio}"
        # assert is_equal_flag, msg
        if is_equal_flag:
            print("Success")
        else:
            print(is_equal_flag, msg)
            global_msg += f"\nFailed test_name: {test_name} <-> msg: {msg}"
            global_is_equal_flag = False
    assert global_is_equal_flag, global_msg
Example #2
0
def run_test(handler):
    in_data, out_data = test_utils.get_dataset()
    for test_name in in_data:
        hypothesis = handler(in_data[test_name])
        print(f"test name: {test_name}")
        is_equal_flag, msg = test_utils.compare_structs(
            out_data[test_name], hypothesis)
        assert is_equal_flag, msg
        print("Success")
Example #3
0
def run_test(handler):
    in_data, out_data = test_utils.get_dataset()
    for test_name in in_data:
        hypothesis = handler(in_data[test_name], RANDOM_SEED)
        print(f"test name: {test_name}")
        is_equal_flag, msg = test_utils.compare_structs(out_data[test_name], hypothesis, ignored_keys=["id"])
        if msg and len(msg.split("`")) == 5:
            _, ground_truth_text, _, hypothesis_text, _ = msg.split("`")
            is_equal_flag, ratio = test_utils.compare_text(ground_truth_text, hypothesis_text, 0.80)
            if not is_equal_flag:
                msg = f"{msg} ratio = {ratio}"
        assert is_equal_flag, msg
        print("Success")