Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
added recursive list/tuple normalization to tests (#2023)
added recursive list/tuple normalization to tests
  • Loading branch information
invisig0th committed Dec 24, 2020
1 parent 3ffc030 commit 6cfd873
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions synapse/tests/utils.py
Expand Up @@ -75,6 +75,13 @@
async def alist(coro):
return [x async for x in coro]

def norm(z):
if isinstance(z, (list, tuple)):
return tuple([norm(n) for n in z])
if isinstance(z, dict):
return {norm(k): norm(v) for (k, v) in z.items()}
return z

class LibTst(s_stormtypes.Lib):

def addLibFuncs(self):
Expand Down Expand Up @@ -1476,13 +1483,7 @@ def eq(self, x, y, msg=None):
'''
Assert X is equal to Y
'''
if type(x) == list:
x = tuple(x)

if type(y) == list:
y = tuple(y)

self.assertEqual(x, y, msg=msg)
self.assertEqual(norm(x), norm(y), msg=msg)

def eqOrNan(self, x, y, msg=None):
'''
Expand All @@ -1504,7 +1505,7 @@ def ne(self, x, y):
'''
Assert X is not equal to Y
'''
self.assertNotEqual(x, y)
self.assertNotEqual(norm(x), norm(y))

def true(self, x, msg=None):
'''
Expand Down

0 comments on commit 6cfd873

Please sign in to comment.