From 3f0641214946d7042a24397eb3862743dbcd58c1 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Wed, 25 Jan 2023 02:17:50 +0300 Subject: mechanical-rob: Fix bugs with corrs test * Replace CRLF in html output with newline to prevent equality comparisons from failing if that's the only difference. * Only include failures that have actual content: filter out empty failure items * Print out an extra newline on completion of checks --- test/requests/correlation_tests.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'test/requests') diff --git a/test/requests/correlation_tests.py b/test/requests/correlation_tests.py index ac1565e6..8c7fc29f 100644 --- a/test/requests/correlation_tests.py +++ b/test/requests/correlation_tests.py @@ -145,7 +145,8 @@ def parse_results_from_html(raw_html): str(row["trait_id"]): row for row in json.loads(thread( script_content, - lambda val: val[len("var tableJson = "):].strip()))} + lambda val: val[len("var tableJson = "):].strip().replace( + "\\r\\n", "\\n")))} return {} @@ -178,10 +179,12 @@ def collect_failures(actual, expected, keys): return __eq return tuple( - __equal(str(exp_row["Record"]), - actual.get(str(exp_row["Record"])), - exp_row) - for exp_row in expected) + item for item in ( + __equal(str(exp_row["Record"]), + actual.get(str(exp_row["Record"])), + exp_row) + for exp_row in expected) + if bool(item)) def check_correctness(host): # pearsons_keys = ( @@ -247,9 +250,11 @@ def check_correctness(host): filepath = Path.cwd().parent.joinpath( f"test/requests/correlation_results_text_files/{expected_file}") failures = { - **failures, - test_title: collect_failures( - results, tuple(parse_expected(filepath)), method_keys) + key: value for key,value in { + **failures, + test_title: collect_failures( + results, tuple(parse_expected(filepath)), method_keys) + }.items() if len(value) > 0 } if len(failures) > 0: @@ -262,6 +267,7 @@ def check_correctness(host): print_newline = True if len(result_failures) > 0: print("") + print("") return False return True -- cgit v1.2.3