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_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):