On Tue, Oct 01, 2013 at 07:14:50PM -0700, Daniel Schepler wrote:
> On Wednesday, October 02, 2013 02:45:38 AM Nikolaus Schulz wrote:
> > Hm, can you reproduce this?  I see that the test parameters there are
> > questionable, but still, the test should not fail.
> 
> Yes, I just reproduced it again.  It doesn't seem to be a 100% failure rate, 
> though, but it does fail for me most times I try to do the build.

This is really weird.  Because what the test code there does is
something like this:

  s = 24 * 60 * 60
  time_msg = time.time() - s
  time_now = time.time()
  assert time_message + s < time_now

So if this fails, time_msg == time_now.  But the resolution of the clock
should be good enough to prevent that from happening.  What do you get
on your system if you run

  $ python2 -c 'import time; print time.time() == time.time()'

If that should happen to print "False", it would be cool if you could
apply the attached patch and run ./test_archivemail once more.

You can do this in the unpacked source bypassing all the packaging
wrappers, they make no difference.

Thanks for testing!

Nikolaus

P.S. I'm leaving tomorrow and will be traveling for two weeks.  Probably
     means I won't fix this before I return.
diff --git a/archivemail b/archivemail
index 26b9aca..b958203 100755
--- a/archivemail
+++ b/archivemail
@@ -1030,7 +1030,7 @@ def is_older_than_time(time_message, max_time):
     return False
 
 
-def is_older_than_days(time_message, max_days):
+def is_older_than_days(time_message, max_days, debugtime=False):
     """Return true if a message is older than the specified number of days,
     false otherwise.
 
@@ -1046,6 +1046,10 @@ def is_older_than_days(time_message, max_days):
     secs_old_max = (max_days * 24 * 60 * 60)
     days_old = (time_now - time_message) / 24 / 60 / 60
     vprint("message is %.2f days old" % days_old)
+    if debugtime:
+        print "time_message=%.8f time_now=%.8f secs_old_max=%.8f old=%s" % \
+                (time_message, time_now, secs_old_max,
+                 time_message + secs_old_max < time_now)
     if ((time_message + secs_old_max) < time_now):
         return True
     return False
diff --git a/test_archivemail b/test_archivemail
index 7bf700f..f609fc7 100755
--- a/test_archivemail
+++ b/test_archivemail
@@ -518,7 +518,7 @@ class TestIsTooOld(unittest.TestCase):
         for minutes in range(0, 61):
             time_msg = time.time() - (25 * 60 * 60) + (minutes * 60)
             assert archivemail.is_older_than_days(time_message=time_msg,
-                max_days=1)
+                max_days=1, debugtime=(minutes == 60))
 
     def testNotOld(self):
         """with max_days=9, should be false for these dates < 9 days"""

Reply via email to