diff options
author | Petri Lehtinen <petri@digip.org> | 2011-11-12 19:02:42 (GMT) |
---|---|---|
committer | Petri Lehtinen <petri@digip.org> | 2011-11-12 19:14:53 (GMT) |
commit | c153cd3d5a08da96d84e83c408033d5793943496 (patch) | |
tree | fbf716c1c15ad1244cb540433b9126eaa4743432 /Lib/test | |
parent | 3714c1ebfd12e99e9bf95b9d9867aca3872bce55 (diff) | |
download | cpython-c153cd3d5a08da96d84e83c408033d5793943496.zip cpython-c153cd3d5a08da96d84e83c408033d5793943496.tar.gz cpython-c153cd3d5a08da96d84e83c408033d5793943496.tar.bz2 |
Update mailbox.Maildir tests
Remove a sleep to fix transient test failures. Use skewfactor of -3 to
make it work on systems that have 1 second precision for time.time().
Closes #11999
Refs #13254
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_mailbox.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/Lib/test/test_mailbox.py b/Lib/test/test_mailbox.py index e0d8da2..007c419 100644 --- a/Lib/test/test_mailbox.py +++ b/Lib/test/test_mailbox.py @@ -815,7 +815,7 @@ class TestMaildir(TestMailbox): # 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._skewfactor = -3 self._box._refresh() self.assertEqual(sorted(self._box._toc.keys()), sorted([key0, key1])) @@ -908,7 +908,12 @@ class TestMaildir(TestMailbox): # 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) + # + # Because this is a test, emulate sleeping. Instead of + # sleeping for 2 seconds, use the skew factor to make _refresh + # think that 2 seconds have passed and re-reading the _toc is + # only required if mtimes differ. + self._box._skewfactor = -3 # 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 @@ -921,7 +926,8 @@ class TestMaildir(TestMailbox): self.assertFalse(refreshed()) # Now, write something into cur and remove it. This changes - # the mtime and should cause a re-read. + # the mtime and should cause a re-read. Note that "sleep + # emulation" is still in effect, as skewfactor is -3. filename = os.path.join(self._path, 'cur', 'stray-file') f = open(filename, 'w') f.close() |