Blame 0003-fix-handle-cases-where-either-actual-or-expected-are.patch

d5a43eb
From e808fae1e0306f457273f325b9f92f20b5396b05 Mon Sep 17 00:00:00 2001
d5a43eb
From: "Ankur Sinha (Ankur Sinha Gmail)" <sanjay.ankur@gmail.com>
d5a43eb
Date: Tue, 6 Jul 2021 14:32:01 +0100
d5a43eb
Subject: [PATCH 3/3] fix: handle cases where either actual or expected are
d5a43eb
 None
d5a43eb
d5a43eb
In this case, the len() function throws a TypeError.
d5a43eb
---
d5a43eb
 tests/helper_functions/__init__.py | 10 +++++++++-
d5a43eb
 1 file changed, 9 insertions(+), 1 deletion(-)
d5a43eb
d5a43eb
diff --git a/tests/helper_functions/__init__.py b/tests/helper_functions/__init__.py
d5a43eb
index 9ef10a7..29815b3 100644
d5a43eb
--- a/tests/helper_functions/__init__.py
d5a43eb
+++ b/tests/helper_functions/__init__.py
d5a43eb
@@ -61,8 +61,16 @@ def assertDeepAlmostEqual(expected, actual, *args, **kwargs):
d5a43eb
             if isinstance(expected, types.GeneratorType):
d5a43eb
                 expected = list(expected)
d5a43eb
                 actual = list(actual)
d5a43eb
+            # if any of them are None, len(None) throws a TypeError
d5a43eb
+            try:
d5a43eb
+                assert len(expected) == len(actual)
d5a43eb
+            except TypeError:
d5a43eb
+                # if both are None, they are equal
d5a43eb
+                if not expected and not actual:
d5a43eb
+                    pass
d5a43eb
+                else:
d5a43eb
+                    raise AssertionError
d5a43eb
 
d5a43eb
-            assert len(expected) == len(actual)
d5a43eb
             for index in range(len(expected)):
d5a43eb
                 v1, v2 = expected[index], actual[index]
d5a43eb
                 assertDeepAlmostEqual(v1, v2,
d5a43eb
-- 
d5a43eb
2.31.1
d5a43eb