diff tests/test-filecache.py @ 36781:ffa3026d4196

cleanup: use stat_result[stat.ST_MTIME] instead of stat_result.st_mtime The latter is floating point by default, and we've been doing os.stat_float_times(False). Unfortunately, os.stat_float_times was removed between Python 3.7.0a1 and 3.7.0b2, so we have to stop using it. Differential Revision: https://phab.mercurial-scm.org/D2696
author Augie Fackler <augie@google.com>
date Mon, 05 Mar 2018 12:30:20 -0500
parents daa5f47558cf
children b3ffa2faae04
line wrap: on
line diff
--- a/tests/test-filecache.py	Mon Mar 05 15:07:32 2018 -0500
+++ b/tests/test-filecache.py	Mon Mar 05 12:30:20 2018 -0500
@@ -1,5 +1,6 @@
 from __future__ import absolute_import, print_function
 import os
+import stat
 import subprocess
 import sys
 
@@ -200,7 +201,7 @@
         fp.close()
 
         oldstat = os.stat(filename)
-        if oldstat.st_ctime != oldstat.st_mtime:
+        if oldstat[stat.ST_CTIME] != oldstat[stat.ST_MTIME]:
             # subsequent changing never causes ambiguity
             continue
 
@@ -219,16 +220,17 @@
                 fp.write('BAR')
 
         newstat = os.stat(filename)
-        if oldstat.st_ctime != newstat.st_ctime:
+        if oldstat[stat.ST_CTIME] != newstat[stat.ST_CTIME]:
             # timestamp ambiguity was naturally avoided while repetition
             continue
 
         # st_mtime should be advanced "repetition * 2" times, because
         # all changes occurred at same time (in sec)
-        expected = (oldstat.st_mtime + repetition * 2) & 0x7fffffff
-        if newstat.st_mtime != expected:
-            print("'newstat.st_mtime %s is not %s (as %s + %s * 2)" %
-                  (newstat.st_mtime, expected, oldstat.st_mtime, repetition))
+        expected = (oldstat[stat.ST_MTIME] + repetition * 2) & 0x7fffffff
+        if newstat[stat.ST_MTIME] != expected:
+            print("'newstat[stat.ST_MTIME] %s is not %s (as %s + %s * 2)" %
+                  (newstat[stat.ST_MTIME], expected,
+                   oldstat[stat.ST_MTIME], repetition))
 
         # no more examination is needed regardless of result
         break