(self)
| 1007 | self.assertFalse((perms & 0o111)) # Execute bits should all be off. |
| 1008 | |
| 1009 | def test_reread(self): |
| 1010 | # Do an initial unconditional refresh |
| 1011 | self._box._refresh() |
| 1012 | |
| 1013 | # Put the last modified times more than two seconds into the past |
| 1014 | # (because mtime may have a two second granularity) |
| 1015 | for subdir in ('cur', 'new'): |
| 1016 | os.utime(os.path.join(self._box._path, subdir), |
| 1017 | (time.time()-5,)*2) |
| 1018 | |
| 1019 | # Because mtime has a two second granularity in worst case (FAT), a |
| 1020 | # refresh is done unconditionally if called for within |
| 1021 | # two-second-plus-a-bit of the last one, just in case the mbox has |
| 1022 | # changed; so now we have to wait for that interval to expire. |
| 1023 | # |
| 1024 | # Because this is a test, emulate sleeping. Instead of |
| 1025 | # sleeping for 2 seconds, use the skew factor to make _refresh |
| 1026 | # think that 2 seconds have passed and re-reading the _toc is |
| 1027 | # only required if mtimes differ. |
| 1028 | self._box._skewfactor = -3 |
| 1029 | |
| 1030 | # Re-reading causes the ._toc attribute to be assigned a new dictionary |
| 1031 | # object, so we'll check that the ._toc attribute isn't a different |
| 1032 | # object. |
| 1033 | orig_toc = self._box._toc |
| 1034 | def refreshed(): |
| 1035 | return self._box._toc is not orig_toc |
| 1036 | |
| 1037 | self._box._refresh() |
| 1038 | self.assertFalse(refreshed()) |
| 1039 | |
| 1040 | # Now, write something into cur and remove it. This changes |
| 1041 | # the mtime and should cause a re-read. Note that "sleep |
| 1042 | # emulation" is still in effect, as skewfactor is -3. |
| 1043 | filename = os.path.join(self._path, 'cur', 'stray-file') |
| 1044 | os_helper.create_empty_file(filename) |
| 1045 | os.unlink(filename) |
| 1046 | self._box._refresh() |
| 1047 | self.assertTrue(refreshed()) |
| 1048 | |
| 1049 | |
| 1050 | class _TestSingleFile(TestMailbox): |
nothing calls this directly
no test coverage detected