summaryrefslogtreecommitdiff
path: root/tests/test_bio_ssl.py
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2018-03-18 23:11:38 +0100
committerMatěj Cepl <mcepl@cepl.eu>2018-03-20 18:47:23 +0100
commit17f7ca77afa75cedaa60bf3db767119adba4a2ec (patch)
tree0c4ff5f475bce84a3e7e88ab83b32dd38892066c /tests/test_bio_ssl.py
parentb977909fc93caa599e52943be25b7f6042a4c70b (diff)
downloadm2crypto-17f7ca77afa75cedaa60bf3db767119adba4a2ec.tar.gz
PEP8isation
Specially replace complicated construct with unittest2 to one import to M2Crypto top module. Also, Rand.load_file should have first parameter as bytes(), not str().
Diffstat (limited to 'tests/test_bio_ssl.py')
-rw-r--r--tests/test_bio_ssl.py25
1 files changed, 13 insertions, 12 deletions
diff --git a/tests/test_bio_ssl.py b/tests/test_bio_ssl.py
index 7e204a5..3d087b0 100644
--- a/tests/test_bio_ssl.py
+++ b/tests/test_bio_ssl.py
@@ -5,11 +5,9 @@ from __future__ import absolute_import, print_function
Copyright (c) 1999-2002 Ng Pheng Siong. All rights reserved."""
-import threading, sys, socket
-try:
- import unittest2 as unittest
-except ImportError:
- import unittest
+import socket
+import sys
+import threading
from M2Crypto import BIO
from M2Crypto import SSL
@@ -17,8 +15,10 @@ from M2Crypto import Err
from M2Crypto import Rand
from M2Crypto import threading as m2threading
+from tests import unittest
from tests.test_ssl import srv_host, allocate_srv_port
+
class HandshakeClient(threading.Thread):
def __init__(self, host, port):
@@ -49,12 +49,12 @@ class HandshakeClient(threading.Thread):
print(err_string)
sys.exit("unrecoverable error in handshake - client")
else:
- output_token = writebio.read()
- if output_token is not None:
- sock.sendall(output_token)
- else:
- input_token = sock.recv(1024)
- readbio.write(input_token)
+ output_token = writebio.read()
+ if output_token is not None:
+ sock.sendall(output_token)
+ else:
+ input_token = sock.recv(1024)
+ readbio.write(input_token)
else:
handshake_complete = True
@@ -125,7 +125,7 @@ class SSLTestCase(unittest.TestCase):
sock.listen(5)
handshake_client = HandshakeClient(srv_host, srv_port)
handshake_client.start()
- new_sock, addr = sock.accept()
+ new_sock, _ = sock.accept()
while not handshake_complete:
input_token = new_sock.recv(1024)
readbio.write(input_token)
@@ -145,6 +145,7 @@ class SSLTestCase(unittest.TestCase):
sock.close()
new_sock.close()
+
def suite():
return unittest.makeSuite(SSLTestCase)