summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-07-10 20:31:05 +0000
committerGuido van Rossum <guido@python.org>2007-07-10 20:31:05 +0000
commit558ca847308cc35ed387cf5800269b647c87a51d (patch)
tree51a6b8226cb0a39fab1dd11a4d3960f4544fc92f
parent1bd2122041d06782f46dd5f3c6b2b50909a7bd65 (diff)
downloadcpython-git-558ca847308cc35ed387cf5800269b647c87a51d.tar.gz
Fix test_hashlib regression caused by my fixing hexdigest() to return
a text string instead of bytes. (This being hex digits it *should* be a text string -- that it wasn't before was a misunderstanding on my part of the C code.)
-rw-r--r--Lib/test/test_hashlib.py25
1 files changed, 12 insertions, 13 deletions
diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py
index e32f7880ae..089323a737 100644
--- a/Lib/test/test_hashlib.py
+++ b/Lib/test/test_hashlib.py
@@ -13,11 +13,10 @@ from test import test_support
def hexstr(s):
assert isinstance(s, bytes), repr(s)
- h = b"0123456789abcdef"
- r = b''
+ h = "0123456789abcdef"
+ r = ''
for i in s:
- r.append(h[(i >> 4) & 0xF])
- r.append(h[i & 0xF])
+ r += h[(i >> 4) & 0xF] + h[i & 0xF]
return r
@@ -60,22 +59,22 @@ class HashLibTestCase(unittest.TestCase):
def check(self, name, data, digest):
# test the direct constructors
computed = getattr(hashlib, name)(data).hexdigest()
- self.assert_(computed == digest)
+ self.assertEqual(computed, digest)
# test the general new() interface
computed = hashlib.new(name, data).hexdigest()
- self.assert_(computed == digest)
+ self.assertEqual(computed, digest)
def test_case_md5_0(self):
- self.check('md5', b'', b'd41d8cd98f00b204e9800998ecf8427e')
+ self.check('md5', b'', 'd41d8cd98f00b204e9800998ecf8427e')
def test_case_md5_1(self):
- self.check('md5', b'abc', b'900150983cd24fb0d6963f7d28e17f72')
+ self.check('md5', b'abc', '900150983cd24fb0d6963f7d28e17f72')
def test_case_md5_2(self):
self.check('md5',
b'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789',
- b'd174ab98d277d9f5a5611c2c9f419d9f')
+ 'd174ab98d277d9f5a5611c2c9f419d9f')
# use the three examples from Federal Information Processing Standards
@@ -84,20 +83,20 @@ class HashLibTestCase(unittest.TestCase):
def test_case_sha1_0(self):
self.check('sha1', b"",
- b"da39a3ee5e6b4b0d3255bfef95601890afd80709")
+ "da39a3ee5e6b4b0d3255bfef95601890afd80709")
def test_case_sha1_1(self):
self.check('sha1', b"abc",
- b"a9993e364706816aba3e25717850c26c9cd0d89d")
+ "a9993e364706816aba3e25717850c26c9cd0d89d")
def test_case_sha1_2(self):
self.check('sha1',
b"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
- b"84983e441c3bd26ebaae4aa1f95129e5e54670f1")
+ "84983e441c3bd26ebaae4aa1f95129e5e54670f1")
def test_case_sha1_3(self):
self.check('sha1', b"a" * 1000000,
- b"34aa973cd4c4daa4f61eeb2bdbad27316534016f")
+ "34aa973cd4c4daa4f61eeb2bdbad27316534016f")
# use the examples from Federal Information Processing Standards