Skip to content

Commit 7f4ebda

Browse files
committed
消除空白行
1 parent fd8e712 commit 7f4ebda

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

scripts/test.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ def general_test(test_files: list[pathlib.Path], preprocess_fn, run_fn, compare_
7979

8080

8181
def compare(test_result_file: pathlib.Path, output_file: pathlib.Path):
82-
def convert_to_float(text):
82+
83+
def is_not_empty_line(text: str):
84+
return len(text.strip()) > 0
85+
86+
def convert_to_float(text: str):
8387
try:
8488
val = float(text)
8589
except ValueError:
@@ -88,9 +92,11 @@ def convert_to_float(text):
8892
return val
8993

9094
with open(test_result_file, "r") as f:
91-
test_results = map(convert_to_float, f.readlines())
95+
test_results = map(convert_to_float, filter(is_not_empty_line, f.readlines()))
9296
with open(output_file, "r") as f:
93-
expected_results = map(convert_to_float, f.readlines())
97+
expected_results = map(
98+
convert_to_float, filter(is_not_empty_line, f.readlines())
99+
)
94100

95101
is_success = True
96102
try:

0 commit comments

Comments
 (0)