summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_pep247.py
diff options
context:
space:
mode:
authorZachary Ware <zachary.ware@gmail.com>2016-09-09 18:38:38 (GMT)
committerZachary Ware <zachary.ware@gmail.com>2016-09-09 18:38:38 (GMT)
commitcce02f8b825ce462193c2e52fadc690004d1cd56 (patch)
tree78a517381e78de90732338fdacf4fbbb90173516 /Lib/test/test_pep247.py
parent68f4dd8b01b1d2b961f51cf07b785366ceb139e4 (diff)
downloadcpython-cce02f8b825ce462193c2e52fadc690004d1cd56.zip
cpython-cce02f8b825ce462193c2e52fadc690004d1cd56.tar.gz
cpython-cce02f8b825ce462193c2e52fadc690004d1cd56.tar.bz2
Remove Lib/test/test_pep247.py
This test file is a holdover from the days before hashlib, and doesn't seem to have anything of value in it.
Diffstat (limited to 'Lib/test/test_pep247.py')
-rw-r--r--Lib/test/test_pep247.py66
1 files changed, 0 insertions, 66 deletions
diff --git a/Lib/test/test_pep247.py b/Lib/test/test_pep247.py
deleted file mode 100644
index c17ceed..0000000
--- a/Lib/test/test_pep247.py
+++ /dev/null
@@ -1,66 +0,0 @@
-"""
-Test suite to check compliance with PEP 247, the standard API
-for hashing algorithms
-"""
-
-import hmac
-import unittest
-from hashlib import md5, sha1, sha224, sha256, sha384, sha512
-
-class Pep247Test(unittest.TestCase):
-
- def check_module(self, module, key=None):
- self.assertTrue(hasattr(module, 'digest_size'))
- self.assertTrue(module.digest_size is None or module.digest_size > 0)
- self.check_object(module.new, module.digest_size, key)
-
- def check_object(self, cls, digest_size, key, digestmod=None):
- if key is not None:
- if digestmod is None:
- digestmod = md5
- obj1 = cls(key, digestmod=digestmod)
- obj2 = cls(key, b'string', digestmod=digestmod)
- h1 = cls(key, b'string', digestmod=digestmod).digest()
- obj3 = cls(key, digestmod=digestmod)
- obj3.update(b'string')
- h2 = obj3.digest()
- else:
- obj1 = cls()
- obj2 = cls(b'string')
- h1 = cls(b'string').digest()
- obj3 = cls()
- obj3.update(b'string')
- h2 = obj3.digest()
- self.assertEqual(h1, h2)
- self.assertTrue(hasattr(obj1, 'digest_size'))
-
- if digest_size is not None:
- self.assertEqual(obj1.digest_size, digest_size)
-
- self.assertEqual(obj1.digest_size, len(h1))
- obj1.update(b'string')
- obj_copy = obj1.copy()
- self.assertEqual(obj1.digest(), obj_copy.digest())
- self.assertEqual(obj1.hexdigest(), obj_copy.hexdigest())
-
- digest, hexdigest = obj1.digest(), obj1.hexdigest()
- hd2 = ""
- for byte in digest:
- hd2 += '%02x' % byte
- self.assertEqual(hd2, hexdigest)
-
- def test_md5(self):
- self.check_object(md5, None, None)
-
- def test_sha(self):
- self.check_object(sha1, None, None)
- self.check_object(sha224, None, None)
- self.check_object(sha256, None, None)
- self.check_object(sha384, None, None)
- self.check_object(sha512, None, None)
-
- def test_hmac(self):
- self.check_module(hmac, key=b'abc')
-
-if __name__ == '__main__':
- unittest.main()