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

Function test_walk_dir

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

Source from the content-addressed store, hash-verified

161
162
163def test_walk_dir(tmp_dir, dvc):
164 tmp_dir.gen(
165 {
166 "dir": {
167 "subdir1": {"foo1": "foo1", "bar1": "bar1"},
168 "subdir2": {"foo2": "foo2"},
169 "foo": "foo",
170 "bar": "bar",
171 }
172 }
173 )
174
175 dvc.add("dir")
176 fs = DataFileSystem(index=dvc.index.data["repo"])
177
178 expected = [
179 "dir/subdir1",
180 "dir/subdir2",
181 "dir/subdir1/foo1",
182 "dir/subdir1/bar1",
183 "dir/subdir2/foo2",
184 "dir/foo",
185 "dir/bar",
186 ]
187
188 actual = []
189 for root, dirs, files in fs.walk("dir"):
190 for entry in dirs + files:
191 actual.append(posixpath.join(root, entry))
192
193 assert set(actual) == set(expected)
194 assert len(actual) == len(expected)
195
196
197def test_walk_missing(tmp_dir, dvc):

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected