summaryrefslogtreecommitdiff
path: root/Lib/test/test_mailbox.py
diff options
context:
space:
mode:
authorPetri Lehtinen <petri@digip.org>2011-11-05 09:50:37 +0200
committerPetri Lehtinen <petri@digip.org>2011-11-05 09:50:37 +0200
commit49aa72ed4c48fb613893388b470aa5b5464c1952 (patch)
treefd89d82285b9a43d66b9c8d12b27849dfeaf5116 /Lib/test/test_mailbox.py
parent5d19b9a1e809ee20ba4f26e4aa04922452d0f15f (diff)
downloadcpython-git-49aa72ed4c48fb613893388b470aa5b5464c1952.tar.gz
Fix Maildir initialization so that maildir contents are read correctly.
Closes #13254.
Diffstat (limited to 'Lib/test/test_mailbox.py')
-rw-r--r--Lib/test/test_mailbox.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/test/test_mailbox.py b/Lib/test/test_mailbox.py
index 112497993c..97d304758e 100644
--- a/Lib/test/test_mailbox.py
+++ b/Lib/test/test_mailbox.py
@@ -683,6 +683,25 @@ class TestMaildir(TestMailbox):
key1: os.path.join('new', key1),
key2: os.path.join('new', key2)})
+ def test_refresh_after_safety_period(self):
+ # Issue #13254: Call _refresh after the "file system safety
+ # period" of 2 seconds has passed; _toc should still be
+ # updated because this is the first call to _refresh.
+ key0 = self._box.add(self._template % 0)
+ key1 = self._box.add(self._template % 1)
+
+ self._box = self._factory(self._path)
+ self.assertEqual(self._box._toc, {})
+
+ # Emulate sleeping. Instead of sleeping for 2 seconds, use the
+ # skew factor to make _refresh think that the filesystem
+ # safety period has passed and re-reading the _toc is only
+ # required if mtimes differ.
+ self._box._skewfactor = -2
+
+ self._box._refresh()
+ self.assertEqual(sorted(self._box._toc.keys()), sorted([key0, key1]))
+
def test_lookup(self):
# Look up message subpaths in the TOC
self.assertRaises(KeyError, lambda: self._box._lookup('foo'))
@@ -758,6 +777,8 @@ class TestMaildir(TestMailbox):
self.assertFalse((perms & 0111)) # Execute bits should all be off.
def test_reread(self):
+ # Do an initial unconditional refresh
+ self._box._refresh()
# Put the last modified times more than two seconds into the past
# (because mtime may have only a two second granularity).