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