summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_pep247.py
diff options
context:
space:
mode:
authorAlexandre Vassalotti <alexandre@peadrop.com>2008-03-03 02:59:49 (GMT)
committerAlexandre Vassalotti <alexandre@peadrop.com>2008-03-03 02:59:49 (GMT)
commita351f7701a6d9e0648b4d108821ebd4ce7b38fee (patch)
tree4797bdff37569b8fbc6ab7722444592b6b248f55 /Lib/test/test_pep247.py
parent7f757edf15d130f82149c2133974056db1be201e (diff)
downloadcpython-a351f7701a6d9e0648b4d108821ebd4ce7b38fee.zip
cpython-a351f7701a6d9e0648b4d108821ebd4ce7b38fee.tar.gz
cpython-a351f7701a6d9e0648b4d108821ebd4ce7b38fee.tar.bz2
Fixed failing unit tests due to str/bytes mismatch.
Changed "assert isinstance(...)" in hmac.py to raise proper TypeError.
Diffstat (limited to 'Lib/test/test_pep247.py')
-rw-r--r--Lib/test/test_pep247.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/Lib/test/test_pep247.py b/Lib/test/test_pep247.py
index 4ea747a..89ca6ff 100644
--- a/Lib/test/test_pep247.py
+++ b/Lib/test/test_pep247.py
@@ -12,25 +12,25 @@ def check_hash_module(module, key=None):
if key is not None:
obj1 = module.new(key)
- obj2 = module.new(key, "string")
+ obj2 = module.new(key, b"string")
- h1 = module.new(key, "string").digest()
- obj3 = module.new(key) ; obj3.update("string") ; h2 = obj3.digest()
+ h1 = module.new(key, b"string").digest()
+ obj3 = module.new(key) ; obj3.update(b"string") ; h2 = obj3.digest()
assert h1 == h2, "Hashes must match"
else:
obj1 = module.new()
- obj2 = module.new("string")
+ obj2 = module.new(b"string")
- h1 = module.new("string").digest()
- obj3 = module.new() ; obj3.update("string") ; h2 = obj3.digest()
+ h1 = module.new(b"string").digest()
+ obj3 = module.new() ; obj3.update(b"string") ; h2 = obj3.digest()
assert h1 == h2, "Hashes must match"
assert hasattr(obj1, 'digest_size'), "Objects must have digest_size attr"
if module.digest_size is not None:
assert obj1.digest_size == module.digest_size, "digest_size must match"
assert obj1.digest_size == len(h1), "digest_size must match actual size"
- obj1.update("string")
+ obj1.update(b"string")
obj_copy = obj1.copy()
assert obj1.digest() == obj_copy.digest(), "Copied objects must match"
assert obj1.hexdigest() == obj_copy.hexdigest(), \
@@ -38,11 +38,11 @@ def check_hash_module(module, key=None):
digest, hexdigest = obj1.digest(), obj1.hexdigest()
hd2 = ""
for byte in digest:
- hd2 += "%02x" % ord(byte)
+ hd2 += "%02x" % byte
assert hd2 == hexdigest, "hexdigest doesn't appear correct"
print('Module', module.__name__, 'seems to comply with PEP 247')
if __name__ == '__main__':
- check_hash_module(hmac, key='abc')
+ check_hash_module(hmac, key=b'abc')