Skip to content

Commit 53d7660

Browse files
committed
tests: add more make_posix_path tests
1 parent 374fab4 commit 53d7660

File tree

1 file changed

+62
-3
lines changed

1 file changed

+62
-3
lines changed

fsspec/implementations/tests/test_local.py

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,62 @@ def test_make_path_posix():
535535
assert userpath.endswith("/path")
536536

537537

538+
@pytest.mark.parametrize(
539+
"path",
540+
[
541+
"/abc/def",
542+
"abc/def",
543+
"",
544+
".",
545+
"//server/share",
546+
"C:\\",
547+
"d:/abc/def",
548+
"e:",
549+
pytest.param(
550+
"f:foo",
551+
marks=[pytest.mark.xfail(WIN, reason="unsupported")],
552+
id="relative-path-with-drive",
553+
),
554+
],
555+
)
556+
def test_make_path_posix_returns_absolute_paths(path):
557+
posix_pth = make_path_posix(path)
558+
assert os.path.isabs(posix_pth)
559+
560+
561+
@pytest.mark.parametrize("container_cls", [list, set, tuple])
562+
def test_make_path_posix_set_list_tuple(container_cls):
563+
paths = container_cls(
564+
[
565+
"/foo/bar",
566+
"bar/foo",
567+
]
568+
)
569+
posix_paths = make_path_posix(paths)
570+
assert isinstance(posix_paths, container_cls)
571+
assert posix_paths == container_cls(
572+
[
573+
make_path_posix("/foo/bar"),
574+
make_path_posix("bar/foo"),
575+
]
576+
)
577+
578+
579+
@pytest.mark.parametrize(
580+
"obj",
581+
[
582+
1,
583+
True,
584+
None,
585+
object(),
586+
],
587+
)
588+
@pytest.mark.xfail(reason="all inputs coerced to string")
589+
def test_make_path_posix_wrong_type(obj):
590+
with pytest.raises(AttributeError): # should probably be changed to TypeError
591+
make_path_posix(obj)
592+
593+
538594
def test_parent():
539595
if WIN:
540596
assert LocalFileSystem._parent("C:\\file or folder") == "C:/"
@@ -576,7 +632,6 @@ def test_parent():
576632
("local:///", "/"),
577633
("/file or folder", "/"),
578634
("/file or folder/", "/"),
579-
("file:///", "/"),
580635
("file:///path", "/"),
581636
("file://c/", "{cwd}"),
582637
],
@@ -764,6 +819,8 @@ def test_strip_protocol_relative_paths(uri, expected, cwd):
764819
posixonly("file:/foo/bar", "/foo/bar"),
765820
winonly("file:/foo/bar", "{current_drive}/foo/bar"),
766821
winonly("file:\\foo\\bar", "{current_drive}/foo/bar"),
822+
winonly("file:D:\\path\\file", "D:/path/file"),
823+
winonly("file:/D:\\path\\file", "D:/path/file"),
767824
winonly("file://D:\\path\\file", "D:/path/file"),
768825
],
769826
)
@@ -800,7 +857,9 @@ def test_strip_protocol_no_authority(uri, expected, cwd, current_drive):
800857
pytest.param(
801858
"file://localhost/c:/path",
802859
"c:/path",
803-
marks=pytest.mark.xfail(reason="not supported"),
860+
marks=pytest.mark.xfail(
861+
reason="rfc8089 section3 'localhost uri' not supported"
862+
),
804863
),
805864
],
806865
)
@@ -820,7 +879,7 @@ def test_strip_protocol_absolute_paths(uri, expected, current_drive, cwd):
820879
],
821880
)
822881
@pytest.mark.skipif(not WIN, reason="Windows only")
823-
@pytest.mark.xfail(WIN, reason="not supported")
882+
@pytest.mark.xfail(WIN, reason="legacy dos uris not supported")
824883
def test_strip_protocol_legacy_dos_uris(uri, expected):
825884
stripped = LocalFileSystem._strip_protocol(uri)
826885
assert expected == stripped

0 commit comments

Comments
 (0)