[Python-checkins] r52786 - python/trunk/Lib/test/test_sha.py

andrew.kuchling python-checkins at python.org
Sat Nov 18 23:17:33 CET 2006


Author: andrew.kuchling
Date: Sat Nov 18 23:17:33 2006
New Revision: 52786
Modified:
 python/trunk/Lib/test/test_sha.py
Log:
Expand checking in test_sha
Modified: python/trunk/Lib/test/test_sha.py
==============================================================================
--- python/trunk/Lib/test/test_sha.py	(original)
+++ python/trunk/Lib/test/test_sha.py	Sat Nov 18 23:17:33 2006
@@ -11,9 +11,23 @@
 
 class SHATestCase(unittest.TestCase):
 def check(self, data, digest):
- computed = sha.new(data).hexdigest()
+ # Check digest matches the expected value
+ obj = sha.new(data)
+ computed = obj.hexdigest()
 self.assert_(computed == digest)
 
+ # Verify that the value doesn't change between two consecutive
+ # digest operations.
+ computed_again = obj.hexdigest()
+ self.assert_(computed == computed_again)
+
+ # Check hexdigest() output matches digest()'s output
+ digest = obj.digest()
+ hexd = ""
+ for c in digest:
+ hexd += '%02x' % ord(c)
+ self.assert_(computed == hexd)
+
 def test_case_1(self):
 self.check("abc",
 "a9993e364706816aba3e25717850c26c9cd0d89d")


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /