FINISH flake8ing
diff --git a/OpenSSL/test/test_ssl.py b/OpenSSL/test/test_ssl.py
index f35a36e..55a4015 100644
--- a/OpenSSL/test/test_ssl.py
+++ b/OpenSSL/test/test_ssl.py
@@ -3050,16 +3050,16 @@
server.sendall(buffer(b('x')))
self.assertEquals(client.recv(1), b('x'))
-
def test_long(self):
"""
- :py:obj:`Connection.sendall` transmits all of the bytes in the string passed to
- it even if this requires multiple calls of an underlying write function.
+ :py:obj:`Connection.sendall` transmits all of the bytes in the string
+ passed to it even if this requires multiple calls of an underlying
+ write function.
"""
server, client = self._loopback()
# Should be enough, underlying SSL_write should only do 16k at a time.
- # On Windows, after 32k of bytes the write will block (forever - because
- # no one is yet reading).
+ # On Windows, after 32k of bytes the write will block (forever
+ # - because no one is yet reading).
message = b('x') * (1024 * 32 - 1) + b('y')
server.sendall(message)
accum = []
@@ -3070,11 +3070,10 @@
received += len(data)
self.assertEquals(message, b('').join(accum))
-
def test_closed(self):
"""
- If the underlying socket is closed, :py:obj:`Connection.sendall` propagates the
- write error from the low level write call.
+ If the underlying socket is closed, :py:obj:`Connection.sendall`
+ propagates the write error from the low level write call.
"""
server, client = self._loopback()
server.sock_shutdown(2)
@@ -3085,38 +3084,34 @@
self.assertEqual(exc.args[0], EPIPE)
-
class ConnectionRenegotiateTests(TestCase, _LoopbackMixin):
"""
Tests for SSL renegotiation APIs.
"""
def test_renegotiate_wrong_args(self):
"""
- :py:obj:`Connection.renegotiate` raises :py:obj:`TypeError` if called with any
- arguments.
+ :py:obj:`Connection.renegotiate` raises :py:obj:`TypeError` if called
+ with any arguments.
"""
connection = Connection(Context(TLSv1_METHOD), None)
self.assertRaises(TypeError, connection.renegotiate, None)
-
def test_total_renegotiations_wrong_args(self):
"""
- :py:obj:`Connection.total_renegotiations` raises :py:obj:`TypeError` if called with
- any arguments.
+ :py:obj:`Connection.total_renegotiations` raises :py:obj:`TypeError` if
+ called with any arguments.
"""
connection = Connection(Context(TLSv1_METHOD), None)
self.assertRaises(TypeError, connection.total_renegotiations, None)
-
def test_total_renegotiations(self):
"""
- :py:obj:`Connection.total_renegotiations` returns :py:obj:`0` before any
- renegotiations have happened.
+ :py:obj:`Connection.total_renegotiations` returns :py:obj:`0` before
+ any renegotiations have happened.
"""
connection = Connection(Context(TLSv1_METHOD), None)
self.assertEquals(connection.total_renegotiations(), 0)
-
# def test_renegotiate(self):
# """
# """
@@ -3137,8 +3132,6 @@
# self.assertEquals(server.total_renegotiations(), 1)
-
-
class ErrorTests(TestCase):
"""
Unit tests for :py:obj:`OpenSSL.SSL.Error`.
@@ -3151,7 +3144,6 @@
self.assertEqual(Error.__name__, 'Error')
-
class ConstantsTests(TestCase):
"""
Tests for the values of constants exposed in :py:obj:`OpenSSL.SSL`.
@@ -3160,50 +3152,52 @@
OpenSSL APIs. The only assertions it seems can be made about them is
their values.
"""
- # unittest.TestCase has no skip mechanism
- if OP_NO_QUERY_MTU is not None:
- def test_op_no_query_mtu(self):
- """
- The value of :py:obj:`OpenSSL.SSL.OP_NO_QUERY_MTU` is 0x1000, the value of
- :py:const:`SSL_OP_NO_QUERY_MTU` defined by :file:`openssl/ssl.h`.
- """
- self.assertEqual(OP_NO_QUERY_MTU, 0x1000)
- else:
- "OP_NO_QUERY_MTU unavailable - OpenSSL version may be too old"
+ @pytest.mark.skipif(
+ OP_NO_QUERY_MTU is None,
+ reason="OP_NO_QUERY_MTU unavailable - OpenSSL version may be too old"
+ )
+ def test_op_no_query_mtu(self):
+ """
+ The value of :py:obj:`OpenSSL.SSL.OP_NO_QUERY_MTU` is 0x1000, the value
+ of :py:const:`SSL_OP_NO_QUERY_MTU` defined by :file:`openssl/ssl.h`.
+ """
+ self.assertEqual(OP_NO_QUERY_MTU, 0x1000)
+ @pytest.mark.skipif(
+ OP_COOKIE_EXCHANGE is None,
+ reason="OP_COOKIE_EXCHANGE unavailable - "
+ "OpenSSL version may be too old"
+ )
+ def test_op_cookie_exchange(self):
+ """
+ The value of :py:obj:`OpenSSL.SSL.OP_COOKIE_EXCHANGE` is 0x2000, the
+ value of :py:const:`SSL_OP_COOKIE_EXCHANGE` defined by
+ :file:`openssl/ssl.h`.
+ """
+ self.assertEqual(OP_COOKIE_EXCHANGE, 0x2000)
- if OP_COOKIE_EXCHANGE is not None:
- def test_op_cookie_exchange(self):
- """
- The value of :py:obj:`OpenSSL.SSL.OP_COOKIE_EXCHANGE` is 0x2000, the value
- of :py:const:`SSL_OP_COOKIE_EXCHANGE` defined by :file:`openssl/ssl.h`.
- """
- self.assertEqual(OP_COOKIE_EXCHANGE, 0x2000)
- else:
- "OP_COOKIE_EXCHANGE unavailable - OpenSSL version may be too old"
+ @pytest.mark.skipif(
+ OP_NO_TICKET is None,
+ reason="OP_NO_TICKET unavailable - OpenSSL version may be too old"
+ )
+ def test_op_no_ticket(self):
+ """
+ The value of :py:obj:`OpenSSL.SSL.OP_NO_TICKET` is 0x4000, the value of
+ :py:const:`SSL_OP_NO_TICKET` defined by :file:`openssl/ssl.h`.
+ """
+ self.assertEqual(OP_NO_TICKET, 0x4000)
-
- if OP_NO_TICKET is not None:
- def test_op_no_ticket(self):
- """
- The value of :py:obj:`OpenSSL.SSL.OP_NO_TICKET` is 0x4000, the value of
- :py:const:`SSL_OP_NO_TICKET` defined by :file:`openssl/ssl.h`.
- """
- self.assertEqual(OP_NO_TICKET, 0x4000)
- else:
- "OP_NO_TICKET unavailable - OpenSSL version may be too old"
-
-
- if OP_NO_COMPRESSION is not None:
- def test_op_no_compression(self):
- """
- The value of :py:obj:`OpenSSL.SSL.OP_NO_COMPRESSION` is 0x20000, the value
- of :py:const:`SSL_OP_NO_COMPRESSION` defined by :file:`openssl/ssl.h`.
- """
- self.assertEqual(OP_NO_COMPRESSION, 0x20000)
- else:
- "OP_NO_COMPRESSION unavailable - OpenSSL version may be too old"
-
+ @pytest.mark.skipif(
+ OP_NO_COMPRESSION is None,
+ reason="OP_NO_COMPRESSION unavailable - OpenSSL version may be too old"
+ )
+ def test_op_no_compression(self):
+ """
+ The value of :py:obj:`OpenSSL.SSL.OP_NO_COMPRESSION` is 0x20000, the
+ value of :py:const:`SSL_OP_NO_COMPRESSION` defined by
+ :file:`openssl/ssl.h`.
+ """
+ self.assertEqual(OP_NO_COMPRESSION, 0x20000)
def test_sess_cache_off(self):
"""
@@ -3212,7 +3206,6 @@
"""
self.assertEqual(0x0, SESS_CACHE_OFF)
-
def test_sess_cache_client(self):
"""
The value of :py:obj:`OpenSSL.SSL.SESS_CACHE_CLIENT` 0x1, the value of
@@ -3220,7 +3213,6 @@
"""
self.assertEqual(0x1, SESS_CACHE_CLIENT)
-
def test_sess_cache_server(self):
"""
The value of :py:obj:`OpenSSL.SSL.SESS_CACHE_SERVER` 0x2, the value of
@@ -3228,7 +3220,6 @@
"""
self.assertEqual(0x2, SESS_CACHE_SERVER)
-
def test_sess_cache_both(self):
"""
The value of :py:obj:`OpenSSL.SSL.SESS_CACHE_BOTH` 0x3, the value of
@@ -3236,7 +3227,6 @@
"""
self.assertEqual(0x3, SESS_CACHE_BOTH)
-
def test_sess_cache_no_auto_clear(self):
"""
The value of :py:obj:`OpenSSL.SSL.SESS_CACHE_NO_AUTO_CLEAR` 0x80, the
@@ -3245,7 +3235,6 @@
"""
self.assertEqual(0x80, SESS_CACHE_NO_AUTO_CLEAR)
-
def test_sess_cache_no_internal_lookup(self):
"""
The value of :py:obj:`OpenSSL.SSL.SESS_CACHE_NO_INTERNAL_LOOKUP` 0x100,
@@ -3254,7 +3243,6 @@
"""
self.assertEqual(0x100, SESS_CACHE_NO_INTERNAL_LOOKUP)
-
def test_sess_cache_no_internal_store(self):
"""
The value of :py:obj:`OpenSSL.SSL.SESS_CACHE_NO_INTERNAL_STORE` 0x200,
@@ -3263,7 +3251,6 @@
"""
self.assertEqual(0x200, SESS_CACHE_NO_INTERNAL_STORE)
-
def test_sess_cache_no_internal(self):
"""
The value of :py:obj:`OpenSSL.SSL.SESS_CACHE_NO_INTERNAL` 0x300, the
@@ -3273,7 +3260,6 @@
self.assertEqual(0x300, SESS_CACHE_NO_INTERNAL)
-
class MemoryBIOTests(TestCase, _LoopbackMixin):
"""
Tests for :py:obj:`OpenSSL.SSL.Connection` using a memory BIO.
@@ -3287,19 +3273,23 @@
# - use TLSv1, use a particular certificate, etc.
server_ctx = Context(TLSv1_METHOD)
server_ctx.set_options(OP_NO_SSLv2 | OP_NO_SSLv3 | OP_SINGLE_DH_USE)
- server_ctx.set_verify(VERIFY_PEER | VERIFY_FAIL_IF_NO_PEER_CERT | VERIFY_CLIENT_ONCE, verify_cb)
+ server_ctx.set_verify(
+ VERIFY_PEER | VERIFY_FAIL_IF_NO_PEER_CERT | VERIFY_CLIENT_ONCE,
+ verify_cb
+ )
server_store = server_ctx.get_cert_store()
- server_ctx.use_privatekey(load_privatekey(FILETYPE_PEM, server_key_pem))
- server_ctx.use_certificate(load_certificate(FILETYPE_PEM, server_cert_pem))
+ server_ctx.use_privatekey(
+ load_privatekey(FILETYPE_PEM, server_key_pem))
+ server_ctx.use_certificate(
+ load_certificate(FILETYPE_PEM, server_cert_pem))
server_ctx.check_privatekey()
server_store.add_cert(load_certificate(FILETYPE_PEM, root_cert_pem))
- # Here the Connection is actually created. If None is passed as the 2nd
- # parameter, it indicates a memory BIO should be created.
+ # Here the Connection is actually created. If None is passed as the
+ # 2nd parameter, it indicates a memory BIO should be created.
server_conn = Connection(server_ctx, sock)
server_conn.set_accept_state()
return server_conn
-
def _client(self, sock):
"""
Create a new client-side SSL :py:obj:`Connection` object wrapped around
@@ -3309,23 +3299,27 @@
# above.
client_ctx = Context(TLSv1_METHOD)
client_ctx.set_options(OP_NO_SSLv2 | OP_NO_SSLv3 | OP_SINGLE_DH_USE)
- client_ctx.set_verify(VERIFY_PEER | VERIFY_FAIL_IF_NO_PEER_CERT | VERIFY_CLIENT_ONCE, verify_cb)
+ client_ctx.set_verify(
+ VERIFY_PEER | VERIFY_FAIL_IF_NO_PEER_CERT | VERIFY_CLIENT_ONCE,
+ verify_cb
+ )
client_store = client_ctx.get_cert_store()
- client_ctx.use_privatekey(load_privatekey(FILETYPE_PEM, client_key_pem))
- client_ctx.use_certificate(load_certificate(FILETYPE_PEM, client_cert_pem))
+ client_ctx.use_privatekey(
+ load_privatekey(FILETYPE_PEM, client_key_pem))
+ client_ctx.use_certificate(
+ load_certificate(FILETYPE_PEM, client_cert_pem))
client_ctx.check_privatekey()
client_store.add_cert(load_certificate(FILETYPE_PEM, root_cert_pem))
client_conn = Connection(client_ctx, sock)
client_conn.set_connect_state()
return client_conn
-
def test_memoryConnect(self):
"""
- Two :py:obj:`Connection`s which use memory BIOs can be manually connected by
- reading from the output of each and writing those bytes to the input of
- the other and in this way establish a connection and exchange
- application-level bytes with each other.
+ Two :py:obj:`Connection`s which use memory BIOs can be manually
+ connected by reading from the output of each and writing those bytes to
+ the input of the other and in this way establish a connection and
+ exchange application-level bytes with each other.
"""
server_conn = self._server(None)
client_conn = self._client(None)
@@ -3345,10 +3339,14 @@
self.assertNotIdentical(server_conn.master_key(), None)
self.assertNotIdentical(server_conn.client_random(), None)
self.assertNotIdentical(server_conn.server_random(), None)
- self.assertEquals(server_conn.client_random(), client_conn.client_random())
- self.assertEquals(server_conn.server_random(), client_conn.server_random())
- self.assertNotEquals(server_conn.client_random(), server_conn.server_random())
- self.assertNotEquals(client_conn.client_random(), client_conn.server_random())
+ self.assertEquals(
+ server_conn.client_random(), client_conn.client_random())
+ self.assertEquals(
+ server_conn.server_random(), client_conn.server_random())
+ self.assertNotEquals(
+ server_conn.client_random(), server_conn.server_random())
+ self.assertNotEquals(
+ client_conn.client_random(), client_conn.server_random())
# Here are the bytes we'll try to send.
important_message = b('One if by land, two if by sea.')
@@ -3363,16 +3361,15 @@
self._interactInMemory(client_conn, server_conn),
(server_conn, important_message[::-1]))
-
def test_socketConnect(self):
"""
Just like :py:obj:`test_memoryConnect` but with an actual socket.
- This is primarily to rule out the memory BIO code as the source of
- any problems encountered while passing data over a :py:obj:`Connection` (if
- this test fails, there must be a problem outside the memory BIO
- code, as no memory BIO is involved here). Even though this isn't a
- memory BIO test, it's convenient to have it here.
+ This is primarily to rule out the memory BIO code as the source of any
+ problems encountered while passing data over a :py:obj:`Connection` (if
+ this test fails, there must be a problem outside the memory BIO code,
+ as no memory BIO is involved here). Even though this isn't a memory
+ BIO test, it's convenient to have it here.
"""
server_conn, client_conn = self._loopback()
@@ -3387,11 +3384,11 @@
msg = client_conn.recv(1024)
self.assertEqual(msg, important_message)
-
def test_socketOverridesMemory(self):
"""
- Test that :py:obj:`OpenSSL.SSL.bio_read` and :py:obj:`OpenSSL.SSL.bio_write` don't
- work on :py:obj:`OpenSSL.SSL.Connection`() that use sockets.
+ Test that :py:obj:`OpenSSL.SSL.bio_read` and
+ :py:obj:`OpenSSL.SSL.bio_write` don't work on
+ :py:obj:`OpenSSL.SSL.Connection`() that use sockets.
"""
context = Context(SSLv3_METHOD)
client = socket()
@@ -3400,13 +3397,12 @@
self.assertRaises(TypeError, clientSSL.bio_write, "foo")
self.assertRaises(TypeError, clientSSL.bio_shutdown)
-
def test_outgoingOverflow(self):
"""
If more bytes than can be written to the memory BIO are passed to
- :py:obj:`Connection.send` at once, the number of bytes which were written is
- returned and that many bytes from the beginning of the input can be
- read from the other end of the connection.
+ :py:obj:`Connection.send` at once, the number of bytes which were
+ written is returned and that many bytes from the beginning of the input
+ can be read from the other end of the connection.
"""
server = self._server(None)
client = self._client(None)
@@ -3427,11 +3423,10 @@
# _loopback passes 2 ** 16 to recv - more than 2 ** 15.
self.assertEquals(len(received), sent)
-
def test_shutdown(self):
"""
- :py:obj:`Connection.bio_shutdown` signals the end of the data stream from
- which the :py:obj:`Connection` reads.
+ :py:obj:`Connection.bio_shutdown` signals the end of the data stream
+ from which the :py:obj:`Connection` reads.
"""
server = self._server(None)
server.bio_shutdown()
@@ -3440,7 +3435,6 @@
# handshake failure.
self.assertEquals(e.__class__, Error)
-
def test_unexpectedEndOfFile(self):
"""
If the connection is lost before an orderly SSL shutdown occurs,
@@ -3452,17 +3446,17 @@
exc = self.assertRaises(SysCallError, server_conn.recv, 1024)
self.assertEqual(exc.args, (-1, "Unexpected EOF"))
-
def _check_client_ca_list(self, func):
"""
- Verify the return value of the :py:obj:`get_client_ca_list` method for server and client connections.
+ Verify the return value of the :py:obj:`get_client_ca_list` method for
+ server and client connections.
:param func: A function which will be called with the server context
before the client and server are connected to each other. This
function should specify a list of CAs for the server to send to the
client and return that same list. The list will be used to verify
- that :py:obj:`get_client_ca_list` returns the proper value at various
- times.
+ that :py:obj:`get_client_ca_list` returns the proper value at
+ various times.
"""
server = self._server(None)
client = self._client(None)
@@ -3476,52 +3470,50 @@
self.assertEqual(client.get_client_ca_list(), expected)
self.assertEqual(server.get_client_ca_list(), expected)
-
def test_set_client_ca_list_errors(self):
"""
- :py:obj:`Context.set_client_ca_list` raises a :py:obj:`TypeError` if called with a
- non-list or a list that contains objects other than X509Names.
+ :py:obj:`Context.set_client_ca_list` raises a :py:obj:`TypeError` if
+ called with a non-list or a list that contains objects other than
+ X509Names.
"""
ctx = Context(TLSv1_METHOD)
self.assertRaises(TypeError, ctx.set_client_ca_list, "spam")
self.assertRaises(TypeError, ctx.set_client_ca_list, ["spam"])
self.assertIdentical(ctx.set_client_ca_list([]), None)
-
def test_set_empty_ca_list(self):
"""
- If passed an empty list, :py:obj:`Context.set_client_ca_list` configures the
- context to send no CA names to the client and, on both the server and
- client sides, :py:obj:`Connection.get_client_ca_list` returns an empty list
- after the connection is set up.
+ If passed an empty list, :py:obj:`Context.set_client_ca_list`
+ configures the context to send no CA names to the client and, on both
+ the server and client sides, :py:obj:`Connection.get_client_ca_list`
+ returns an empty list after the connection is set up.
"""
def no_ca(ctx):
ctx.set_client_ca_list([])
return []
self._check_client_ca_list(no_ca)
-
def test_set_one_ca_list(self):
"""
If passed a list containing a single X509Name,
- :py:obj:`Context.set_client_ca_list` configures the context to send that CA
- name to the client and, on both the server and client sides,
+ :py:obj:`Context.set_client_ca_list` configures the context to send
+ that CA name to the client and, on both the server and client sides,
:py:obj:`Connection.get_client_ca_list` returns a list containing that
X509Name after the connection is set up.
"""
cacert = load_certificate(FILETYPE_PEM, root_cert_pem)
cadesc = cacert.get_subject()
+
def single_ca(ctx):
ctx.set_client_ca_list([cadesc])
return [cadesc]
self._check_client_ca_list(single_ca)
-
def test_set_multiple_ca_list(self):
"""
If passed a list containing multiple X509Name objects,
- :py:obj:`Context.set_client_ca_list` configures the context to send those CA
- names to the client and, on both the server and client sides,
+ :py:obj:`Context.set_client_ca_list` configures the context to send
+ those CA names to the client and, on both the server and client sides,
:py:obj:`Connection.get_client_ca_list` returns a list containing those
X509Names after the connection is set up.
"""
@@ -3537,12 +3529,11 @@
return L
self._check_client_ca_list(multiple_ca)
-
def test_reset_ca_list(self):
"""
If called multiple times, only the X509Names passed to the final call
- of :py:obj:`Context.set_client_ca_list` are used to configure the CA names
- sent to the client.
+ of :py:obj:`Context.set_client_ca_list` are used to configure the CA
+ names sent to the client.
"""
cacert = load_certificate(FILETYPE_PEM, root_cert_pem)
secert = load_certificate(FILETYPE_PEM, server_cert_pem)
@@ -3558,7 +3549,6 @@
return [cadesc]
self._check_client_ca_list(changed_ca)
-
def test_mutated_ca_list(self):
"""
If the list passed to :py:obj:`Context.set_client_ca_list` is mutated
@@ -3578,11 +3568,10 @@
return [cadesc]
self._check_client_ca_list(mutated_ca)
-
def test_add_client_ca_errors(self):
"""
- :py:obj:`Context.add_client_ca` raises :py:obj:`TypeError` if called with a non-X509
- object or with a number of arguments other than one.
+ :py:obj:`Context.add_client_ca` raises :py:obj:`TypeError` if called
+ with a non-X509 object or with a number of arguments other than one.
"""
ctx = Context(TLSv1_METHOD)
cacert = load_certificate(FILETYPE_PEM, root_cert_pem)
@@ -3590,7 +3579,6 @@
self.assertRaises(TypeError, ctx.add_client_ca, "spam")
self.assertRaises(TypeError, ctx.add_client_ca, cacert, cacert)
-
def test_one_add_client_ca(self):
"""
A certificate's subject can be added as a CA to be sent to the client
@@ -3598,12 +3586,12 @@
"""
cacert = load_certificate(FILETYPE_PEM, root_cert_pem)
cadesc = cacert.get_subject()
+
def single_ca(ctx):
ctx.add_client_ca(cacert)
return [cadesc]
self._check_client_ca_list(single_ca)
-
def test_multiple_add_client_ca(self):
"""
Multiple CA names can be sent to the client by calling
@@ -3621,12 +3609,11 @@
return [cadesc, sedesc]
self._check_client_ca_list(multiple_ca)
-
def test_set_and_add_client_ca(self):
"""
A call to :py:obj:`Context.set_client_ca_list` followed by a call to
- :py:obj:`Context.add_client_ca` results in using the CA names from the first
- call and the CA name from the second call.
+ :py:obj:`Context.add_client_ca` results in using the CA names from the
+ first call and the CA name from the second call.
"""
cacert = load_certificate(FILETYPE_PEM, root_cert_pem)
secert = load_certificate(FILETYPE_PEM, server_cert_pem)
@@ -3642,12 +3629,11 @@
return [cadesc, sedesc, cldesc]
self._check_client_ca_list(mixed_set_add_ca)
-
def test_set_after_add_client_ca(self):
"""
A call to :py:obj:`Context.set_client_ca_list` after a call to
- :py:obj:`Context.add_client_ca` replaces the CA name specified by the former
- call with the names specified by the latter cal.
+ :py:obj:`Context.add_client_ca` replaces the CA name specified by the
+ former call with the names specified by the latter call.
"""
cacert = load_certificate(FILETYPE_PEM, root_cert_pem)
secert = load_certificate(FILETYPE_PEM, server_cert_pem)
@@ -3664,21 +3650,20 @@
self._check_client_ca_list(set_replaces_add_ca)
-
class ConnectionBIOTests(TestCase):
"""
Tests for :py:obj:`Connection.bio_read` and :py:obj:`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.
+ :py:obj:`Connection.bio_read` raises
+ :py:obj:`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)
-
def test_buffer_size(self):
"""
:py:obj:`Connection.bio_read` accepts an integer giving the maximum
@@ -3694,24 +3679,21 @@
data = conn.bio_read(2)
self.assertEqual(2, len(data))
-
- if not 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`.
- """
- ctx = Context(TLSv1_METHOD)
- conn = Connection(ctx, None)
- conn.set_connect_state()
- try:
- conn.do_handshake()
- except WantReadError:
- pass
- data = conn.bio_read(long(2))
- self.assertEqual(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`.
+ """
+ ctx = Context(TLSv1_METHOD)
+ conn = Connection(ctx, None)
+ conn.set_connect_state()
+ try:
+ conn.do_handshake()
+ except WantReadError:
+ pass
+ data = conn.bio_read(long(2))
+ self.assertEqual(2, len(data))
class InfoConstantTests(TestCase):
@@ -3732,8 +3714,8 @@
SSL_CB_LOOP, SSL_CB_EXIT, SSL_CB_READ, SSL_CB_WRITE, SSL_CB_ALERT,
SSL_CB_READ_ALERT, SSL_CB_WRITE_ALERT, SSL_CB_ACCEPT_LOOP,
SSL_CB_ACCEPT_EXIT, SSL_CB_CONNECT_LOOP, SSL_CB_CONNECT_EXIT,
- SSL_CB_HANDSHAKE_START, SSL_CB_HANDSHAKE_DONE]:
-
+ SSL_CB_HANDSHAKE_START, SSL_CB_HANDSHAKE_DONE
+ ]:
self.assertTrue(isinstance(const, int))