@@ -869,8 +869,6 @@ def test_folder_file_perms(self):
869869 self .assertFalse ((perms & 0o111 )) # Execute bits should all be off.
870870
871871 def test_reread (self ):
872- # Wait for 2 seconds
873- time .sleep (2 )
874872
875873 # Initially, the mailbox has not been read and the time is null.
876874 assert getattr (self ._box , '_last_read' , None ) is None
@@ -879,15 +877,21 @@ def test_reread(self):
879877 self ._box ._refresh ()
880878 assert getattr (self ._box , '_last_read' , None ) is not None
881879
882- # Try calling _refresh() again; the modification times shouldn't have
883- # changed, so the mailbox should not be re-reading. Re-reading causes
884- # the ._toc attribute to be assigned a new dictionary object, so
885- # we'll check that the ._toc attribute isn't a different object.
880+ # Put the last modified times more than one second into the past
881+ # (because mtime has a one second granularity, a refresh is done
882+ # unconditionally if called for within the same second, just in case
883+ # the mbox has changed).
884+ for subdir in ('cur' , 'new' ):
885+ os .utime (os .path .join (self ._box ._path , subdir ),
886+ (time .time ()- 5 ,)* 2 )
887+
888+ # Re-reading causes the ._toc attribute to be assigned a new dictionary
889+ # object, so we'll check that the ._toc attribute isn't a different
890+ # object.
886891 orig_toc = self ._box ._toc
887892 def refreshed ():
888893 return self ._box ._toc is not orig_toc
889894
890- time .sleep (1 ) # Wait 1sec to ensure time.time()'s value changes
891895 self ._box ._refresh ()
892896 assert not refreshed ()
893897
0 commit comments