allow type tests by name

This commit is contained in:
Mike Fährmann 2019-04-29 17:27:59 +02:00
parent df7cdb648a
commit 5018781898
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

View File

@ -119,8 +119,13 @@ class TestExtractorResults(unittest.TestCase):
self._test_kwdict(value, test)
elif isinstance(test, type):
self.assertIsInstance(value, test, msg=key)
elif isinstance(test, str) and test.startswith("re:"):
self.assertRegex(value, test[3:], msg=key)
elif isinstance(test, str):
if test.startswith("re:"):
self.assertRegex(value, test[3:], msg=key)
elif test.startswith("type:"):
self.assertEqual(type(value).__name__, test[5:], msg=key)
else:
self.assertEqual(value, test, msg=key)
else:
self.assertEqual(value, test, msg=key)