@@ -2114,29 +2114,25 @@ def test_center_ljust_rjust_fillchar(self):
21142114 # If fillchar is not a charatter, normal str raises TypeError
21152115 # 'aaa'.ljust(5, 'XY')
21162116 # TypeError: must be char, not str
2117- msg = "fillchar must be a character, not str"
2118- with pytest .raises (TypeError , match = msg ):
2119- result = values .str .center (5 , fillchar = 'XY' )
2117+ template = "fillchar must be a character, not {dtype}"
21202118
2121- msg = "fillchar must be a character, not str"
2122- with pytest .raises (TypeError , match = msg ):
2123- result = values .str .ljust (5 , fillchar = 'XY' )
2119+ with pytest .raises (TypeError , match = template .format (dtype = "str" )):
2120+ values .str .center (5 , fillchar = 'XY' )
21242121
2125- msg = "fillchar must be a character, not str"
2126- with pytest .raises (TypeError , match = msg ):
2127- result = values .str .rjust (5 , fillchar = 'XY' )
2122+ with pytest .raises (TypeError , match = template .format (dtype = "str" )):
2123+ values .str .ljust (5 , fillchar = 'XY' )
21282124
2129- msg = "fillchar must be a character, not int"
2130- with pytest .raises (TypeError , match = msg ):
2131- result = values .str .center (5 , fillchar = 1 )
2125+ with pytest .raises (TypeError , match = template .format (dtype = "str" )):
2126+ values .str .rjust (5 , fillchar = 'XY' )
21322127
2133- msg = "fillchar must be a character, not int"
2134- with pytest .raises (TypeError , match = msg ):
2135- result = values .str .ljust (5 , fillchar = 1 )
2128+ with pytest .raises (TypeError , match = template .format (dtype = "int" )):
2129+ values .str .center (5 , fillchar = 1 )
21362130
2137- msg = "fillchar must be a character, not int"
2138- with pytest .raises (TypeError , match = msg ):
2139- result = values .str .rjust (5 , fillchar = 1 )
2131+ with pytest .raises (TypeError , match = template .format (dtype = "int" )):
2132+ values .str .ljust (5 , fillchar = 1 )
2133+
2134+ with pytest .raises (TypeError , match = template .format (dtype = "int" )):
2135+ values .str .rjust (5 , fillchar = 1 )
21402136
21412137 def test_zfill (self ):
21422138 values = Series (['1' , '22' , 'aaa' , '333' , '45678' ])
0 commit comments