diff options
author | Matěj Cepl <mcepl@cepl.eu> | 2015-10-13 14:51:24 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@cepl.eu> | 2015-10-13 15:23:06 +0200 |
commit | a4e8e60f95ce6b2c1e4bc5d804d6521392bfa66b (patch) | |
tree | 5bb242ba3646b2df8322c2555975c4244ca4588e /tests | |
parent | 1b5f8bbe04280558dfe577a2df203eaf0600c473 (diff) | |
download | m2crypto-a4e8e60f95ce6b2c1e4bc5d804d6521392bfa66b.tar.gz |
Switch unit testing to have at least 2.7 unittest API available.
Fixes #48
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_asn1.py | 7 | ||||
-rw-r--r-- | tests/test_authcookie.py | 7 | ||||
-rw-r--r-- | tests/test_bio.py | 5 | ||||
-rw-r--r-- | tests/test_bio_file.py | 8 | ||||
-rw-r--r-- | tests/test_bio_iobuf.py | 5 | ||||
-rw-r--r-- | tests/test_bio_membuf.py | 6 | ||||
-rw-r--r-- | tests/test_bio_ssl.py | 6 | ||||
-rwxr-xr-x | tests/test_bn.py | 7 | ||||
-rw-r--r-- | tests/test_dh.py | 6 | ||||
-rw-r--r-- | tests/test_dsa.py | 6 | ||||
-rw-r--r-- | tests/test_ec_curves.py | 6 | ||||
-rw-r--r-- | tests/test_ecdh.py | 8 | ||||
-rw-r--r-- | tests/test_ecdsa.py | 7 | ||||
-rw-r--r-- | tests/test_engine.py | 6 | ||||
-rw-r--r-- | tests/test_evp.py | 6 | ||||
-rw-r--r-- | tests/test_obj.py | 6 | ||||
-rw-r--r-- | tests/test_pgp.py | 8 | ||||
-rw-r--r-- | tests/test_rand.py | 6 | ||||
-rw-r--r-- | tests/test_rc4.py | 5 | ||||
-rw-r--r-- | tests/test_rsa.py | 6 | ||||
-rw-r--r-- | tests/test_smime.py | 6 | ||||
-rw-r--r-- | tests/test_ssl.py | 7 | ||||
-rw-r--r-- | tests/test_ssl_offline.py | 7 | ||||
-rw-r--r-- | tests/test_ssl_win.py | 7 | ||||
-rw-r--r-- | tests/test_threading.py | 5 | ||||
-rw-r--r-- | tests/test_x509.py | 6 |
26 files changed, 134 insertions, 31 deletions
diff --git a/tests/test_asn1.py b/tests/test_asn1.py index 30ef759..66b0803 100644 --- a/tests/test_asn1.py +++ b/tests/test_asn1.py @@ -4,7 +4,12 @@ Copyright (c) 2005 Open Source Applications Foundation. All rights reserved.""" -import unittest, time, datetime +import time, datetime +try: + import unittest2 as unittest +except ImportError: + import unittest + from M2Crypto import ASN1, m2 class ASN1TestCase(unittest.TestCase): diff --git a/tests/test_authcookie.py b/tests/test_authcookie.py index 9ce0eb8..458d731 100644 --- a/tests/test_authcookie.py +++ b/tests/test_authcookie.py @@ -4,7 +4,12 @@ Copyright (c) 1999-2002 Ng Pheng Siong. All rights reserved.""" -import Cookie, binascii, time, unittest, sys +import Cookie, binascii, time, sys +try: + import unittest2 as unittest +except ImportError: + import unittest + from M2Crypto.AuthCookie import AuthCookie, AuthCookieJar, mix, unmix, unmix3 from M2Crypto import Rand, EVP diff --git a/tests/test_bio.py b/tests/test_bio.py index 1d7b0c3..88b6902 100644 --- a/tests/test_bio.py +++ b/tests/test_bio.py @@ -8,8 +8,11 @@ Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved. Copyright (c) 2006 Open Source Applications Foundation Author: Heikki Toivonen """ +try: + import unittest2 as unittest +except ImportError: + import unittest -import unittest from M2Crypto import BIO, Rand from fips import fips_mode diff --git a/tests/test_bio_file.py b/tests/test_bio_file.py index e118386..506bf28 100644 --- a/tests/test_bio_file.py +++ b/tests/test_bio_file.py @@ -4,10 +4,14 @@ Copyright (c) 1999-2002 Ng Pheng Siong. All rights reserved.""" -import unittest +import os, sys +try: + import unittest2 as unittest +except ImportError: + import unittest + import M2Crypto from M2Crypto.BIO import File, openfile -import os, sys class FileTestCase(unittest.TestCase): diff --git a/tests/test_bio_iobuf.py b/tests/test_bio_iobuf.py index 358e5df..eb79a6c 100644 --- a/tests/test_bio_iobuf.py +++ b/tests/test_bio_iobuf.py @@ -5,8 +5,11 @@ Copyright (c) 2000 Ng Pheng Siong. All rights reserved.""" from cStringIO import StringIO +try: + import unittest2 as unittest +except ImportError: + import unittest -import unittest import M2Crypto from M2Crypto.BIO import IOBuffer, MemoryBuffer diff --git a/tests/test_bio_membuf.py b/tests/test_bio_membuf.py index 7d719fd..76edfa0 100644 --- a/tests/test_bio_membuf.py +++ b/tests/test_bio_membuf.py @@ -4,7 +4,11 @@ Copyright (c) 2000 Ng Pheng Siong. All rights reserved.""" -import unittest +try: + import unittest2 as unittest +except ImportError: + import unittest + import M2Crypto from M2Crypto.BIO import MemoryBuffer diff --git a/tests/test_bio_ssl.py b/tests/test_bio_ssl.py index 0dee9da..229475a 100644 --- a/tests/test_bio_ssl.py +++ b/tests/test_bio_ssl.py @@ -3,7 +3,11 @@ Copyright (c) 1999-2002 Ng Pheng Siong. All rights reserved.""" -import unittest, threading, sys, socket +import threading, sys, socket +try: + import unittest2 as unittest +except ImportError: + import unittest from M2Crypto import BIO from M2Crypto import SSL diff --git a/tests/test_bn.py b/tests/test_bn.py index 62c83fe..271b63a 100755 --- a/tests/test_bn.py +++ b/tests/test_bn.py @@ -6,7 +6,12 @@ Unit tests for M2Crypto.BN. Copyright (c) 2005 Open Source Applications Foundation. All rights reserved. """ -import unittest, re +import re +try: + import unittest2 as unittest +except ImportError: + import unittest + from M2Crypto import BN, Rand loops = 16 diff --git a/tests/test_dh.py b/tests/test_dh.py index 0e66c89..1bf65f7 100644 --- a/tests/test_dh.py +++ b/tests/test_dh.py @@ -4,7 +4,11 @@ Copyright (c) 2000 Ng Pheng Siong. All rights reserved.""" -import unittest +try: + import unittest2 as unittest +except ImportError: + import unittest + from M2Crypto import DH, BIO, Rand, m2 class DHTestCase(unittest.TestCase): diff --git a/tests/test_dsa.py b/tests/test_dsa.py index 7823f50..2287a70 100644 --- a/tests/test_dsa.py +++ b/tests/test_dsa.py @@ -4,8 +4,12 @@ Copyright (c) 2000 Ng Pheng Siong. All rights reserved.""" -import unittest import sha +try: + import unittest2 as unittest +except ImportError: + import unittest + from M2Crypto import DSA, BIO, Rand, m2 class DSATestCase(unittest.TestCase): diff --git a/tests/test_ec_curves.py b/tests/test_ec_curves.py index d01f863..a39c93e 100644 --- a/tests/test_ec_curves.py +++ b/tests/test_ec_curves.py @@ -18,8 +18,12 @@ """ -import unittest #import sha +try: + import unittest2 as unittest +except ImportError: + import unittest + from M2Crypto import EC, Rand from test_ecdsa import ECDSATestCase as ECDSATest diff --git a/tests/test_ecdh.py b/tests/test_ecdh.py index 29581dc..5b7f61b 100644 --- a/tests/test_ecdh.py +++ b/tests/test_ecdh.py @@ -5,11 +5,13 @@ Copyright (c) 2000 Ng Pheng Siong. All rights reserved. Portions copyright (c) 2005-2006 Vrije Universiteit Amsterdam. All rights reserved. """ +import sys +try: + import unittest2 as unittest +except ImportError: + import unittest - -import unittest from M2Crypto import EC, BIO, Rand, m2 -import sys class ECDHTestCase(unittest.TestCase): diff --git a/tests/test_ecdsa.py b/tests/test_ecdsa.py index 74d9a82..1ae608c 100644 --- a/tests/test_ecdsa.py +++ b/tests/test_ecdsa.py @@ -5,9 +5,12 @@ Copyright (c) 2000 Ng Pheng Siong. All rights reserved. Portions copyright (c) 2005-2006 Vrije Universiteit Amsterdam. All rights reserved. """ - -import unittest import sha +try: + import unittest2 as unittest +except ImportError: + import unittest + from M2Crypto import EC, BIO, Rand, m2 class ECDSATestCase(unittest.TestCase): diff --git a/tests/test_engine.py b/tests/test_engine.py index 91c2aa8..0254d38 100644 --- a/tests/test_engine.py +++ b/tests/test_engine.py @@ -2,7 +2,11 @@ """Unit tests for M2Crypto.Engine.""" -import unittest +try: + import unittest2 as unittest +except ImportError: + import unittest + from M2Crypto import Engine, m2 class EngineTestCase(unittest.TestCase): diff --git a/tests/test_evp.py b/tests/test_evp.py index ba09092..d882a1f 100644 --- a/tests/test_evp.py +++ b/tests/test_evp.py @@ -7,9 +7,13 @@ Copyright (c) 2004-2007 Open Source Applications Foundation Author: Heikki Toivonen """ -import unittest import cStringIO, sha from binascii import hexlify, unhexlify +try: + import unittest2 as unittest +except ImportError: + import unittest + from M2Crypto import EVP, RSA, util, Rand, m2, BIO from M2Crypto.util import h2b diff --git a/tests/test_obj.py b/tests/test_obj.py index 9144135..f25a1f4 100644 --- a/tests/test_obj.py +++ b/tests/test_obj.py @@ -3,7 +3,11 @@ """Unit tests for M2Crypto.m2 obj_* functions. """ -import unittest +try: + import unittest2 as unittest +except ImportError: + import unittest + from M2Crypto import X509, ASN1, BIO, Rand, m2 """ diff --git a/tests/test_pgp.py b/tests/test_pgp.py index c86d153..476cd50 100644 --- a/tests/test_pgp.py +++ b/tests/test_pgp.py @@ -4,9 +4,13 @@ Copyright (c) 1999 Ng Pheng Siong. All rights reserved.""" -import unittest -from M2Crypto import EVP, PGP from cStringIO import StringIO +try: + import unittest2 as unittest +except ImportError: + import unittest + +from M2Crypto import EVP, PGP class PGPTestCase(unittest.TestCase): diff --git a/tests/test_rand.py b/tests/test_rand.py index 3e4d65d..02493bb 100644 --- a/tests/test_rand.py +++ b/tests/test_rand.py @@ -5,8 +5,12 @@ Copyright (C) 2006 Open Source Applications Foundation (OSAF). All Rights Reserved. """ -import unittest import os, sys +try: + import unittest2 as unittest +except ImportError: + import unittest + from M2Crypto import Rand class RandTestCase(unittest.TestCase): diff --git a/tests/test_rc4.py b/tests/test_rc4.py index 5a2d239..535d79a 100644 --- a/tests/test_rc4.py +++ b/tests/test_rc4.py @@ -4,7 +4,10 @@ Copyright (c) 2009 Heikki Toivonen. All rights reserved.""" -import unittest +try: + import unittest2 as unittest +except ImportError: + import unittest from binascii import hexlify from M2Crypto import RC4 diff --git a/tests/test_rsa.py b/tests/test_rsa.py index 0bb986b..e2e61f5 100644 --- a/tests/test_rsa.py +++ b/tests/test_rsa.py @@ -4,8 +4,12 @@ Copyright (c) 2000 Ng Pheng Siong. All rights reserved.""" -import unittest import sha, md5, os, sys +try: + import unittest2 as unittest +except ImportError: + import unittest + from M2Crypto import RSA, BIO, Rand, m2, EVP, X509 class RSATestCase(unittest.TestCase): diff --git a/tests/test_smime.py b/tests/test_smime.py index f18c9db..fe0e538 100644 --- a/tests/test_smime.py +++ b/tests/test_smime.py @@ -5,7 +5,11 @@ Copyright (C) 2006 Open Source Applications Foundation. All Rights Reserved. """ -import unittest +try: + import unittest2 as unittest +except ImportError: + import unittest + from M2Crypto import SMIME, BIO, Rand, X509, EVP class SMIMETestCase(unittest.TestCase): diff --git a/tests/test_ssl.py b/tests/test_ssl.py index fc857a8..855d144 100644 --- a/tests/test_ssl.py +++ b/tests/test_ssl.py @@ -20,7 +20,12 @@ Others: - ThreadingSSLServer """ -import os, socket, string, sys, tempfile, thread, time, unittest +import os, socket, string, sys, tempfile, thread, time +try: + import unittest2 as unittest +except ImportError: + import unittest + from M2Crypto import Rand, SSL, m2, Err from fips import fips_mode diff --git a/tests/test_ssl_offline.py b/tests/test_ssl_offline.py index ba77434..9c10401 100644 --- a/tests/test_ssl_offline.py +++ b/tests/test_ssl_offline.py @@ -5,7 +5,12 @@ Copyright (C) 2006 Open Source Applications Foundation. All Rights Reserved. Copyright (C) 2009-2010 Heikki Toivonen. All Rights Reserved. """ -import unittest, doctest +import doctest +try: + import unittest2 as unittest +except ImportError: + import unittest + from M2Crypto.SSL import Checker from M2Crypto import X509 from M2Crypto import SSL diff --git a/tests/test_ssl_win.py b/tests/test_ssl_win.py index 0d13bd0..86f8606 100644 --- a/tests/test_ssl_win.py +++ b/tests/test_ssl_win.py @@ -7,7 +7,12 @@ on your PATH. Copyright (c) 2000-2001 Ng Pheng Siong. All rights reserved.""" -import os, os.path, string, time, unittest +import os, os.path, string, time +try: + import unittest2 as unittest +except ImportError: + import unittest + try: import win32process except ImportError: diff --git a/tests/test_threading.py b/tests/test_threading.py index 7912a61..387aa11 100644 --- a/tests/test_threading.py +++ b/tests/test_threading.py @@ -4,8 +4,11 @@ Copyright (C) 2007 Open Source Applications Foundation. All Rights Reserved. """ +try: + import unittest2 as unittest +except ImportError: + import unittest -import unittest from M2Crypto import threading as m2threading, Rand diff --git a/tests/test_x509.py b/tests/test_x509.py index 7ea86df..08bcedf 100644 --- a/tests/test_x509.py +++ b/tests/test_x509.py @@ -9,8 +9,12 @@ Copyright (C) 2004-2005 OSAF. All Rights Reserved. Author: Heikki Toivonen """ -import unittest import os, time, base64, sys +try: + import unittest2 as unittest +except ImportError: + import unittest + from M2Crypto import X509, EVP, RSA, Rand, ASN1, m2, util, BIO class X509TestCase(unittest.TestCase): |