Skip to content

Commit 87c80f0

Browse files
committed
fix(tests): Normalize paths in filesystem backend. This fixes test failures on Windows
1 parent e85ddd9 commit 87c80f0

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

libs/deepagents/tests/unit_tests/backends/test_filesystem_backend.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ def test_filesystem_backend_normal_mode(tmp_path: Path):
2121
# ls_info absolute path - should only list files in root, not subdirectories
2222
infos = be.ls_info(str(root))
2323
paths = {i["path"] for i in infos}
24-
assert str(f1) in paths # File in root should be listed
25-
assert str(f2) not in paths # File in subdirectory should NOT be listed
26-
assert (str(root) + "/dir/") in paths # Directory should be listed
24+
# Normalize paths for comparison (backend returns POSIX-style paths)
25+
assert str(f1).replace("\\", "/") in paths # File in root should be listed
26+
assert str(f2).replace("\\", "/") not in paths # File in subdirectory should NOT be listed
27+
assert (str(root).replace("\\", "/") + "/dir/") in paths # Directory should be listed
2728

2829
# read, edit, write
2930
txt = be.read(str(f1))
@@ -39,7 +40,7 @@ def test_filesystem_backend_normal_mode(tmp_path: Path):
3940

4041
# glob_info
4142
g = be.glob_info("*.py", path=str(root))
42-
assert any(i["path"] == str(f2) for i in g)
43+
assert any(i["path"] == str(f2).replace("\\", "/") for i in g)
4344

4445

4546
def test_filesystem_backend_virtual_mode(tmp_path: Path):
@@ -148,15 +149,16 @@ def test_filesystem_backend_ls_normal_mode_nested(tmp_path: Path):
148149
root_listing = be.ls_info(str(root))
149150
root_paths = [fi["path"] for fi in root_listing]
150151

151-
assert str(root / "file1.txt") in root_paths
152-
assert str(root / "subdir") + "/" in root_paths
153-
assert str(root / "subdir" / "file2.txt") not in root_paths
152+
# Normalize paths for comparison (backend returns POSIX-style paths)
153+
assert str(root / "file1.txt").replace("\\", "/") in root_paths
154+
assert str(root / "subdir").replace("\\", "/") + "/" in root_paths
155+
assert str(root / "subdir" / "file2.txt").replace("\\", "/") not in root_paths
154156

155157
subdir_listing = be.ls_info(str(root / "subdir"))
156158
subdir_paths = [fi["path"] for fi in subdir_listing]
157-
assert str(root / "subdir" / "file2.txt") in subdir_paths
158-
assert str(root / "subdir" / "nested") + "/" in subdir_paths
159-
assert str(root / "subdir" / "nested" / "file3.txt") not in subdir_paths
159+
assert str(root / "subdir" / "file2.txt").replace("\\", "/") in subdir_paths
160+
assert str(root / "subdir" / "nested").replace("\\", "/") + "/" in subdir_paths
161+
assert str(root / "subdir" / "nested" / "file3.txt").replace("\\", "/") not in subdir_paths
160162

161163

162164
def test_filesystem_backend_ls_trailing_slash(tmp_path: Path):

0 commit comments

Comments
 (0)