summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDwayne C. Litzenberger <dlitz@dlitz.net>2011-10-22 15:07:47 -0400
committerDwayne C. Litzenberger <dlitz@dlitz.net>2011-10-22 15:07:47 -0400
commit094d70b64d6b575841c6d340f2391b977bc61694 (patch)
treecaa140eb47c78615f3d8eaa37115aaef7d650418
parenta23efbfbb7e6ead0ae87a2c3f889ca4a4ef00d4a (diff)
downloadpycrypto-094d70b64d6b575841c6d340f2391b977bc61694.tar.gz
Python 3.x fixes:
- Use absolute imports - Fix StringIO import so that 2to3 can translate it
-rw-r--r--lib/Crypto/Random/__init__.py4
-rw-r--r--lib/Crypto/SelfTest/Cipher/__init__.py16
-rw-r--r--lib/Crypto/SelfTest/Hash/__init__.py20
-rw-r--r--lib/Crypto/SelfTest/Protocol/__init__.py6
-rw-r--r--lib/Crypto/SelfTest/PublicKey/__init__.py6
-rw-r--r--lib/Crypto/SelfTest/Random/Fortuna/__init__.py6
-rw-r--r--lib/Crypto/SelfTest/Random/OSRNG/__init__.py10
-rw-r--r--lib/Crypto/SelfTest/Random/__init__.py8
-rw-r--r--lib/Crypto/SelfTest/Util/__init__.py6
-rw-r--r--lib/Crypto/SelfTest/__init__.py16
10 files changed, 49 insertions, 49 deletions
diff --git a/lib/Crypto/Random/__init__.py b/lib/Crypto/Random/__init__.py
index 0d0e6f2..659ffee 100644
--- a/lib/Crypto/Random/__init__.py
+++ b/lib/Crypto/Random/__init__.py
@@ -25,8 +25,8 @@
__revision__ = "$Id$"
__all__ = ['new']
-import OSRNG
-import _UserFriendlyRNG
+from Crypto.Random import OSRNG
+from Crypto.Random import _UserFriendlyRNG
def new(*args, **kwargs):
"""Return a file-like object that outputs cryptographically random bytes."""
diff --git a/lib/Crypto/SelfTest/Cipher/__init__.py b/lib/Crypto/SelfTest/Cipher/__init__.py
index 0034f37..6d3ab90 100644
--- a/lib/Crypto/SelfTest/Cipher/__init__.py
+++ b/lib/Crypto/SelfTest/Cipher/__init__.py
@@ -28,14 +28,14 @@ __revision__ = "$Id$"
def get_tests(config={}):
tests = []
- import test_AES; tests += test_AES.get_tests(config=config)
- import test_ARC2; tests += test_ARC2.get_tests(config=config)
- import test_ARC4; tests += test_ARC4.get_tests(config=config)
- import test_Blowfish; tests += test_Blowfish.get_tests(config=config)
- import test_CAST; tests += test_CAST.get_tests(config=config)
- import test_DES3; tests += test_DES3.get_tests(config=config)
- import test_DES; tests += test_DES.get_tests(config=config)
- import test_XOR; tests += test_XOR.get_tests(config=config)
+ from Crypto.SelfTest.Cipher import test_AES; tests += test_AES.get_tests(config=config)
+ from Crypto.SelfTest.Cipher import test_ARC2; tests += test_ARC2.get_tests(config=config)
+ from Crypto.SelfTest.Cipher import test_ARC4; tests += test_ARC4.get_tests(config=config)
+ from Crypto.SelfTest.Cipher import test_Blowfish; tests += test_Blowfish.get_tests(config=config)
+ from Crypto.SelfTest.Cipher import test_CAST; tests += test_CAST.get_tests(config=config)
+ from Crypto.SelfTest.Cipher import test_DES3; tests += test_DES3.get_tests(config=config)
+ from Crypto.SelfTest.Cipher import test_DES; tests += test_DES.get_tests(config=config)
+ from Crypto.SelfTest.Cipher import test_XOR; tests += test_XOR.get_tests(config=config)
return tests
if __name__ == '__main__':
diff --git a/lib/Crypto/SelfTest/Hash/__init__.py b/lib/Crypto/SelfTest/Hash/__init__.py
index d457519..bb19f9b 100644
--- a/lib/Crypto/SelfTest/Hash/__init__.py
+++ b/lib/Crypto/SelfTest/Hash/__init__.py
@@ -28,17 +28,17 @@ __revision__ = "$Id$"
def get_tests(config={}):
tests = []
- import test_HMAC; tests += test_HMAC.get_tests(config=config)
- import test_MD2; tests += test_MD2.get_tests(config=config)
- import test_MD4; tests += test_MD4.get_tests(config=config)
- import test_MD5; tests += test_MD5.get_tests(config=config)
- import test_RIPEMD; tests += test_RIPEMD.get_tests(config=config)
- import test_SHA; tests += test_SHA.get_tests(config=config)
- import test_SHA256; tests += test_SHA256.get_tests(config=config)
+ from Crypto.SelfTest.Hash import test_HMAC; tests += test_HMAC.get_tests(config=config)
+ from Crypto.SelfTest.Hash import test_MD2; tests += test_MD2.get_tests(config=config)
+ from Crypto.SelfTest.Hash import test_MD4; tests += test_MD4.get_tests(config=config)
+ from Crypto.SelfTest.Hash import test_MD5; tests += test_MD5.get_tests(config=config)
+ from Crypto.SelfTest.Hash import test_RIPEMD; tests += test_RIPEMD.get_tests(config=config)
+ from Crypto.SelfTest.Hash import test_SHA; tests += test_SHA.get_tests(config=config)
+ from Crypto.SelfTest.Hash import test_SHA256; tests += test_SHA256.get_tests(config=config)
try:
- import test_SHA224; tests += test_SHA224.get_tests(config=config)
- import test_SHA384; tests += test_SHA384.get_tests(config=config)
- import test_SHA512; tests += test_SHA512.get_tests(config=config)
+ from Crypto.SelfTest.Hash import test_SHA224; tests += test_SHA224.get_tests(config=config)
+ from Crypto.SelfTest.Hash import test_SHA384; tests += test_SHA384.get_tests(config=config)
+ from Crypto.SelfTest.Hash import test_SHA512; tests += test_SHA512.get_tests(config=config)
except ImportError:
import sys
sys.stderr.write("SelfTest: warning: not testing SHA224/SHA384/SHA512 modules (not available)\n")
diff --git a/lib/Crypto/SelfTest/Protocol/__init__.py b/lib/Crypto/SelfTest/Protocol/__init__.py
index fc18ba8..a62c670 100644
--- a/lib/Crypto/SelfTest/Protocol/__init__.py
+++ b/lib/Crypto/SelfTest/Protocol/__init__.py
@@ -28,9 +28,9 @@ __revision__ = "$Id$"
def get_tests(config={}):
tests = []
- import test_chaffing; tests += test_chaffing.get_tests(config=config)
- import test_rfc1751; tests += test_rfc1751.get_tests(config=config)
- import test_AllOrNothing; tests += test_AllOrNothing.get_tests(config=config)
+ from Crypto.SelfTest.Protocol import test_chaffing; tests += test_chaffing.get_tests(config=config)
+ from Crypto.SelfTest.Protocol import test_rfc1751; tests += test_rfc1751.get_tests(config=config)
+ from Crypto.SelfTest.Protocol import test_AllOrNothing; tests += test_AllOrNothing.get_tests(config=config)
return tests
if __name__ == '__main__':
diff --git a/lib/Crypto/SelfTest/PublicKey/__init__.py b/lib/Crypto/SelfTest/PublicKey/__init__.py
index f29ae51..88a62ea 100644
--- a/lib/Crypto/SelfTest/PublicKey/__init__.py
+++ b/lib/Crypto/SelfTest/PublicKey/__init__.py
@@ -30,9 +30,9 @@ import os
def get_tests(config={}):
tests = []
- import test_DSA; tests += test_DSA.get_tests(config=config)
- import test_RSA; tests += test_RSA.get_tests(config=config)
- import test_importKey; tests += test_importKey.get_tests(config=config)
+ from Crypto.SelfTest.PublicKey import test_DSA; tests += test_DSA.get_tests(config=config)
+ from Crypto.SelfTest.PublicKey import test_RSA; tests += test_RSA.get_tests(config=config)
+ from Crypto.SelfTest.PublicKey import test_importKey; tests += test_importKey.get_tests(config=config)
return tests
if __name__ == '__main__':
diff --git a/lib/Crypto/SelfTest/Random/Fortuna/__init__.py b/lib/Crypto/SelfTest/Random/Fortuna/__init__.py
index bd31e72..81a0e13 100644
--- a/lib/Crypto/SelfTest/Random/Fortuna/__init__.py
+++ b/lib/Crypto/SelfTest/Random/Fortuna/__init__.py
@@ -30,9 +30,9 @@ import os
def get_tests(config={}):
tests = []
- import test_FortunaAccumulator; tests += test_FortunaAccumulator.get_tests(config=config)
- import test_FortunaGenerator; tests += test_FortunaGenerator.get_tests(config=config)
- import test_SHAd256; tests += test_SHAd256.get_tests(config=config)
+ from Crypto.SelfTest.Random.Fortuna import test_FortunaAccumulator; tests += test_FortunaAccumulator.get_tests(config=config)
+ from Crypto.SelfTest.Random.Fortuna import test_FortunaGenerator; tests += test_FortunaGenerator.get_tests(config=config)
+ from Crypto.SelfTest.Random.Fortuna import test_SHAd256; tests += test_SHAd256.get_tests(config=config)
return tests
if __name__ == '__main__':
diff --git a/lib/Crypto/SelfTest/Random/OSRNG/__init__.py b/lib/Crypto/SelfTest/Random/OSRNG/__init__.py
index b41bb7d..44b3fa1 100644
--- a/lib/Crypto/SelfTest/Random/OSRNG/__init__.py
+++ b/lib/Crypto/SelfTest/Random/OSRNG/__init__.py
@@ -31,13 +31,13 @@ import os
def get_tests(config={}):
tests = []
if os.name == 'nt':
- import test_nt; tests += test_nt.get_tests(config=config)
- import test_winrandom; tests += test_winrandom.get_tests(config=config)
+ from Crypto.SelfTest.Random.OSRNG import test_nt; tests += test_nt.get_tests(config=config)
+ from Crypto.SelfTest.Random.OSRNG import test_winrandom; tests += test_winrandom.get_tests(config=config)
elif os.name == 'posix':
- import test_posix; tests += test_posix.get_tests(config=config)
+ from Crypto.SelfTest.Random.OSRNG import test_posix; tests += test_posix.get_tests(config=config)
if hasattr(os, 'urandom'):
- import test_fallback; tests += test_fallback.get_tests(config=config)
- import test_generic; tests += test_generic.get_tests(config=config)
+ from Crypto.SelfTest.Random.OSRNG import test_fallback; tests += test_fallback.get_tests(config=config)
+ from Crypto.SelfTest.Random.OSRNG import test_generic; tests += test_generic.get_tests(config=config)
return tests
if __name__ == '__main__':
diff --git a/lib/Crypto/SelfTest/Random/__init__.py b/lib/Crypto/SelfTest/Random/__init__.py
index 5dcad2d..48d84ff 100644
--- a/lib/Crypto/SelfTest/Random/__init__.py
+++ b/lib/Crypto/SelfTest/Random/__init__.py
@@ -28,10 +28,10 @@ __revision__ = "$Id$"
def get_tests(config={}):
tests = []
- import Fortuna; tests += Fortuna.get_tests(config=config)
- import OSRNG; tests += OSRNG.get_tests(config=config)
- import test_random; tests += test_random.get_tests(config=config)
- import test_rpoolcompat; tests += test_rpoolcompat.get_tests(config=config)
+ from Crypto.SelfTest.Random import Fortuna; tests += Fortuna.get_tests(config=config)
+ from Crypto.SelfTest.Random import OSRNG; tests += OSRNG.get_tests(config=config)
+ from Crypto.SelfTest.Random import test_random; tests += test_random.get_tests(config=config)
+ from Crypto.SelfTest.Random import test_rpoolcompat; tests += test_rpoolcompat.get_tests(config=config)
return tests
if __name__ == '__main__':
diff --git a/lib/Crypto/SelfTest/Util/__init__.py b/lib/Crypto/SelfTest/Util/__init__.py
index e81053f..abd640a 100644
--- a/lib/Crypto/SelfTest/Util/__init__.py
+++ b/lib/Crypto/SelfTest/Util/__init__.py
@@ -31,9 +31,9 @@ import os
def get_tests(config={}):
tests = []
if os.name == 'nt':
- import test_winrandom; tests += test_winrandom.get_tests(config=config)
- import test_number; tests += test_number.get_tests(config=config)
- import test_Counter; tests += test_Counter.get_tests(config=config)
+ from Crypto.SelfTest.Util import test_winrandom; tests += test_winrandom.get_tests(config=config)
+ from Crypto.SelfTest.Util import test_number; tests += test_number.get_tests(config=config)
+ from Crypto.SelfTest.Util import test_Counter; tests += test_Counter.get_tests(config=config)
return tests
if __name__ == '__main__':
diff --git a/lib/Crypto/SelfTest/__init__.py b/lib/Crypto/SelfTest/__init__.py
index da56a4a..c4cef21 100644
--- a/lib/Crypto/SelfTest/__init__.py
+++ b/lib/Crypto/SelfTest/__init__.py
@@ -32,7 +32,7 @@ __revision__ = "$Id$"
import sys
import unittest
-import StringIO
+from StringIO import StringIO
class SelfTestError(Exception):
def __init__(self, message, result):
@@ -65,7 +65,7 @@ def run(module=None, verbosity=0, stream=None, tests=None, config=None, **kwargs
else:
raise ValueError("'module' and 'tests' arguments are mutually exclusive")
if stream is None:
- kwargs['stream'] = StringIO.StringIO()
+ kwargs['stream'] = StringIO()
runner = unittest.TextTestRunner(verbosity=verbosity, **kwargs)
result = runner.run(suite)
if not result.wasSuccessful():
@@ -76,12 +76,12 @@ def run(module=None, verbosity=0, stream=None, tests=None, config=None, **kwargs
def get_tests(config={}):
tests = []
- import Cipher; tests += Cipher.get_tests(config=config)
- import Hash; tests += Hash.get_tests(config=config)
- import Protocol; tests += Protocol.get_tests(config=config)
- import PublicKey; tests += PublicKey.get_tests(config=config)
- import Random; tests += Random.get_tests(config=config)
- import Util; tests += Util.get_tests(config=config)
+ from Crypto.SelfTest import Cipher; tests += Cipher.get_tests(config=config)
+ from Crypto.SelfTest import Hash; tests += Hash.get_tests(config=config)
+ from Crypto.SelfTest import Protocol; tests += Protocol.get_tests(config=config)
+ from Crypto.SelfTest import PublicKey; tests += PublicKey.get_tests(config=config)
+ from Crypto.SelfTest import Random; tests += Random.get_tests(config=config)
+ from Crypto.SelfTest import Util; tests += Util.get_tests(config=config)
return tests
if __name__ == '__main__':