Convert a few more small test classes to be pytest-style (#585)

* Rewrite test_tsafe to be pytest-style

* Rewrite TestRevoked to be pytest-style

* Convert TestConnection to be pytest-style
diff --git a/tests/test_crypto.py b/tests/test_crypto.py
index 710f737..49b9bad 100644
--- a/tests/test_crypto.py
+++ b/tests/test_crypto.py
@@ -3115,8 +3115,7 @@
 
 class TestRevoked(object):
     """
-    Please add test cases for the Revoked class here if possible. This class
-    holds the new py.test style tests.
+    Tests for `OpenSSL.crypto.Revoked`.
     """
     def test_ignores_unsupported_revoked_cert_extension_get_reason(self):
         """
@@ -3136,111 +3135,81 @@
         reason = revoked[1].get_reason()
         assert reason is None
 
-
-class RevokedTests(TestCase):
-    """
-    Tests for :py:obj:`OpenSSL.crypto.Revoked`. Please add test cases to
-    TestRevoked above if possible.
-    """
-
     def test_construction(self):
         """
-        Confirm we can create :py:obj:`OpenSSL.crypto.Revoked`.  Check
-        that it is empty.
+        Confirm we can create `OpenSSL.crypto.Revoked`.  Check that it is
+        empty.
         """
         revoked = Revoked()
-        self.assertTrue(isinstance(revoked, Revoked))
-        self.assertEquals(type(revoked), Revoked)
-        self.assertEquals(revoked.get_serial(), b'00')
-        self.assertEquals(revoked.get_rev_date(), None)
-        self.assertEquals(revoked.get_reason(), None)
-
-    def test_construction_wrong_args(self):
-        """
-        Calling :py:obj:`OpenSSL.crypto.Revoked` with any arguments results
-        in a :py:obj:`TypeError` being raised.
-        """
-        self.assertRaises(TypeError, Revoked, None)
-        self.assertRaises(TypeError, Revoked, 1)
-        self.assertRaises(TypeError, Revoked, "foo")
+        assert isinstance(revoked, Revoked)
+        assert type(revoked) == Revoked
+        assert revoked.get_serial() == b'00'
+        assert revoked.get_rev_date() is None
+        assert revoked.get_reason() is None
 
     def test_serial(self):
         """
         Confirm we can set and get serial numbers from
-        :py:obj:`OpenSSL.crypto.Revoked`.  Confirm errors are handled
-        with grace.
+        `OpenSSL.crypto.Revoked`.  Confirm errors are handled with grace.
         """
         revoked = Revoked()
         ret = revoked.set_serial(b'10b')
-        self.assertEquals(ret, None)
+        assert ret is None
         ser = revoked.get_serial()
-        self.assertEquals(ser, b'010B')
+        assert ser == b'010B'
 
         revoked.set_serial(b'31ppp')  # a type error would be nice
         ser = revoked.get_serial()
-        self.assertEquals(ser, b'31')
+        assert ser == b'31'
 
-        self.assertRaises(ValueError, revoked.set_serial, b'pqrst')
-        self.assertRaises(TypeError, revoked.set_serial, 100)
-        self.assertRaises(TypeError, revoked.get_serial, 1)
-        self.assertRaises(TypeError, revoked.get_serial, None)
-        self.assertRaises(TypeError, revoked.get_serial, "")
+        with pytest.raises(ValueError):
+            revoked.set_serial(b'pqrst')
+        with pytest.raises(TypeError):
+            revoked.set_serial(100)
 
     def test_date(self):
         """
         Confirm we can set and get revocation dates from
-        :py:obj:`OpenSSL.crypto.Revoked`.  Confirm errors are handled
-        with grace.
+        `OpenSSL.crypto.Revoked`.  Confirm errors are handled with grace.
         """
         revoked = Revoked()
         date = revoked.get_rev_date()
-        self.assertEquals(date, None)
+        assert date is None
 
         now = datetime.now().strftime("%Y%m%d%H%M%SZ").encode("ascii")
         ret = revoked.set_rev_date(now)
-        self.assertEqual(ret, None)
+        assert ret is None
         date = revoked.get_rev_date()
-        self.assertEqual(date, now)
+        assert date == now
 
     def test_reason(self):
         """
         Confirm we can set and get revocation reasons from
-        :py:obj:`OpenSSL.crypto.Revoked`.  The "get" need to work
-        as "set".  Likewise, each reason of all_reasons() must work.
+        `OpenSSL.crypto.Revoked`.  The "get" need to work as "set".
+        Likewise, each reason of all_reasons() must work.
         """
         revoked = Revoked()
         for r in revoked.all_reasons():
             for x in range(2):
                 ret = revoked.set_reason(r)
-                self.assertEquals(ret, None)
+                assert ret is None
                 reason = revoked.get_reason()
-                self.assertEquals(
-                    reason.lower().replace(b' ', b''),
+                assert (
+                    reason.lower().replace(b' ', b'') ==
                     r.lower().replace(b' ', b''))
                 r = reason  # again with the resp of get
 
         revoked.set_reason(None)
-        self.assertEqual(revoked.get_reason(), None)
+        assert revoked.get_reason() is None
 
-    def test_set_reason_wrong_arguments(self):
+    def test_set_reason_invalid_reason(self):
         """
-        Calling :py:obj:`OpenSSL.crypto.Revoked.set_reason` with other than
-        one argument, or an argument which isn't a valid reason,
-        results in :py:obj:`TypeError` or :py:obj:`ValueError` being raised.
+        Calling `OpenSSL.crypto.Revoked.set_reason` with an argument which
+        isn't a valid reason results in `ValueError` being raised.
         """
         revoked = Revoked()
-        self.assertRaises(TypeError, revoked.set_reason, 100)
-        self.assertRaises(ValueError, revoked.set_reason, b'blue')
-
-    def test_get_reason_wrong_arguments(self):
-        """
-        Calling :py:obj:`OpenSSL.crypto.Revoked.get_reason` with any
-        arguments results in :py:obj:`TypeError` being raised.
-        """
-        revoked = Revoked()
-        self.assertRaises(TypeError, revoked.get_reason, None)
-        self.assertRaises(TypeError, revoked.get_reason, 1)
-        self.assertRaises(TypeError, revoked.get_reason, "foo")
+        with pytest.raises(ValueError):
+            revoked.set_reason(b'blue')
 
 
 class CRLTests(TestCase):
diff --git a/tests/test_ssl.py b/tests/test_ssl.py
index ee849fd..c32ebab 100644
--- a/tests/test_ssl.py
+++ b/tests/test_ssl.py
@@ -3729,24 +3729,24 @@
         self._check_client_ca_list(set_replaces_add_ca)
 
 
-class ConnectionBIOTests(TestCase):
+class TestConnection(object):
     """
-    Tests for :py:obj:`Connection.bio_read` and :py:obj:`Connection.bio_write`.
+    Tests for `Connection.bio_read` and `Connection.bio_write`.
     """
     def test_wantReadError(self):
         """
-        :py:obj:`Connection.bio_read` raises
-        :py:obj:`OpenSSL.SSL.WantReadError` if there are no bytes available to
-        be read from the BIO.
+        `Connection.bio_read` raises `OpenSSL.SSL.WantReadError` if there are
+        no bytes available to be read from the BIO.
         """
         ctx = Context(TLSv1_METHOD)
         conn = Connection(ctx, None)
-        self.assertRaises(WantReadError, conn.bio_read, 1024)
+        with pytest.raises(WantReadError):
+            conn.bio_read(1024)
 
     def test_buffer_size(self):
         """
-        :py:obj:`Connection.bio_read` accepts an integer giving the maximum
-        number of bytes to read and return.
+        `Connection.bio_read` accepts an integer giving the maximum number
+        of bytes to read and return.
         """
         ctx = Context(TLSv1_METHOD)
         conn = Connection(ctx, None)
@@ -3756,13 +3756,13 @@
         except WantReadError:
             pass
         data = conn.bio_read(2)
-        self.assertEqual(2, len(data))
+        assert 2 == len(data)
 
     @skip_if_py3
     def test_buffer_size_long(self):
         """
-        On Python 2 :py:obj:`Connection.bio_read` accepts values of type
-        :py:obj:`long` as well as :py:obj:`int`.
+        On Python 2 `Connection.bio_read` accepts values of type `long` as
+        well as `int`.
         """
         ctx = Context(TLSv1_METHOD)
         conn = Connection(ctx, None)
@@ -3772,7 +3772,7 @@
         except WantReadError:
             pass
         data = conn.bio_read(long(2))
-        self.assertEqual(2, len(data))
+        assert 2 == len(data)
 
 
 class InfoConstantTests(TestCase):
diff --git a/tests/test_tsafe.py b/tests/test_tsafe.py
index 97045ce..8ffe35a 100644
--- a/tests/test_tsafe.py
+++ b/tests/test_tsafe.py
@@ -2,22 +2,20 @@
 # See LICENSE for details.
 
 """
-Unit tests for :py:obj:`OpenSSL.tsafe`.
+Unit tests for `OpenSSL.tsafe`.
 """
 
 from OpenSSL.SSL import TLSv1_METHOD, Context
 from OpenSSL.tsafe import Connection
 
-from .util import TestCase
 
-
-class ConnectionTest(TestCase):
+class TestConnection(object):
     """
-    Tests for :py:obj:`OpenSSL.tsafe.Connection`.
+    Tests for `OpenSSL.tsafe.Connection`.
     """
     def test_instantiation(self):
         """
-        :py:obj:`OpenSSL.tsafe.Connection` can be instantiated.
+        `OpenSSL.tsafe.Connection` can be instantiated.
         """
         # The following line should not throw an error.  This isn't an ideal
         # test.  It would be great to refactor the other Connection tests so