@@ -121,6 +121,32 @@ def test_mixed_cmp(self):
121121 self ._assert_cmp (a , 'a' , 1 )
122122 self ._assert_cmp (a , 'ac' , - 1 )
123123
124+ @support .subTests ('str_class' , (UserString , UserStringSubclass ))
125+ def test_startswith_userstring (self , str_class ):
126+ s = UserString ('hello world' )
127+ self .assertTrue (s .startswith (str_class ('hello' )))
128+ self .assertFalse (s .startswith (str_class ('world' )))
129+ self .assertTrue (s .startswith (str_class ('' )))
130+ self .assertFalse (s .startswith (str_class ('hello world!' )))
131+ self .assertTrue (s .startswith (str_class ('world' ), 6 ))
132+ self .assertTrue (s .startswith (str_class ('world' ), 6 , 11 ))
133+ self .assertFalse (s .startswith (str_class ('world' ), 6 , 10 ))
134+ self .assertTrue (s .startswith (str_class ('world' ), - 5 ))
135+ self .assertTrue (s .startswith (str_class ('world' ), start = 6 , end = 11 ))
136+
137+ @support .subTests ('str_class' , (UserString , UserStringSubclass ))
138+ def test_endswith_userstring (self , str_class ):
139+ s = UserString ('hello world' )
140+ self .assertTrue (s .endswith (str_class ('world' )))
141+ self .assertFalse (s .endswith (str_class ('hello' )))
142+ self .assertTrue (s .endswith (str_class ('' )))
143+ self .assertFalse (s .endswith (str_class ('hello world!' )))
144+ self .assertTrue (s .endswith (str_class ('world' ), 6 ))
145+ self .assertTrue (s .endswith (str_class ('hello' ), 0 , 5 ))
146+ self .assertFalse (s .endswith (str_class ('hello' ), 1 , 5 ))
147+ self .assertTrue (s .endswith (str_class ('hello' ), - 11 , - 6 ))
148+ self .assertTrue (s .endswith (str_class ('hello' ), start = 0 , end = 5 ))
149+
124150 def test_rmod (self ):
125151 class ustr2 (UserString ):
126152 pass
0 commit comments