@@ -50,6 +50,7 @@ def test_unsupported_operation(self):
50
50
self .assertRaises (e , m .join , 'foo' )
51
51
self .assertRaises (e , m .split , 'foo' )
52
52
self .assertRaises (e , m .splitdrive , 'foo' )
53
+ self .assertRaises (e , m .splitext , 'foo' )
53
54
self .assertRaises (e , m .normcase , 'foo' )
54
55
self .assertRaises (e , m .isabs , 'foo' )
55
56
@@ -789,8 +790,12 @@ def test_suffix_common(self):
789
790
self .assertEqual (P ('/a/.hg.rc' ).suffix , '.rc' )
790
791
self .assertEqual (P ('a/b.tar.gz' ).suffix , '.gz' )
791
792
self .assertEqual (P ('/a/b.tar.gz' ).suffix , '.gz' )
792
- self .assertEqual (P ('a/Some name. Ending with a dot.' ).suffix , '' )
793
- self .assertEqual (P ('/a/Some name. Ending with a dot.' ).suffix , '' )
793
+ self .assertEqual (P ('a/trailing.dot.' ).suffix , '.' )
794
+ self .assertEqual (P ('/a/trailing.dot.' ).suffix , '.' )
795
+ self .assertEqual (P ('a/..d.o.t..' ).suffix , '.' )
796
+ self .assertEqual (P ('a/inn.er..dots' ).suffix , '.dots' )
797
+ self .assertEqual (P ('photo' ).suffix , '' )
798
+ self .assertEqual (P ('photo.jpg' ).suffix , '.jpg' )
794
799
795
800
@needs_windows
796
801
def test_suffix_windows (self ):
@@ -807,8 +812,8 @@ def test_suffix_windows(self):
807
812
self .assertEqual (P ('c:/a/.hg.rc' ).suffix , '.rc' )
808
813
self .assertEqual (P ('c:a/b.tar.gz' ).suffix , '.gz' )
809
814
self .assertEqual (P ('c:/a/b.tar.gz' ).suffix , '.gz' )
810
- self .assertEqual (P ('c:a/Some name. Ending with a dot.' ).suffix , '' )
811
- self .assertEqual (P ('c:/a/Some name. Ending with a dot.' ).suffix , '' )
815
+ self .assertEqual (P ('c:a/trailing. dot.' ).suffix , '. ' )
816
+ self .assertEqual (P ('c:/a/trailing. dot.' ).suffix , '. ' )
812
817
self .assertEqual (P ('//My.py/Share.php' ).suffix , '' )
813
818
self .assertEqual (P ('//My.py/Share.php/a/b' ).suffix , '' )
814
819
@@ -828,8 +833,12 @@ def test_suffixes_common(self):
828
833
self .assertEqual (P ('/a/.hg.rc' ).suffixes , ['.rc' ])
829
834
self .assertEqual (P ('a/b.tar.gz' ).suffixes , ['.tar' , '.gz' ])
830
835
self .assertEqual (P ('/a/b.tar.gz' ).suffixes , ['.tar' , '.gz' ])
831
- self .assertEqual (P ('a/Some name. Ending with a dot.' ).suffixes , [])
832
- self .assertEqual (P ('/a/Some name. Ending with a dot.' ).suffixes , [])
836
+ self .assertEqual (P ('a/trailing.dot.' ).suffixes , ['.dot' , '.' ])
837
+ self .assertEqual (P ('/a/trailing.dot.' ).suffixes , ['.dot' , '.' ])
838
+ self .assertEqual (P ('a/..d.o.t..' ).suffixes , ['.o' , '.t' , '.' , '.' ])
839
+ self .assertEqual (P ('a/inn.er..dots' ).suffixes , ['.er' , '.' , '.dots' ])
840
+ self .assertEqual (P ('photo' ).suffixes , [])
841
+ self .assertEqual (P ('photo.jpg' ).suffixes , ['.jpg' ])
833
842
834
843
@needs_windows
835
844
def test_suffixes_windows (self ):
@@ -848,8 +857,8 @@ def test_suffixes_windows(self):
848
857
self .assertEqual (P ('c:/a/b.tar.gz' ).suffixes , ['.tar' , '.gz' ])
849
858
self .assertEqual (P ('//My.py/Share.php' ).suffixes , [])
850
859
self .assertEqual (P ('//My.py/Share.php/a/b' ).suffixes , [])
851
- self .assertEqual (P ('c:a/Some name. Ending with a dot.' ).suffixes , [])
852
- self .assertEqual (P ('c:/a/Some name. Ending with a dot.' ).suffixes , [])
860
+ self .assertEqual (P ('c:a/trailing. dot.' ).suffixes , ['.dot' , '.' ])
861
+ self .assertEqual (P ('c:/a/trailing. dot.' ).suffixes , ['.dot' , '.' ])
853
862
854
863
def test_stem_empty (self ):
855
864
P = self .cls
@@ -865,8 +874,11 @@ def test_stem_common(self):
865
874
self .assertEqual (P ('a/.hgrc' ).stem , '.hgrc' )
866
875
self .assertEqual (P ('a/.hg.rc' ).stem , '.hg' )
867
876
self .assertEqual (P ('a/b.tar.gz' ).stem , 'b.tar' )
868
- self .assertEqual (P ('a/Some name. Ending with a dot.' ).stem ,
869
- 'Some name. Ending with a dot.' )
877
+ self .assertEqual (P ('a/trailing.dot.' ).stem , 'trailing.dot' )
878
+ self .assertEqual (P ('a/..d.o.t..' ).stem , '..d.o.t.' )
879
+ self .assertEqual (P ('a/inn.er..dots' ).stem , 'inn.er.' )
880
+ self .assertEqual (P ('photo' ).stem , 'photo' )
881
+ self .assertEqual (P ('photo.jpg' ).stem , 'photo' )
870
882
871
883
@needs_windows
872
884
def test_stem_windows (self ):
@@ -880,8 +892,8 @@ def test_stem_windows(self):
880
892
self .assertEqual (P ('c:a/.hgrc' ).stem , '.hgrc' )
881
893
self .assertEqual (P ('c:a/.hg.rc' ).stem , '.hg' )
882
894
self .assertEqual (P ('c:a/b.tar.gz' ).stem , 'b.tar' )
883
- self .assertEqual (P ('c:a/Some name. Ending with a dot.' ).stem ,
884
- 'Some name. Ending with a dot.' )
895
+ self .assertEqual (P ('c:a/trailing. dot.' ).stem , 'trailing.dot' )
896
+
885
897
def test_with_name_common (self ):
886
898
P = self .cls
887
899
self .assertEqual (P ('a/b' ).with_name ('d.xml' ), P ('a/d.xml' ))
@@ -929,16 +941,16 @@ def test_with_stem_common(self):
929
941
self .assertEqual (P ('a/b.py' ).with_stem ('d' ), P ('a/d.py' ))
930
942
self .assertEqual (P ('/a/b.py' ).with_stem ('d' ), P ('/a/d.py' ))
931
943
self .assertEqual (P ('/a/b.tar.gz' ).with_stem ('d' ), P ('/a/d.gz' ))
932
- self .assertEqual (P ('a/Dot ending.' ).with_stem ('d' ), P ('a/d' ))
933
- self .assertEqual (P ('/a/Dot ending.' ).with_stem ('d' ), P ('/a/d' ))
944
+ self .assertEqual (P ('a/Dot ending.' ).with_stem ('d' ), P ('a/d. ' ))
945
+ self .assertEqual (P ('/a/Dot ending.' ).with_stem ('d' ), P ('/a/d. ' ))
934
946
935
947
@needs_windows
936
948
def test_with_stem_windows (self ):
937
949
P = self .cls
938
950
self .assertEqual (P ('c:a/b' ).with_stem ('d' ), P ('c:a/d' ))
939
951
self .assertEqual (P ('c:/a/b' ).with_stem ('d' ), P ('c:/a/d' ))
940
- self .assertEqual (P ('c:a/Dot ending.' ).with_stem ('d' ), P ('c:a/d' ))
941
- self .assertEqual (P ('c:/a/Dot ending.' ).with_stem ('d' ), P ('c:/a/d' ))
952
+ self .assertEqual (P ('c:a/Dot ending.' ).with_stem ('d' ), P ('c:a/d. ' ))
953
+ self .assertEqual (P ('c:/a/Dot ending.' ).with_stem ('d' ), P ('c:/a/d. ' ))
942
954
self .assertRaises (ValueError , P ('c:' ).with_stem , 'd' )
943
955
self .assertRaises (ValueError , P ('c:/' ).with_stem , 'd' )
944
956
self .assertRaises (ValueError , P ('//My/Share' ).with_stem , 'd' )
@@ -974,6 +986,11 @@ def test_with_suffix_common(self):
974
986
# Stripping suffix.
975
987
self .assertEqual (P ('a/b.py' ).with_suffix ('' ), P ('a/b' ))
976
988
self .assertEqual (P ('/a/b' ).with_suffix ('' ), P ('/a/b' ))
989
+ # Single dot
990
+ self .assertEqual (P ('a/b' ).with_suffix ('.' ), P ('a/b.' ))
991
+ self .assertEqual (P ('/a/b' ).with_suffix ('.' ), P ('/a/b.' ))
992
+ self .assertEqual (P ('a/b.py' ).with_suffix ('.' ), P ('a/b.' ))
993
+ self .assertEqual (P ('/a/b.py' ).with_suffix ('.' ), P ('/a/b.' ))
977
994
978
995
@needs_windows
979
996
def test_with_suffix_windows (self ):
@@ -1012,7 +1029,6 @@ def test_with_suffix_invalid(self):
1012
1029
# Invalid suffix.
1013
1030
self .assertRaises (ValueError , P ('a/b' ).with_suffix , 'gz' )
1014
1031
self .assertRaises (ValueError , P ('a/b' ).with_suffix , '/' )
1015
- self .assertRaises (ValueError , P ('a/b' ).with_suffix , '.' )
1016
1032
self .assertRaises (ValueError , P ('a/b' ).with_suffix , '/.gz' )
1017
1033
self .assertRaises (ValueError , P ('a/b' ).with_suffix , 'c/d' )
1018
1034
self .assertRaises (ValueError , P ('a/b' ).with_suffix , '.c/.d' )
0 commit comments