Skip to content

Commit

Permalink
fix Windows tests for LocalIO.url2transport_path
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-monch committed May 14, 2024
1 parent 3074c2f commit 9955ae6
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions datalad_next/patches/tests/test_add_method_url2transport_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
http_remote_io_url2transport_path,
)

from datalad.utils import on_windows
from datalad.tests.utils_pytest import skip_if


def test_local_io_url2transport_path():

for url, transport_path in (
('/a/b/c', '/a/b/c'),
('/C:/a/b/c', '/C:/a/b/c'),
('/C:a/b/c', '/C:a/b/c'),
('C:/a/b/c', 'C:/a/b/c'),
):
assert local_io_url2transport_path(
Expand All @@ -23,6 +25,7 @@ def test_local_io_url2transport_path():
) == Path(transport_path)


@skip_if(not on_windows)
def test_local_io_url2transport_path_windows_warning(monkeypatch):
monkeypatch.setattr(
'datalad_next.patches.add_method_url2transport_path.on_windows',
Expand All @@ -33,8 +36,19 @@ def test_local_io_url2transport_path_windows_warning(monkeypatch):
'datalad_next.patches.add_method_url2transport_path.lgr.warning',
lambda x: warnings.append(x),
)
local_io_url2transport_path(None, PurePosixPath('/C:a/b/c'))
assert len(warnings) == 1

for url, transport_path in (
('/a/b/c', '/a/b/c'),
('C:/a/b/c', 'C:/a/b/c'),
('C:a/b/c', 'C:a/b/c'),
('/C:a/b/c', 'C:a/b/c'),
('/C:/a/b/c', 'C:/a/b/c'),
):
assert local_io_url2transport_path(
None,
PurePosixPath(url)
) == Path(transport_path)
assert len(warnings) > 0


def test_http_remote_io_url2transport_path():
Expand Down

0 comments on commit 9955ae6

Please sign in to comment.