@@ -50,6 +50,7 @@ def test_unsupported_operation(self):
5050 self .assertRaises (e , m .join , 'foo' )
5151 self .assertRaises (e , m .split , 'foo' )
5252 self .assertRaises (e , m .splitdrive , 'foo' )
53+ self .assertRaises (e , m .splitext , 'foo' )
5354 self .assertRaises (e , m .normcase , 'foo' )
5455 self .assertRaises (e , m .isabs , 'foo' )
5556
@@ -789,8 +790,12 @@ def test_suffix_common(self):
789790 self .assertEqual (P ('/a/.hg.rc' ).suffix , '.rc' )
790791 self .assertEqual (P ('a/b.tar.gz' ).suffix , '.gz' )
791792 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' )
794799
795800 @needs_windows
796801 def test_suffix_windows (self ):
@@ -807,8 +812,8 @@ def test_suffix_windows(self):
807812 self .assertEqual (P ('c:/a/.hg.rc' ).suffix , '.rc' )
808813 self .assertEqual (P ('c:a/b.tar.gz' ).suffix , '.gz' )
809814 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 , '. ' )
812817 self .assertEqual (P ('//My.py/Share.php' ).suffix , '' )
813818 self .assertEqual (P ('//My.py/Share.php/a/b' ).suffix , '' )
814819
@@ -828,8 +833,12 @@ def test_suffixes_common(self):
828833 self .assertEqual (P ('/a/.hg.rc' ).suffixes , ['.rc' ])
829834 self .assertEqual (P ('a/b.tar.gz' ).suffixes , ['.tar' , '.gz' ])
830835 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' ])
833842
834843 @needs_windows
835844 def test_suffixes_windows (self ):
@@ -848,8 +857,8 @@ def test_suffixes_windows(self):
848857 self .assertEqual (P ('c:/a/b.tar.gz' ).suffixes , ['.tar' , '.gz' ])
849858 self .assertEqual (P ('//My.py/Share.php' ).suffixes , [])
850859 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' , '.' ])
853862
854863 def test_stem_empty (self ):
855864 P = self .cls
@@ -865,8 +874,11 @@ def test_stem_common(self):
865874 self .assertEqual (P ('a/.hgrc' ).stem , '.hgrc' )
866875 self .assertEqual (P ('a/.hg.rc' ).stem , '.hg' )
867876 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' )
870882
871883 @needs_windows
872884 def test_stem_windows (self ):
@@ -880,8 +892,8 @@ def test_stem_windows(self):
880892 self .assertEqual (P ('c:a/.hgrc' ).stem , '.hgrc' )
881893 self .assertEqual (P ('c:a/.hg.rc' ).stem , '.hg' )
882894 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+
885897 def test_with_name_common (self ):
886898 P = self .cls
887899 self .assertEqual (P ('a/b' ).with_name ('d.xml' ), P ('a/d.xml' ))
@@ -929,16 +941,16 @@ def test_with_stem_common(self):
929941 self .assertEqual (P ('a/b.py' ).with_stem ('d' ), P ('a/d.py' ))
930942 self .assertEqual (P ('/a/b.py' ).with_stem ('d' ), P ('/a/d.py' ))
931943 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. ' ))
934946
935947 @needs_windows
936948 def test_with_stem_windows (self ):
937949 P = self .cls
938950 self .assertEqual (P ('c:a/b' ).with_stem ('d' ), P ('c:a/d' ))
939951 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. ' ))
942954 self .assertRaises (ValueError , P ('c:' ).with_stem , 'd' )
943955 self .assertRaises (ValueError , P ('c:/' ).with_stem , 'd' )
944956 self .assertRaises (ValueError , P ('//My/Share' ).with_stem , 'd' )
@@ -974,6 +986,11 @@ def test_with_suffix_common(self):
974986 # Stripping suffix.
975987 self .assertEqual (P ('a/b.py' ).with_suffix ('' ), P ('a/b' ))
976988 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.' ))
977994
978995 @needs_windows
979996 def test_with_suffix_windows (self ):
@@ -1012,7 +1029,6 @@ def test_with_suffix_invalid(self):
10121029 # Invalid suffix.
10131030 self .assertRaises (ValueError , P ('a/b' ).with_suffix , 'gz' )
10141031 self .assertRaises (ValueError , P ('a/b' ).with_suffix , '/' )
1015- self .assertRaises (ValueError , P ('a/b' ).with_suffix , '.' )
10161032 self .assertRaises (ValueError , P ('a/b' ).with_suffix , '/.gz' )
10171033 self .assertRaises (ValueError , P ('a/b' ).with_suffix , 'c/d' )
10181034 self .assertRaises (ValueError , P ('a/b' ).with_suffix , '.c/.d' )
0 commit comments