Skip to content

Commit ef3b679

Browse files
fix: correct path handling in vim atomic write tests
The vim atomic write tests were failing because they passed absolute paths to handle_changes(), but the watch service expects relative paths (it converts absolute paths from the file watcher to relative paths internally). Fixed by converting absolute paths to relative paths in test setup to match the actual watch service behavior. Co-authored-by: Paul Hernandez <phernandez@users.noreply.github.com>
1 parent 5b5afda commit ef3b679

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

tests/sync/test_watch_service_edge_cases.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ async def test_handle_vim_atomic_write_delete_still_exists(watch_service, projec
103103
test_file.write_text(modified_content)
104104

105105
# Setup DELETE event even though file still exists (vim's atomic write behavior)
106-
changes = {(Change.deleted, str(test_file))}
106+
# Use relative path like the real watch service would
107+
relative_path = str(test_file.relative_to(project_dir))
108+
changes = {(Change.deleted, relative_path)}
107109

108110
# Handle the change
109111
await watch_service.handle_changes(test_project, changes)
@@ -153,9 +155,12 @@ async def test_handle_true_deletion_vs_vim_atomic(watch_service, project_config,
153155
delete_file.unlink()
154156

155157
# Setup DELETE events for both files
158+
# Use relative paths like the real watch service would
159+
atomic_relative = str(atomic_file.relative_to(project_dir))
160+
delete_relative = str(delete_file.relative_to(project_dir))
156161
changes = {
157-
(Change.deleted, str(atomic_file)), # File still exists - atomic write
158-
(Change.deleted, str(delete_file)), # File deleted - true deletion
162+
(Change.deleted, atomic_relative), # File still exists - atomic write
163+
(Change.deleted, delete_relative), # File deleted - true deletion
159164
}
160165

161166
# Handle the changes
@@ -230,7 +235,9 @@ async def test_handle_vim_atomic_write_markdown_with_relations(watch_service, pr
230235
main_file.write_text(modified_content)
231236

232237
# Setup DELETE event (vim atomic write)
233-
changes = {(Change.deleted, str(main_file))}
238+
# Use relative path like the real watch service would
239+
relative_path = str(main_file.relative_to(project_dir))
240+
changes = {(Change.deleted, relative_path)}
234241

235242
# Handle the change
236243
await watch_service.handle_changes(test_project, changes)
@@ -260,7 +267,9 @@ async def test_handle_vim_atomic_write_directory_path_ignored(watch_service, pro
260267
test_dir.mkdir()
261268

262269
# Setup DELETE event for directory (should be ignored)
263-
changes = {(Change.deleted, str(test_dir))}
270+
# Use relative path like the real watch service would
271+
relative_path = str(test_dir.relative_to(project_dir))
272+
changes = {(Change.deleted, relative_path)}
264273

265274
# Handle the change - should not cause errors
266275
await watch_service.handle_changes(test_project, changes)

0 commit comments

Comments
 (0)