CVS: crypto/test test_hashes.py,1.3,1.4

"A.M. Kuchling" <[email protected]> Fri, 13 Aug 2004 15:23:14 -0700
Newsgroups gmane.comp.python.cryptography.cvs
Message-ID <[email protected]>
Update of /cvsroot/pycrypto/crypto/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27455

Modified Files:
	test_hashes.py 
Log Message:
Avoid ZeroDivisionError if resolution of time.time() is too small (e.g. on Windows)

Index: test_hashes.py
===================================================================
RCS file: /cvsroot/pycrypto/crypto/test/test_hashes.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- test_hashes.py	19 Dec 2003 14:24:25 -0000	1.3
+++ test_hashes.py	13 Aug 2004 22:23:12 -0000	1.4
@@ -49,7 +49,12 @@
         start=time.time()
         s=obj.update(self.str_128k)
         end=time.time()
-        print hash_mod.__name__, ':', 128/(end-start), 'K/sec'
+        delta = end-start
+        print hash_mod.__name__, ':', 
+        if delta == 0:
+            print 'Unable to measure time -- elapsed time too small'
+        else:
+            print '%.2f K/sec' % (128/(end-start))
 
     def check_md2 (self):
         "MD2 module"



-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285