diff options
44 files changed, 185 insertions, 107 deletions
diff --git a/M2Crypto/ASN1.py b/M2Crypto/ASN1.py index f826f86..10c047a 100644 --- a/M2Crypto/ASN1.py +++ b/M2Crypto/ASN1.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + """ M2Crypto wrapper for OpenSSL ASN1 API. @@ -9,8 +11,8 @@ Copyright (C) 2005 OSAF. All Rights Reserved. import time, datetime -import BIO -import m2 +from . import BIO +from . import m2 MBSTRING_FLAG = 0x1000 MBSTRING_ASC = MBSTRING_FLAG | 1 diff --git a/M2Crypto/AuthCookie.py b/M2Crypto/AuthCookie.py index 399f34b..ef1efea 100644 --- a/M2Crypto/AuthCookie.py +++ b/M2Crypto/AuthCookie.py @@ -1,9 +1,11 @@ +from __future__ import absolute_import + """Secure Authenticator Cookies Copyright (c) 1999-2002 Ng Pheng Siong. All rights reserved.""" # M2Crypto -import Rand, m2 +from . import Rand, m2 # Python. Cookie is bundled with Python 2.x. import Cookie, binascii, re, time diff --git a/M2Crypto/BIO.py b/M2Crypto/BIO.py index e777d72..03f8c57 100644 --- a/M2Crypto/BIO.py +++ b/M2Crypto/BIO.py @@ -1,12 +1,14 @@ +from __future__ import absolute_import + """M2Crypto wrapper for OpenSSL BIO API. Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved.""" -import m2 +from . import m2 from cStringIO import StringIO # Deprecated -from m2 import bio_do_handshake as bio_do_ssl_handshake # noqa +from .m2 import bio_do_handshake as bio_do_ssl_handshake class BIOError(Exception): diff --git a/M2Crypto/BN.py b/M2Crypto/BN.py index ac2a781..a515dc9 100755 --- a/M2Crypto/BN.py +++ b/M2Crypto/BN.py @@ -1,10 +1,12 @@ +from __future__ import absolute_import + """ M2Crypto wrapper for OpenSSL BN (BIGNUM) API. Copyright (c) 2005 Open Source Applications Foundation. All rights reserved. """ -import m2 +from . import m2 def rand(bits, top=-1, bottom=0): """ diff --git a/M2Crypto/DH.py b/M2Crypto/DH.py index 2de2cbf..60efaa0 100644 --- a/M2Crypto/DH.py +++ b/M2Crypto/DH.py @@ -1,9 +1,11 @@ +from __future__ import absolute_import + """M2Crypto wrapper for OpenSSL DH API. Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved.""" -from util import genparam_callback -import BIO, Err, m2 +from .util import genparam_callback +from . import BIO, Err, m2 class DHError(Exception): pass diff --git a/M2Crypto/DSA.py b/M2Crypto/DSA.py index 325e418..efa4859 100644 --- a/M2Crypto/DSA.py +++ b/M2Crypto/DSA.py @@ -1,4 +1,4 @@ -from __future__ import print_function +from __future__ import absolute_import, print_function """ M2Crypto wrapper for OpenSSL DSA API. @@ -10,7 +10,7 @@ from __future__ import print_function """ import sys -import util, BIO, m2 +from . import util, BIO, m2 class DSAError(Exception): pass diff --git a/M2Crypto/EC.py b/M2Crypto/EC.py index 800a705..f27a574 100644 --- a/M2Crypto/EC.py +++ b/M2Crypto/EC.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + """ M2Crypto wrapper for OpenSSL ECDH/ECDSA API. @@ -8,7 +10,7 @@ Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved. Portions copyright (c) 2005-2006 Vrije Universiteit Amsterdam. All rights reserved.""" -import util, BIO, m2 +from . import util, BIO, m2 class ECError(Exception): pass diff --git a/M2Crypto/EVP.py b/M2Crypto/EVP.py index 28303bd..53ff750 100644 --- a/M2Crypto/EVP.py +++ b/M2Crypto/EVP.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + """M2Crypto wrapper for OpenSSL EVP API. Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved. @@ -7,7 +9,7 @@ Author: Heikki Toivonen """ from M2Crypto import Err, util, BIO, RSA -import m2 +from . import m2 class EVPError(Exception): pass diff --git a/M2Crypto/Err.py b/M2Crypto/Err.py index b1e80c3..f34a998 100644 --- a/M2Crypto/Err.py +++ b/M2Crypto/Err.py @@ -1,9 +1,11 @@ +from __future__ import absolute_import + """M2Crypto wrapper for OpenSSL Error API. Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved.""" -import BIO -import m2 +from . import BIO +from . import m2 def get_error(): err = BIO.MemoryBuffer() diff --git a/M2Crypto/PGP/PublicKey.py b/M2Crypto/PGP/PublicKey.py index 290bc44..4c62afe 100644 --- a/M2Crypto/PGP/PublicKey.py +++ b/M2Crypto/PGP/PublicKey.py @@ -1,10 +1,12 @@ +from __future__ import absolute_import + """M2Crypto PGP2. Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved.""" -from constants import * -from packet import * -import RSA +from .constants import * +from .packet import * +from . import RSA class PublicKey: def __init__(self, pubkey_pkt): diff --git a/M2Crypto/PGP/PublicKeyRing.py b/M2Crypto/PGP/PublicKeyRing.py index 1a827f1..6294c46 100644 --- a/M2Crypto/PGP/PublicKeyRing.py +++ b/M2Crypto/PGP/PublicKeyRing.py @@ -1,10 +1,12 @@ +from __future__ import absolute_import + """M2Crypto PGP2. Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved.""" -from constants import * -from packet import * -from PublicKey import * +from .constants import * +from .packet import * +from .PublicKey import * class PublicKeyRing: def __init__(self, keyring): diff --git a/M2Crypto/PGP/__init__.py b/M2Crypto/PGP/__init__.py index 27fd669..9e4ed7a 100644 --- a/M2Crypto/PGP/__init__.py +++ b/M2Crypto/PGP/__init__.py @@ -1,14 +1,16 @@ +from __future__ import absolute_import + """M2Crypto PGP2. Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved.""" -from constants import * +from .constants import * -from packet import public_key_packet, trust_packet, userid_packet,\ +from .packet import public_key_packet, trust_packet, userid_packet,\ comment_packet, signature_packet, private_key_packet, cke_packet,\ pke_packet, literal_packet, packet_stream -from PublicKey import * -from PublicKeyRing import * +from .PublicKey import * +from .PublicKeyRing import * diff --git a/M2Crypto/PGP/packet.py b/M2Crypto/PGP/packet.py index 601312e..2f353f8 100644 --- a/M2Crypto/PGP/packet.py +++ b/M2Crypto/PGP/packet.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + """M2Crypto PGP2. This module implements PGP packets per RFC1991 and various source distributions. @@ -34,7 +36,7 @@ if sys.version_info > (3,): from M2Crypto import EVP, RSA from M2Crypto.util import octx_to_num -from constants import * +from .constants import * _OK_VERSION = ('\002', '\003') _OK_VALIDITY = ('\000',) diff --git a/M2Crypto/RC4.py b/M2Crypto/RC4.py index 64133b8..55d59c7 100644 --- a/M2Crypto/RC4.py +++ b/M2Crypto/RC4.py @@ -1,8 +1,10 @@ +from __future__ import absolute_import + """M2Crypto wrapper for OpenSSL RC4 API. Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved.""" -from m2 import rc4_new, rc4_free, rc4_set_key, rc4_update +from .m2 import rc4_new, rc4_free, rc4_set_key, rc4_update class RC4: diff --git a/M2Crypto/RSA.py b/M2Crypto/RSA.py index a395a3e..c193515 100644 --- a/M2Crypto/RSA.py +++ b/M2Crypto/RSA.py @@ -1,9 +1,11 @@ +from __future__ import absolute_import + """M2Crypto wrapper for OpenSSL RSA API. Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved.""" import sys -import util, BIO, Err, m2 +from . import util, BIO, Err, m2 class RSAError(Exception): pass diff --git a/M2Crypto/Rand.py b/M2Crypto/Rand.py index 6cf5eef..19fae3c 100644 --- a/M2Crypto/Rand.py +++ b/M2Crypto/Rand.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + """M2Crypto wrapper for OpenSSL PRNG. Requires OpenSSL 0.9.5 and above. Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved.""" @@ -5,7 +7,7 @@ Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved.""" __all__ = ['rand_seed', 'rand_add', 'load_file', 'save_file', 'rand_bytes', 'rand_pseudo_bytes'] -import m2 +from . import m2 rand_seed = m2.rand_seed rand_add = m2.rand_add diff --git a/M2Crypto/SMIME.py b/M2Crypto/SMIME.py index e624fe9..f906ab5 100644 --- a/M2Crypto/SMIME.py +++ b/M2Crypto/SMIME.py @@ -1,9 +1,11 @@ +from __future__ import absolute_import + """M2Crypto wrapper for OpenSSL S/MIME API. Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved.""" -import BIO, EVP, X509, Err, util -import m2 +from . import BIO, EVP, X509, Err, util +from . import m2 PKCS7_TEXT = m2.PKCS7_TEXT PKCS7_NOCERTS = m2.PKCS7_NOCERTS diff --git a/M2Crypto/SSL/Connection.py b/M2Crypto/SSL/Connection.py index f1eb8c3..5fc0bed 100644 --- a/M2Crypto/SSL/Connection.py +++ b/M2Crypto/SSL/Connection.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + """SSL Connection aka socket Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved. @@ -16,14 +18,14 @@ __all__ = ['Connection', import socket # M2Crypto -import Checker +from . import Checker -import timeout +from . import timeout -from Cipher import Cipher, Cipher_Stack +from .Cipher import Cipher, Cipher_Stack from M2Crypto import X509, m2 from M2Crypto.SSL import SSLError -from Session import Session +from .Session import Session #SSLError = getattr(__import__('M2Crypto.SSL', globals(), locals(), # 'SSLError'), 'SSLError') diff --git a/M2Crypto/SSL/Context.py b/M2Crypto/SSL/Context.py index 2dc0aea..d11d656 100644 --- a/M2Crypto/SSL/Context.py +++ b/M2Crypto/SSL/Context.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + """SSL Context Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved.""" @@ -6,7 +8,7 @@ __all__ = ['map', 'Context'] # M2Crypto -import cb +from . import cb import sys from M2Crypto import BIO, Err, RSA, X509, m2, util diff --git a/M2Crypto/SSL/SSLServer.py b/M2Crypto/SSL/SSLServer.py index 4d8132e..e5c408a 100644 --- a/M2Crypto/SSL/SSLServer.py +++ b/M2Crypto/SSL/SSLServer.py @@ -1,4 +1,4 @@ -from __future__ import print_function +from __future__ import absolute_import, print_function """SSLServer @@ -10,7 +10,7 @@ __all__ = ['SSLServer', 'ForkingSSLServer', 'ThreadingSSLServer'] import socket, SocketServer # M2Crypto -from Connection import Connection +from .Connection import Connection from M2Crypto.SSL import SSLError from M2Crypto import m2 diff --git a/M2Crypto/SSL/__init__.py b/M2Crypto/SSL/__init__.py index 00d4e54..abc7441 100644 --- a/M2Crypto/SSL/__init__.py +++ b/M2Crypto/SSL/__init__.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + """M2Crypto SSL services. Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved.""" @@ -12,12 +14,12 @@ class SSLTimeoutError(SSLError, socket.timeout): pass m2.ssl_init(SSLError, SSLTimeoutError) # M2Crypto.SSL -from Cipher import Cipher, Cipher_Stack -from Context import Context -from Connection import Connection -from SSLServer import SSLServer, ForkingSSLServer, ThreadingSSLServer -from ssl_dispatcher import ssl_dispatcher -from timeout import timeout +from .Cipher import Cipher, Cipher_Stack +from .Context import Context +from .Connection import Connection +from .SSLServer import SSLServer, ForkingSSLServer, ThreadingSSLServer +from .ssl_dispatcher import ssl_dispatcher +from .timeout import timeout verify_none = m2.SSL_VERIFY_NONE verify_peer = m2.SSL_VERIFY_PEER diff --git a/M2Crypto/SSL/cb.py b/M2Crypto/SSL/cb.py index 60f9dbd..d7204fd 100644 --- a/M2Crypto/SSL/cb.py +++ b/M2Crypto/SSL/cb.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + """SSL callbacks Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved.""" @@ -9,7 +11,6 @@ __all__ = ['unknown_issuer', 'ssl_verify_callback_stub', 'ssl_verify_callback', import sys # M2Crypto -import Context from M2Crypto import m2 def ssl_verify_callback_stub(ssl_ctx_ptr, x509_ptr, errnum, errdepth, ok): @@ -25,6 +26,7 @@ unknown_issuer = [ def ssl_verify_callback(ssl_ctx_ptr, x509_ptr, errnum, errdepth, ok): # Deprecated + from . import Context ssl_ctx = Context.map()[long(ssl_ctx_ptr)] if errnum in unknown_issuer: if ssl_ctx.get_allow_unknown_ca(): diff --git a/M2Crypto/SSL/ssl_dispatcher.py b/M2Crypto/SSL/ssl_dispatcher.py index 1e8c875..4c66cdb 100644 --- a/M2Crypto/SSL/ssl_dispatcher.py +++ b/M2Crypto/SSL/ssl_dispatcher.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + """SSL dispatcher Copyright (c) 1999-2002 Ng Pheng Siong. All rights reserved.""" @@ -8,7 +10,7 @@ __all__ = ['ssl_dispatcher'] import asyncore, socket # M2Crypto -from Connection import Connection +from .Connection import Connection from M2Crypto import Err, m2 diff --git a/M2Crypto/X509.py b/M2Crypto/X509.py index 62aa4ed..87566d5 100644 --- a/M2Crypto/X509.py +++ b/M2Crypto/X509.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + """M2Crypto wrapper for OpenSSL X509 API. Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved. @@ -9,6 +11,8 @@ Author: Heikki Toivonen # M2Crypto import binascii +from M2Crypto import ASN1, BIO, Err, EVP, util +from . import m2 import m2 diff --git a/M2Crypto/__init__.py b/M2Crypto/__init__.py index 4486918..2e7a732 100644 --- a/M2Crypto/__init__.py +++ b/M2Crypto/__init__.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + """ M2Crypto is the most complete Python wrapper for OpenSSL featuring RSA, DSA, DH, EC, HMACs, message digests, symmetric ciphers (including AES); SSL @@ -21,37 +23,35 @@ __version__ = '0.23.0' version = __version__ version_info = StrictVersion(__version__).version -import _m2crypto -import m2 -import ASN1 -import AuthCookie -import BIO -import BN -import Rand -import DH -import DSA +from . import _m2crypto +from . import m2 +from . import ASN1 +from . import AuthCookie +from . import BIO +from . import BN +from . import Rand +from . import DH +from . import DSA if m2.OPENSSL_VERSION_NUMBER >= 0x90800F and m2.OPENSSL_NO_EC == 0: - import EC -import Err -import Engine -import EVP -import RSA -import RC4 -import SMIME -import SSL -import X509 -import PGP -import m2urllib + from . import EC +from . import Err +from . import Engine +from . import EVP +from . import RSA +from . import RC4 +from . import SMIME +from . import SSL +from . import X509 +from . import PGP +from . import m2urllib # Backwards compatibility. urllib2 = m2urllib -import m2urllib2 - -import ftpslib -import httpslib -import m2xmlrpclib -import threading -import util +from . import ftpslib +from . import httpslib +from . import m2xmlrpclib +from . import threading +from . import util encrypt = 1 decrypt = 0 diff --git a/M2Crypto/callback.py b/M2Crypto/callback.py index 46613ca..edf16f0 100644 --- a/M2Crypto/callback.py +++ b/M2Crypto/callback.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + """Deprecated, use the util module instead. Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved.""" @@ -6,4 +8,4 @@ import warnings warnings.warn('Use the util module instead', DeprecationWarning) -from util import genparam_callback, passphrase_callback +from .util import genparam_callback, passphrase_callback diff --git a/M2Crypto/ftpslib.py b/M2Crypto/ftpslib.py index 9dfaf59..c1def37 100644 --- a/M2Crypto/ftpslib.py +++ b/M2Crypto/ftpslib.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + """M2Crypto client-side FTP/TLS. This implementation complies with draft-murray-auth-ftp-ssl-07.txt. @@ -38,7 +40,7 @@ import socket # noqa import time # noqa # M2Crypto -import SSL +from . import SSL DEFAULT_PROTOCOL = 'sslv23' diff --git a/M2Crypto/httpslib.py b/M2Crypto/httpslib.py index 2984c40..777e96c 100644 --- a/M2Crypto/httpslib.py +++ b/M2Crypto/httpslib.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + """M2Crypto support for Python's httplib. Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved.""" @@ -8,8 +10,8 @@ from urlparse import urlsplit, urlunsplit import base64 from httplib import * -from httplib import HTTPS_PORT # This is not imported with just '*' -import SSL +from httplib import HTTPS_PORT # This is not imported with just '*' +from . import SSL class HTTPSConnection(HTTPConnection): diff --git a/M2Crypto/m2.py b/M2Crypto/m2.py index 7dac083..cfe1c98 100644 --- a/M2Crypto/m2.py +++ b/M2Crypto/m2.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + """M2Crypto low level OpenSSL wrapper functions. m2 is the low level wrapper for OpenSSL functions. Typically you would not @@ -25,5 +27,5 @@ Portions created by Open Source Applications Foundation (OSAF) are Copyright (C) 2004 OSAF. All Rights Reserved. """ -from _m2crypto import * +from ._m2crypto import * lib_init() diff --git a/M2Crypto/m2urllib.py b/M2Crypto/m2urllib.py index 8e1de49..a1ed7f8 100644 --- a/M2Crypto/m2urllib.py +++ b/M2Crypto/m2urllib.py @@ -1,4 +1,4 @@ -from __future__ import print_function +from __future__ import absolute_import, print_function """M2Crypto enhancement to Python's urllib for handling 'https' url's. @@ -8,8 +8,8 @@ Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved.""" import string, sys, urllib from urllib import * -import SSL -import httpslib +from . import SSL +from . import httpslib DEFAULT_PROTOCOL = 'sslv23' diff --git a/M2Crypto/m2urllib2.py b/M2Crypto/m2urllib2.py index 4ccfaf5..5bd1090 100644 --- a/M2Crypto/m2urllib2.py +++ b/M2Crypto/m2urllib2.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + """ M2Crypto enhancement to Python's urllib2 for handling 'https' url's. @@ -14,7 +16,15 @@ Summary of changes: import socket import urlparse -import SSL +from . import SSL +from . import httpslib + + +class _closing_fileobject(socket._fileobject): + '''socket._fileobject that propagates self.close() to the socket. + + Python 2.5 provides this as socket._fileobject(sock, close=True). + ''' import httpslib from urllib2 import * # noqa diff --git a/M2Crypto/m2xmlrpclib.py b/M2Crypto/m2xmlrpclib.py index 326d1bd..7090a5d 100644 --- a/M2Crypto/m2xmlrpclib.py +++ b/M2Crypto/m2xmlrpclib.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + """M2Crypto enhancement to xmlrpclib. Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved.""" @@ -6,7 +8,7 @@ import base64, string, sys from xmlrpclib import * import M2Crypto -import SSL, httpslib, m2urllib +from . import SSL, httpslib, m2urllib __version__ = M2Crypto.version diff --git a/M2Crypto/threading.py b/M2Crypto/threading.py index d313f3e..77c1b5f 100644 --- a/M2Crypto/threading.py +++ b/M2Crypto/threading.py @@ -1,10 +1,12 @@ +from __future__ import absolute_import + """ M2Crypto threading support, required for multithreaded applications. Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved.""" # M2Crypto -import m2 +from . import m2 def init(): """ diff --git a/M2Crypto/util.py b/M2Crypto/util.py index c577034..99a0497 100644 --- a/M2Crypto/util.py +++ b/M2Crypto/util.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + """ M2Crypto utility routines. @@ -8,7 +10,7 @@ """ import sys -import m2 +from . import m2 # Python 2 has int() and long(). # Python 3 and higher only has int(). diff --git a/tests/alltests.py b/tests/alltests.py index bdc9505..dfa8abb 100644 --- a/tests/alltests.py +++ b/tests/alltests.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -from __future__ import print_function +from __future__ import absolute_import, print_function def suite(): from M2Crypto import m2 @@ -94,7 +94,7 @@ def runall(report_leaks=0): Rand.save_file('tests/randpool.dat') finally: if os.name == 'posix': - from test_ssl import zap_servers + from .test_ssl import zap_servers zap_servers() if report_leaks: diff --git a/tests/test_bio.py b/tests/test_bio.py index ca71c49..8cbfc9d 100644 --- a/tests/test_bio.py +++ b/tests/test_bio.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +from __future__ import absolute_import """ Unit tests for M2Crypto.BIO. @@ -15,7 +16,7 @@ except ImportError: from M2Crypto import BIO, Rand -from fips import fips_mode +from .fips import fips_mode class CipherStreamTestCase(unittest.TestCase): def try_algo(self, algo): diff --git a/tests/test_bio_ssl.py b/tests/test_bio_ssl.py index 518d79a..c44a2ec 100644 --- a/tests/test_bio_ssl.py +++ b/tests/test_bio_ssl.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -from __future__ import print_function +from __future__ import absolute_import, print_function """Unit tests for M2Crypto.BIO.File. @@ -17,7 +17,7 @@ from M2Crypto import Err from M2Crypto import Rand from M2Crypto import threading as m2threading -from test_ssl import srv_host, allocate_srv_port +from .test_ssl import srv_host, allocate_srv_port class HandshakeClient(threading.Thread): diff --git a/tests/test_ec_curves.py b/tests/test_ec_curves.py index 5dafcb8..1bffaff 100644 --- a/tests/test_ec_curves.py +++ b/tests/test_ec_curves.py @@ -1,5 +1,7 @@ #!/usr/bin/env python # XXX memory leaks +from __future__ import absolute_import + """ Unit tests for M2Crypto.EC, the curves diff --git a/tests/test_evp.py b/tests/test_evp.py index c05d836..e5b0c9a 100644 --- a/tests/test_evp.py +++ b/tests/test_evp.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +from __future__ import absolute_import """ Unit tests for M2Crypto.EVP. @@ -17,7 +18,7 @@ except ImportError: from M2Crypto import EVP, RSA, util, Rand, m2, BIO from M2Crypto.util import h2b -from fips import fips_mode +from .fips import fips_mode class EVPTestCase(unittest.TestCase): def _gen_callback(self, *args): diff --git a/tests/test_rc4.py b/tests/test_rc4.py index 017324f..1b5dcf0 100644 --- a/tests/test_rc4.py +++ b/tests/test_rc4.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +from __future__ import absolute_import """Unit tests for M2Crypto.RC4. @@ -11,7 +12,7 @@ except ImportError: from M2Crypto import RC4, Rand from binascii import hexlify -from fips import fips_mode +from .fips import fips_mode class RC4TestCase(unittest.TestCase): diff --git a/tests/test_rsa.py b/tests/test_rsa.py index aa6284a..9ae7709 100644 --- a/tests/test_rsa.py +++ b/tests/test_rsa.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +from __future__ import absolute_import """Unit tests for M2Crypto.RSA. @@ -14,7 +15,7 @@ except ImportError: from M2Crypto import BIO, RSA, Rand, X509, m2 -from fips import fips_mode +from .fips import fips_mode log = logging.getLogger('test_RSA') diff --git a/tests/test_ssl.py b/tests/test_ssl.py index f9cabae..47130d5 100644 --- a/tests/test_ssl.py +++ b/tests/test_ssl.py @@ -1,6 +1,5 @@ #!/usr/bin/env python - -from __future__ import print_function +from __future__ import absolute_import, print_function """Unit tests for M2Crypto.SSL. @@ -1174,5 +1173,5 @@ if __name__ == '__main__': zap_servers() if report_leaks: - import alltests + from . import alltests alltests.dump_garbage() diff --git a/tests/test_ssl_offline.py b/tests/test_ssl_offline.py index 60e3470..d409eea 100644 --- a/tests/test_ssl_offline.py +++ b/tests/test_ssl_offline.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + """Unit tests for M2Crypto.SSL offline parts Copyright (C) 2006 Open Source Applications Foundation. All Rights Reserved. @@ -12,7 +14,7 @@ except ImportError: import unittest from M2Crypto import Rand, SSL, X509 -from test_ssl import srv_host +from .test_ssl import srv_host class CheckerTestCase(unittest.TestCase): diff --git a/tests/test_ssl_win.py b/tests/test_ssl_win.py index 34e9835..b2bbddb 100644 --- a/tests/test_ssl_win.py +++ b/tests/test_ssl_win.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +from __future__ import absolute_import """Unit tests for M2Crypto.SSL. @@ -7,7 +8,9 @@ on your PATH. Copyright (c) 2000-2001 Ng Pheng Siong. All rights reserved.""" -import os, os.path, string, time +import os +import os.path +import time try: import unittest2 as unittest except ImportError: @@ -19,21 +22,20 @@ except ImportError: win32process = None if win32process: - from M2Crypto import Rand, SSL - import test_ssl + from M2Crypto import Rand + from . import test_ssl def find_openssl(): plist = os.environ['PATH'].split(';') for p in plist: try: - dir = os.listdir(p) - if 'openssl.exe' in dir: + path_dir = os.listdir(p) + if 'openssl.exe' in path_dir: return os.path.join(p, 'openssl.exe') except WindowsError: pass return None - srv_host = 'localhost' srv_port = 64000 @@ -47,9 +49,10 @@ if win32process: # to find the .pem files os.chdir('tests') try: - hproc, hthread, pid, tid = win32process.CreateProcess(self.openssl, - string.join(args), None, None, 0, win32process.DETACHED_PROCESS, - None, None, self.startupinfo) + hproc, _, _, _ = win32process.CreateProcess( + self.openssl, ' '.join(args), None, None, 0, + win32process.DETACHED_PROCESS, None, None, + self.startupinfo) finally: os.chdir('..') time.sleep(0.3) @@ -58,14 +61,12 @@ if win32process: def stop_server(self, hproc): win32process.TerminateProcess(hproc, 0) - def suite(): return unittest.makeSuite(SSLWinClientTestCase) def zap_servers(): pass - if __name__ == '__main__': try: if find_openssl() is not None: |