[Zope-Checkins] CVS: Zope/lib/python/Products/Transience/tests - testTimeoutRelated.py:1.9.6.2

Tim Peters tim.one at comcast.net
Fri Jan 30 15:17:07 EST 2004


Update of /cvs-repository/Zope/lib/python/Products/Transience/tests
In directory cvs.zope.org:/tmp/cvs-serv24806/lib/python/Products/Transience/tests

Modified Files:
      Tag: Zope-2_6-branch
	testTimeoutRelated.py 
Log Message:
testLastAccessed:  This test failed frequently on Windows, because of a
bad assumption about how time.time() works.  Repaired it.


=== Zope/lib/python/Products/Transience/tests/testTimeoutRelated.py 1.9.6.1 => 1.9.6.2 ===
--- Zope/lib/python/Products/Transience/tests/testTimeoutRelated.py:1.9.6.1	Tue Jan 21 02:56:52 2003
+++ Zope/lib/python/Products/Transience/tests/testTimeoutRelated.py	Fri Jan 30 15:17:04 2004
@@ -77,7 +77,13 @@
     def testLastAccessed(self):
         sdo = self.app.sm.new_or_existing('TempObject')
         la1 = sdo.getLastAccessed()
-        fauxtime.sleep(WRITEGRANULARITY + 1)
+        # Windows time.time() generally doesn't update more than 18.2 times
+        # per second, so we have to wait at least 1/18.2 ~= 0.055 seconds
+        # beyond WRITEGRANULARITY to be sure the time.time() result actually
+        # moves beyond WRITEGRANULARITY.  Round 0.055 up to 0.06 to be
+        # safe, and account for that fauxtime.sleep divides the faux sleep
+        # time by 60.
+        fauxtime.sleep(WRITEGRANULARITY + 0.06 * 60)
         sdo = self.app.sm.get('TempObject')
         assert sdo.getLastAccessed() > la1, (sdo.getLastAccessed(), la1)
 




More information about the Zope-Checkins mailing list