|
12 | 12 | from unittest.mock import patch |
13 | 13 | from pathvalidate import sanitize_filename |
14 | 14 | from pygeodiff import GeoDiff |
| 15 | +from pathlib import PureWindowsPath |
15 | 16 |
|
16 | 17 | from ..utils import save_diagnostic_log_file |
17 | 18 |
|
@@ -228,15 +229,22 @@ def test_is_valid_path(client, filepath, allow): |
228 | 229 | assert is_valid_path(filepath) == allow |
229 | 230 |
|
230 | 231 |
|
231 | | -test_paths = [ |
232 | | - ("photos /lutraHQ.jpg", True), |
233 | | - ("photo s/ lutraHQ.jpg", False), |
| 232 | +trailing_spaces_paths = [ |
| 233 | + ("photos /lutraHQ.jpg", "posix", True), |
| 234 | + ("photo s/ lutraHQ.jpg", "posix", False), |
| 235 | + ("assets\photos \lutraHQ.jpg", "windows", True), |
| 236 | + ("assets\ photos\lutraHQ.jpg", "windows", False), |
234 | 237 | ] |
235 | 238 |
|
236 | 239 |
|
237 | | -@pytest.mark.parametrize("path,result", test_paths) |
238 | | -def test_has_trailing_space(path, result): |
239 | | - assert has_trailing_space(path) is result |
| 240 | +@pytest.mark.parametrize("path,path_platform,result", trailing_spaces_paths) |
| 241 | +def test_has_trailing_space(path, path_platform, result): |
| 242 | + if path_platform == "windows": |
| 243 | + # we must mock Path to instantiate as Windows path |
| 244 | + with patch("mergin.sync.utils.Path", PureWindowsPath): |
| 245 | + assert has_trailing_space(path) is result |
| 246 | + else: |
| 247 | + assert has_trailing_space(path) is result |
240 | 248 |
|
241 | 249 |
|
242 | 250 | def test_get_x_accell_uri(client): |
|
0 commit comments