[tests] implement explicit type checks for 'len:'
for example 'len:dict:3' to check for a dict with 3 items
This commit is contained in:
@@ -272,8 +272,11 @@ class TestExtractorResults(unittest.TestCase):
|
|||||||
elif test.startswith("type:"):
|
elif test.startswith("type:"):
|
||||||
self.assertEqual(test[5:], type(value).__name__, msg=path)
|
self.assertEqual(test[5:], type(value).__name__, msg=path)
|
||||||
elif test.startswith("len:"):
|
elif test.startswith("len:"):
|
||||||
self.assertIsInstance(value, (list, tuple), msg=path)
|
cls, _, length = test[4:].rpartition(":")
|
||||||
self.assertEqual(int(test[4:]), len(value), msg=path)
|
if cls:
|
||||||
|
self.assertEqual(
|
||||||
|
cls, type(value).__name__, msg=path + "/type")
|
||||||
|
self.assertEqual(int(length), len(value), msg=path)
|
||||||
else:
|
else:
|
||||||
self.assertEqual(test, value, msg=path)
|
self.assertEqual(test, value, msg=path)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user