with gfile.GFile(self.tmp + "dir2/file2", "w"): pass # Create file # Dest file already exists, overwrite=False (default). self.assertRaises( OSError, lambda: gfile.Copy(self.tmp + "dir1/file1", self.tmp + "dir2/file2")) # Overwrite succeeds gfile.Copy(self.tmp + "dir1/file1", self.tmp + "dir2/file2", overwrite=True) self.assertTrue(gfile.Exists(self.tmp + "dir2/file2")) # Normal copy. gfile.Rename(self.tmp + "dir1/file1", self.tmp + "dir2/file1") self.assertTrue(gfile.Exists(self.tmp + "dir2/file1")) # Normal copy to non-existent dir self.assertRaises(OSError, lambda: gfile.Rename(self.tmp + "dir1/file1", self.tmp + "newdir/file1")) def testOpen(self): with gfile.Open(self.tmp + "test_open", "wb") as f: f.write(b"foo") with gfile.Open(self.tmp + "test_open") as f: result = f.readlines() self.assertEqual(["foo"], result) if __name__ == "__main__": googletest.main()
from tensorflow.python.platform.default import _googletest as googletest from tensorflow.python.platform.default import _logging as logging class EventLoaderTest(googletest.TestCase): def test_log(self): # Just check that logging works without raising an exception. logging.error("test log message") if __name__ == "__main__": googletest.main()