MCPcopy
hub / github.com/treeverse/dvc / test_walk

Function test_walk

tests/unit/fs/test_data.py:129–160  ·  view source on GitHub ↗
(tmp_dir, dvc)

Source from the content-addressed store, hash-verified

127
128
129def test_walk(tmp_dir, dvc):
130 tmp_dir.gen(
131 {
132 "dir": {
133 "subdir1": {"foo1": "foo1", "bar1": "bar1"},
134 "subdir2": {"foo2": "foo2"},
135 "foo": "foo",
136 "bar": "bar",
137 }
138 }
139 )
140
141 dvc.add(localfs.find("dir"))
142 fs = DataFileSystem(index=dvc.index.data["repo"])
143
144 expected = [
145 "dir/subdir1",
146 "dir/subdir2",
147 "dir/subdir1/foo1",
148 "dir/subdir1/bar1",
149 "dir/subdir2/foo2",
150 "dir/foo",
151 "dir/bar",
152 ]
153
154 actual = []
155 for root, dirs, files in fs.walk("dir"):
156 for entry in dirs + files:
157 actual.append(posixpath.join(root, entry))
158
159 assert set(actual) == set(expected)
160 assert len(actual) == len(expected)
161
162
163def test_walk_dir(tmp_dir, dvc):

Callers

nothing calls this directly

Calls 7

DataFileSystemClass · 0.90
walkMethod · 0.80
appendMethod · 0.80
joinMethod · 0.80
genMethod · 0.45
addMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected