Convert X509ExtTests to use pytest-style tests (#564)
diff --git a/tests/util.py b/tests/util.py
index 2cab91f..7520a28 100644
--- a/tests/util.py
+++ b/tests/util.py
@@ -305,10 +305,26 @@
:param constructionArgs: Positional arguments to use with
:py:data:`theType` to create an instance of it.
"""
- self.assertEqual(theType.__name__, name)
- self.assertTrue(isinstance(theType, type))
- instance = theType(*constructionArgs)
- self.assertIdentical(type(instance), theType)
+ assert is_consistent_type(theType, name, *constructionArgs)
+
+
+def is_consistent_type(theType, name, *constructionArgs):
+ """
+ Perform various assertions about *theType* to ensure that it is a
+ well-defined type. This is useful for extension types, where it's
+ pretty easy to do something wacky. If something about the type is
+ unusual, an exception will be raised.
+
+ :param theType: The type object about which to make assertions.
+ :param name: A string giving the name of the type.
+ :param constructionArgs: Positional arguments to use with
+ *theType* to create an instance of it.
+ """
+ assert theType.__name__ == name
+ assert isinstance(theType, type)
+ instance = theType(*constructionArgs)
+ assert type(instance) is theType
+ return True
class EqualityTestsMixin(object):