MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / testWalkInOrder

Method testWalkInOrder

tensorflow/python/lib/io/file_io_test.py:279–304  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

277 file_io.create_dir(os.path.join(dir_path, "subdir1_2/subdir2"))
278
279 def testWalkInOrder(self):
280 dir_path = os.path.join(self._base_dir, "test_dir")
281 self._setupWalkDirectories(dir_path)
282 # Now test the walk (in_order = True)
283 all_dirs = []
284 all_subdirs = []
285 all_files = []
286 for (w_dir, w_subdirs, w_files) in file_io.walk(dir_path, in_order=True):
287 all_dirs.append(w_dir)
288 all_subdirs.append(w_subdirs)
289 all_files.append(w_files)
290 self.assertItemsEqual(all_dirs, [dir_path] + [
291 os.path.join(dir_path, item)
292 for item in
293 ["subdir1_1", "subdir1_2", "subdir1_2/subdir2", "subdir1_3"]
294 ])
295 self.assertEqual(dir_path, all_dirs[0])
296 self.assertLess(
297 all_dirs.index(os.path.join(dir_path, "subdir1_2")),
298 all_dirs.index(os.path.join(dir_path, "subdir1_2/subdir2")))
299 self.assertItemsEqual(all_subdirs[1:5], [[], ["subdir2"], [], []])
300 self.assertItemsEqual(all_subdirs[0],
301 ["subdir1_1", "subdir1_2", "subdir1_3"])
302 self.assertItemsEqual(all_files, [["file1.txt"], ["file2.txt"], [], [], []])
303 self.assertLess(
304 all_files.index(["file1.txt"]), all_files.index(["file2.txt"]))
305
306 def testWalkPostOrder(self):
307 dir_path = os.path.join(self._base_dir, "test_dir")

Callers

nothing calls this directly

Calls 4

_setupWalkDirectoriesMethod · 0.95
joinMethod · 0.45
appendMethod · 0.45
indexMethod · 0.45

Tested by

no test coverage detected