@@ -2114,29 +2114,25 @@ def test_center_ljust_rjust_fillchar(self):
2114
2114
# If fillchar is not a charatter, normal str raises TypeError
2115
2115
# 'aaa'.ljust(5, 'XY')
2116
2116
# 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}"
2120
2118
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' )
2124
2121
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' )
2128
2124
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' )
2132
2127
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 )
2136
2130
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 )
2140
2136
2141
2137
def test_zfill (self ):
2142
2138
values = Series (['1' , '22' , 'aaa' , '333' , '45678' ])
0 commit comments