aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/python/platform/default/gfile_test.py
diff options
context:
space:
mode:
authorGravatar Andrew Dai <adai@google.com>2016-01-26 14:45:31 -0800
committerGravatar Vijay Vasudevan <vrv@google.com>2016-01-26 15:08:40 -0800
commitde3fd54c1beda2861a0a0a9197328e42b54170c0 (patch)
treee355cc17ffb471f646714e3df3ed61449cc02247 /tensorflow/python/platform/default/gfile_test.py
parent5dff1a1d0e8d9e5aa63cc84742642cb7e527c1dc (diff)
Allow the list of previous checkpoints in the Saver to be set with a timestamp. Otherwise previous timestamp checkpoints could be kept forever.
Add a Stat function to the gfile module that returns the last modified time of a file. Change: 113098506
Diffstat (limited to 'tensorflow/python/platform/default/gfile_test.py')
-rw-r--r--tensorflow/python/platform/default/gfile_test.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/tensorflow/python/platform/default/gfile_test.py b/tensorflow/python/platform/default/gfile_test.py
index 023dac56de..334db154d4 100644
--- a/tensorflow/python/platform/default/gfile_test.py
+++ b/tensorflow/python/platform/default/gfile_test.py
@@ -19,6 +19,7 @@ from __future__ import print_function
import os
import shutil
+import time
from tensorflow.python.platform.default import _gfile as gfile
from tensorflow.python.platform.default import _googletest as googletest
@@ -163,6 +164,15 @@ class FunctionTests(_BaseTest, googletest.TestCase):
gfile.DeleteRecursively(self.tmp + "error_dir")
self.assertFalse(gfile.Exists(self.tmp + "error_dir"))
+ def testStat(self):
+ with gfile.GFile(self.tmp + "test_stat", "w"):
+ pass
+ creation_time = time.time()
+ statinfo = gfile.Stat(self.tmp + "test_stat")
+ # Test the modification timestamp is within 20 seconds of closing the file.
+ self.assertLessEqual(statinfo.mtime, creation_time + 10)
+ self.assertGreaterEqual(statinfo.mtime, creation_time - 10)
+
if __name__ == "__main__":
googletest.main()