diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2012-02-08 03:09:37 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2012-02-08 03:09:37 (GMT) |
commit | 1aa54a417d767efb2ebb4c1a31e69f7be9b1d6ae (patch) | |
tree | 2f52f3ed2ba3f7d4ce5fc1af4b779915f657e01c /Lib/test | |
parent | a2f7c0063852dd67585709cc1edacb4bafbd5ba8 (diff) | |
download | cpython-1aa54a417d767efb2ebb4c1a31e69f7be9b1d6ae.zip cpython-1aa54a417d767efb2ebb4c1a31e69f7be9b1d6ae.tar.gz cpython-1aa54a417d767efb2ebb4c1a31e69f7be9b1d6ae.tar.bz2 |
Issue #13964: Skip os.*utime*() tests if os.stat() doesn't support timestamp
with a subsecond resolution
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_os.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index e44174c..4d27c2b 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -27,6 +27,14 @@ try: except ImportError: threading = None +os.stat_float_times(True) +st = os.stat(__file__) +stat_supports_subsecond = ( + # check if float and int timestamps are different + (st.st_atime != st[7]) + or (st.st_mtime != st[8]) + or (st.st_ctime != st[9])) + # Detect whether we're on a Linux system that uses the (now outdated # and unmaintained) linuxthreads threading library. There's an issue # when combining linuxthreads with a failed execv call: see @@ -300,6 +308,8 @@ class StatAttributeTests(unittest.TestCase): st2 = os.stat(support.TESTFN) self.assertAlmostEqual(st1.st_mtime, st2.st_mtime, delta=10) + @unittest.skipUnless(stat_supports_subsecond, + "os.stat() doesn't has a subsecond resolution") def _test_utime_subsecond(self, set_time_func): asec, amsec = 1, 901 atime = asec + amsec * 1e-3 @@ -308,6 +318,7 @@ class StatAttributeTests(unittest.TestCase): filename = self.fname os.utime(filename, (0, 0)) set_time_func(filename, atime, mtime) + os.stat_float_times(True) st = os.stat(filename) self.assertAlmostEqual(st.st_atime, atime, places=3) self.assertAlmostEqual(st.st_mtime, mtime, places=3) |