Merge #9557: eliminate 3 seconds of static overhead from test_mailbox.
This commit is contained in:
commit
79fe2a3462
|
@ -869,8 +869,6 @@ class TestMaildir(TestMailbox):
|
||||||
self.assertFalse((perms & 0o111)) # Execute bits should all be off.
|
self.assertFalse((perms & 0o111)) # Execute bits should all be off.
|
||||||
|
|
||||||
def test_reread(self):
|
def test_reread(self):
|
||||||
# Wait for 2 seconds
|
|
||||||
time.sleep(2)
|
|
||||||
|
|
||||||
# Initially, the mailbox has not been read and the time is null.
|
# Initially, the mailbox has not been read and the time is null.
|
||||||
assert getattr(self._box, '_last_read', None) is None
|
assert getattr(self._box, '_last_read', None) is None
|
||||||
|
@ -879,15 +877,21 @@ class TestMaildir(TestMailbox):
|
||||||
self._box._refresh()
|
self._box._refresh()
|
||||||
assert getattr(self._box, '_last_read', None) is not None
|
assert getattr(self._box, '_last_read', None) is not None
|
||||||
|
|
||||||
# Try calling _refresh() again; the modification times shouldn't have
|
# Put the last modified times more than one second into the past
|
||||||
# changed, so the mailbox should not be re-reading. Re-reading causes
|
# (because mtime has a one second granularity, a refresh is done
|
||||||
# the ._toc attribute to be assigned a new dictionary object, so
|
# unconditionally if called for within the same second, just in case
|
||||||
# we'll check that the ._toc attribute isn't a different object.
|
# 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
|
orig_toc = self._box._toc
|
||||||
def refreshed():
|
def refreshed():
|
||||||
return self._box._toc is not orig_toc
|
return self._box._toc is not orig_toc
|
||||||
|
|
||||||
time.sleep(1) # Wait 1sec to ensure time.time()'s value changes
|
|
||||||
self._box._refresh()
|
self._box._refresh()
|
||||||
assert not refreshed()
|
assert not refreshed()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue