summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_mailbox.py
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2011-03-25 20:03:47 (GMT)
committerR David Murray <rdmurray@bitdance.com>2011-03-25 20:03:47 (GMT)
commitb9a428d57de898271bf160f736bbae7e2538bc41 (patch)
treeb6c9ef90ea59408c53701b995c10670f0f7d2a49 /Lib/test/test_mailbox.py
parentebbf1e67a8c56a79ee62280d32517e77b103bf8e (diff)
downloadcpython-b9a428d57de898271bf160f736bbae7e2538bc41.zip
cpython-b9a428d57de898271bf160f736bbae7e2538bc41.tar.gz
cpython-b9a428d57de898271bf160f736bbae7e2538bc41.tar.bz2
#9557: eliminate 3 seconds of static overhead from test_mailbox.
This patch doesn't quite fix the 'run in a VM with Samba share' timing problem, but it should at least make it better.
Diffstat (limited to 'Lib/test/test_mailbox.py')
-rw-r--r--Lib/test/test_mailbox.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/Lib/test/test_mailbox.py b/Lib/test/test_mailbox.py
index 9a43f88..dd13c72 100644
--- a/Lib/test/test_mailbox.py
+++ b/Lib/test/test_mailbox.py
@@ -741,8 +741,6 @@ class TestMaildir(TestMailbox):
self.assertFalse((perms & 0o111)) # Execute bits should all be off.
def test_reread(self):
- # Wait for 2 seconds
- time.sleep(2)
# Initially, the mailbox has not been read and the time is null.
assert getattr(self._box, '_last_read', None) is None
@@ -751,15 +749,21 @@ class TestMaildir(TestMailbox):
self._box._refresh()
assert getattr(self._box, '_last_read', None) is not None
- # Try calling _refresh() again; the modification times shouldn't have
- # changed, so the mailbox should not be re-reading. 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.
+ # 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).
+ for subdir in ('cur', 'new'):
+ os.utime(os.path.join(self._box._path, subdir),
+ (time.time()-5,)*2)
+
+ # 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.
orig_toc = self._box._toc
def refreshed():
return self._box._toc is not orig_toc
- time.sleep(1) # Wait 1sec to ensure time.time()'s value changes
self._box._refresh()
assert not refreshed()