|
1 | 1 | """Test edge cases in the WatchService.""" |
2 | 2 |
|
3 | | -from pathlib import Path |
4 | 3 | from unittest.mock import patch |
5 | 4 |
|
6 | 5 | import pytest |
@@ -103,9 +102,8 @@ async def test_handle_vim_atomic_write_delete_still_exists(watch_service, projec |
103 | 102 | test_file.write_text(modified_content) |
104 | 103 |
|
105 | 104 | # Setup DELETE event even though file still exists (vim's atomic write behavior) |
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)} |
| 105 | + # Use absolute path like the real watch service would |
| 106 | + changes = {(Change.deleted, str(test_file))} |
109 | 107 |
|
110 | 108 | # Handle the change |
111 | 109 | await watch_service.handle_changes(test_project, changes) |
@@ -155,12 +153,10 @@ async def test_handle_true_deletion_vs_vim_atomic(watch_service, project_config, |
155 | 153 | delete_file.unlink() |
156 | 154 |
|
157 | 155 | # 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)) |
| 156 | + # Use absolute paths like the real watch service would |
161 | 157 | changes = { |
162 | | - (Change.deleted, atomic_relative), # File still exists - atomic write |
163 | | - (Change.deleted, delete_relative), # File deleted - true deletion |
| 158 | + (Change.deleted, str(atomic_file)), # File still exists - atomic write |
| 159 | + (Change.deleted, str(delete_file)), # File deleted - true deletion |
164 | 160 | } |
165 | 161 |
|
166 | 162 | # Handle the changes |
@@ -235,9 +231,8 @@ async def test_handle_vim_atomic_write_markdown_with_relations(watch_service, pr |
235 | 231 | main_file.write_text(modified_content) |
236 | 232 |
|
237 | 233 | # Setup DELETE event (vim atomic write) |
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)} |
| 234 | + # Use absolute path like the real watch service would |
| 235 | + changes = {(Change.deleted, str(main_file))} |
241 | 236 |
|
242 | 237 | # Handle the change |
243 | 238 | await watch_service.handle_changes(test_project, changes) |
@@ -267,9 +262,8 @@ async def test_handle_vim_atomic_write_directory_path_ignored(watch_service, pro |
267 | 262 | test_dir.mkdir() |
268 | 263 |
|
269 | 264 | # Setup DELETE event for directory (should be ignored) |
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)} |
| 265 | + # Use absolute path like the real watch service would |
| 266 | + changes = {(Change.deleted, str(test_dir))} |
273 | 267 |
|
274 | 268 | # Handle the change - should not cause errors |
275 | 269 | await watch_service.handle_changes(test_project, changes) |
|
0 commit comments