summaryrefslogtreecommitdiff
path: root/tests/util.py
diff options
context:
space:
mode:
authorAlex Chan <alex@alexwlchan.net>2016-11-18 13:53:39 +0000
committerHynek Schlawack <hs@ox.cx>2016-11-18 14:53:39 +0100
commitc60770699be48e9c3f3b4f542c8a4118be2936ab (patch)
tree9231d6ea9232d3eaeeb8db170d62b5ac2ad4d371 /tests/util.py
parentec1e32d37cfc6c7be469a4b7c1c28448312362c2 (diff)
downloadpyopenssl-c60770699be48e9c3f3b4f542c8a4118be2936ab.tar.gz
Convert X509ExtTests to use pytest-style tests (#564)
Diffstat (limited to 'tests/util.py')
-rw-r--r--tests/util.py24
1 files changed, 20 insertions, 4 deletions
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 @@ class TestCase(TestCase):
: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):