@@ -535,6 +535,62 @@ def test_make_path_posix():
535
535
assert userpath .endswith ("/path" )
536
536
537
537
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
+
538
594
def test_parent ():
539
595
if WIN :
540
596
assert LocalFileSystem ._parent ("C:\\ file or folder" ) == "C:/"
@@ -576,7 +632,6 @@ def test_parent():
576
632
("local:///" , "/" ),
577
633
("/file or folder" , "/" ),
578
634
("/file or folder/" , "/" ),
579
- ("file:///" , "/" ),
580
635
("file:///path" , "/" ),
581
636
("file://c/" , "{cwd}" ),
582
637
],
@@ -764,6 +819,8 @@ def test_strip_protocol_relative_paths(uri, expected, cwd):
764
819
posixonly ("file:/foo/bar" , "/foo/bar" ),
765
820
winonly ("file:/foo/bar" , "{current_drive}/foo/bar" ),
766
821
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" ),
767
824
winonly ("file://D:\\ path\\ file" , "D:/path/file" ),
768
825
],
769
826
)
@@ -800,7 +857,9 @@ def test_strip_protocol_no_authority(uri, expected, cwd, current_drive):
800
857
pytest .param (
801
858
"file://localhost/c:/path" ,
802
859
"c:/path" ,
803
- marks = pytest .mark .xfail (reason = "not supported" ),
860
+ marks = pytest .mark .xfail (
861
+ reason = "rfc8089 section3 'localhost uri' not supported"
862
+ ),
804
863
),
805
864
],
806
865
)
@@ -820,7 +879,7 @@ def test_strip_protocol_absolute_paths(uri, expected, current_drive, cwd):
820
879
],
821
880
)
822
881
@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" )
824
883
def test_strip_protocol_legacy_dos_uris (uri , expected ):
825
884
stripped = LocalFileSystem ._strip_protocol (uri )
826
885
assert expected == stripped
0 commit comments