Skip to content

Commit f78aeba

Browse files
committed
test(cli): use os.path.samefile to compare dirs
1 parent 1a504f3 commit f78aeba

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

tests/test_cli_utils.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,15 +243,15 @@ async def test_find_project_config_dir_nested():
243243

244244
# Test finding from level3_dir; should find .vectorcode in level2
245245
found_dir = await find_project_config_dir(level3_dir)
246-
assert found_dir == vectorcode_dir
246+
assert found_dir is not None and os.path.samefile(found_dir, vectorcode_dir)
247247

248248
# Test finding from level2_dir; should find .vectorcode in level2
249249
found_dir = await find_project_config_dir(level2_dir)
250-
assert found_dir == vectorcode_dir
250+
assert found_dir is not None and os.path.samefile(found_dir, vectorcode_dir)
251251

252252
# Test finding from level1_dir; should find .git in level1
253253
found_dir = await find_project_config_dir(level1_dir)
254-
assert found_dir == git_dir
254+
assert found_dir is not None and os.path.samefile(found_dir, git_dir)
255255

256256

257257
@pytest.mark.asyncio
@@ -291,12 +291,14 @@ def test_find_project_root():
291291

292292
# Test when anchor file exists
293293
os.makedirs(os.path.join(temp_dir, ".vectorcode"))
294-
assert find_project_root(temp_dir) == temp_dir
294+
found_dir = find_project_root(temp_dir)
295+
assert found_dir is not None and os.path.samefile(found_dir, temp_dir)
295296

296297
# Test when start_from is a file
297298
test_file = os.path.join(temp_dir, "test_file.txt")
298299
open(test_file, "a").close()
299-
assert find_project_root(test_file) == temp_dir
300+
found_dir = find_project_root(test_file)
301+
assert found_dir is not None and os.path.samefile(found_dir, temp_dir)
300302

301303

302304
@pytest.mark.asyncio
@@ -379,7 +381,7 @@ def test_find_project_root_file_input(tmp_path):
379381
project_root = find_project_root(temp_file)
380382

381383
# Assert that it returns the parent directory (tmp_path)
382-
assert str(project_root) == str(tmp_path)
384+
assert os.path.samefile(str(project_root), str(tmp_path))
383385

384386

385387
@pytest.mark.asyncio

0 commit comments

Comments
 (0)