Round to int, because some systems support sub-second time stamps in stat, but not in utime.

Also be consistent with modifying only mtime, not atime.
This commit is contained in:
Martin v. Löwis 2006-10-15 11:02:07 +00:00
parent 012bc7253b
commit a97e06d9db
1 changed files with 4 additions and 2 deletions

View File

@ -226,9 +226,11 @@ class StatAttributeTests(unittest.TestCase):
def test_utime_dir(self): def test_utime_dir(self):
delta = 1000000 delta = 1000000
st = os.stat(test_support.TESTFN) st = os.stat(test_support.TESTFN)
os.utime(test_support.TESTFN, (st.st_atime, st.st_mtime-delta)) # round to int, because some systems may support sub-second
# time stamps in stat, but not in utime.
os.utime(test_support.TESTFN, (st.st_atime, int(st.st_mtime-delta)))
st2 = os.stat(test_support.TESTFN) st2 = os.stat(test_support.TESTFN)
self.assertAlmostEquals(st2.st_mtime, st.st_mtime-delta, 2) self.assertEquals(st2.st_mtime, int(st.st_mtime-delta))
# Restrict test to Win32, since there is no guarantee other # Restrict test to Win32, since there is no guarantee other
# systems support centiseconds # systems support centiseconds