Skip to content

Commit a9539a1

Browse files
committed
test(listdir): enhance tests for listdir_matching with fullpath and recursive checks
1 parent ce25066 commit a9539a1

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

tests/test_pathtools.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,20 @@ def test_listdir_matching_various(tmpdir):
141141
# fullpath returns absolute paths
142142
res_full = listdir_matching(str(base), ".tif", fullpath=True)
143143
assert all(os.path.isabs(x) for x in res_full)
144+
assert os.path.join(str(base), "a.TIF") in res_full
145+
assert os.path.join(str(base), "b.tif") in res_full
144146

145147
# recursive with relative paths
146148
sub = base.mkdir("sub")
147149
sub.join("s.TIF").write("x")
148150
res_rec = listdir_matching(str(base), ".tif", recursive=True)
149151
# should include the file from subdir as a relative path
150-
assert "sub/" in "/".join(res_rec) or any(p.startswith("sub/") for p in res_rec)
152+
assert "sub/s.TIF" in [p.replace(os.sep, "/") for p in res_rec]
153+
154+
# recursive with fullpath
155+
res_rec_full = listdir_matching(str(base), ".tif", recursive=True, fullpath=True)
156+
assert all(os.path.isabs(x) for x in res_rec_full)
157+
assert os.path.join(str(sub), "s.TIF") in res_rec_full
151158

152159
# regex matching
153160
res_regex = listdir_matching(str(base), r".*\.tif$", regex=True)

0 commit comments

Comments
 (0)