summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2011-05-07 02:20:34 (GMT)
committerR David Murray <rdmurray@bitdance.com>2011-05-07 02:20:34 (GMT)
commit94b8ee3bffec592c62cff0334b0fdde83c2fae35 (patch)
tree5c21d9a9d10b5c5c2f82ce41c92a302bbff89dfa /Lib/test
parent6355c16d3623921cbecb156c23349b8a6fe32827 (diff)
parentcaed7fe0ffeadb681d175320574d4d51c060f07b (diff)
downloadcpython-94b8ee3bffec592c62cff0334b0fdde83c2fae35.zip
cpython-94b8ee3bffec592c62cff0334b0fdde83c2fae35.tar.gz
cpython-94b8ee3bffec592c62cff0334b0fdde83c2fae35.tar.bz2
#11999: sync based on comparing mtimes, not mtime to system clock
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_mailbox.py23
1 files changed, 10 insertions, 13 deletions
diff --git a/Lib/test/test_mailbox.py b/Lib/test/test_mailbox.py
index 45abcc8..8dc7326 100644
--- a/Lib/test/test_mailbox.py
+++ b/Lib/test/test_mailbox.py
@@ -870,21 +870,18 @@ class TestMaildir(TestMailbox):
def test_reread(self):
- # Initially, the mailbox has not been read and the time is null.
- assert getattr(self._box, '_last_read', None) is None
-
- # Refresh mailbox; the times should now be set to something.
- self._box._refresh()
- assert getattr(self._box, '_last_read', None) is not None
-
- # Put the last modified times more than one second into the past
- # (because mtime has a one second granularity, a refresh is done
- # unconditionally if called for within the same second, just in case
- # the mbox has changed).
+ # Put the last modified times more than two seconds into the past
+ # (because mtime may have a two second granularity)
for subdir in ('cur', 'new'):
os.utime(os.path.join(self._box._path, subdir),
(time.time()-5,)*2)
+ # Because mtime has a two second granularity in worst case (FAT), a
+ # refresh is done unconditionally if called for within
+ # two-second-plus-a-bit of the last one, just in case the mbox has
+ # changed; so now we have to wait for that interval to expire.
+ time.sleep(2.01 + self._box._skewfactor)
+
# Re-reading causes the ._toc attribute to be assigned a new dictionary
# object, so we'll check that the ._toc attribute isn't a different
# object.
@@ -893,7 +890,7 @@ class TestMaildir(TestMailbox):
return self._box._toc is not orig_toc
self._box._refresh()
- assert not refreshed()
+ self.assertFalse(refreshed())
# Now, write something into cur and remove it. This changes
# the mtime and should cause a re-read.
@@ -902,7 +899,7 @@ class TestMaildir(TestMailbox):
f.close()
os.unlink(filename)
self._box._refresh()
- assert refreshed()
+ self.assertTrue(refreshed())
class _TestMboxMMDF(TestMailbox):