Browse files

Make tests compatible to Python 2.1

  • Loading branch information...
1 parent 623c303 commit b2c5880538e85269c07c3a17e0493e2e2180d52f Legrandin committed Feb 3, 2011
Showing with 9 additions and 2 deletions.
  1. +6 −1 lib/Crypto/SelfTest/Hash/common.py
  2. +3 −1 lib/Crypto/SelfTest/Signature/test_pkcs1_15.py
View
7 lib/Crypto/SelfTest/Hash/common.py
@@ -79,7 +79,12 @@ def __init__(self, hashmod, oid):
def runTest(self):
h = self.hashmod.new()
if self.oid==None:
- self.assertRaises(AttributeError, lambda: h.oid)
+ try:
+ raised = 0
+ a = h.oid
+ except AttributeError:
+ raised = 1
+ self.assertEqual(raised,1)
else:
self.assertEqual(h.oid, self.oid)
View
4 lib/Crypto/SelfTest/Signature/test_pkcs1_15.py
@@ -30,6 +30,8 @@
from Crypto.Hash import MD2,SHA
from Crypto.Signature import PKCS1_v1_5 as PKCS
+from string import maketrans
+
def isStr(s):
t = ''
try:
@@ -40,7 +42,7 @@ def isStr(s):
def rws(t):
"""Remove white spaces, tabs, and new lines from a string"""
- return t.translate(None,'\n\t ')
+ return t.translate(maketrans("",""),'\n\t ')
def t2b(t):
"""Convert a text string with bytes in hex form to a byte string"""

0 comments on commit b2c5880

Please sign in to comment.