From 3b958af172dc1f85a3660c06f352eecfc4d68d4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20M=C3=BCller?= Date: Fri, 21 Jul 2023 15:50:08 +0200 Subject: [PATCH] tests: handle float in repr --- tests/helper.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/tests/helper.py b/tests/helper.py index b7719fd..18979a0 100644 --- a/tests/helper.py +++ b/tests/helper.py @@ -8,11 +8,19 @@ def assert_equal_dump_no_whitespace_no_byte(data_a, data_b): def repl(x): - return x.replace( - " ", "").replace( - "b'", "'").replace( - "\n", "").replace( - "float32", "'>f4'") + for old, new in [ + [" ", ""], # ignore whitespaces + ["b'", "'"], # ignore bytes vs str + ["\n", ""], # ignore newlines + # teat all floats as equal + ["float32", "float"], + ["float64", "float"], + ["'>f4'", "float"], + ["'>f8'", "float"], + ]: + x = x.replace(old, new) + return x + a = repl(data_a) b = repl(data_b) print("DBUG data_a: ", a)