@@ -2589,11 +2589,6 @@ def df_main_dtypes():
25892589
25902590class TestNLargestNSmallest :
25912591
2592- dtype_error_msg_template = (
2593- "Column {column!r} has dtype {dtype}, cannot "
2594- "use method {method!r} with this dtype"
2595- )
2596-
25972592 # ----------------------------------------------------------------------
25982593 # Top / bottom
25992594 @pytest .mark .parametrize (
@@ -2620,8 +2615,9 @@ def test_n(self, df_strings, nselect_method, n, order):
26202615 df = df_strings
26212616 if "b" in order :
26222617
2623- error_msg = self .dtype_error_msg_template .format (
2624- column = "b" , method = nselect_method , dtype = "object"
2618+ error_msg = (
2619+ f"Column 'b' has dtype object, "
2620+ f"cannot use method '{ nselect_method } ' with this dtype"
26252621 )
26262622 with pytest .raises (TypeError , match = error_msg ):
26272623 getattr (df , nselect_method )(n , order )
@@ -2637,8 +2633,9 @@ def test_n(self, df_strings, nselect_method, n, order):
26372633 def test_n_error (self , df_main_dtypes , nselect_method , columns ):
26382634 df = df_main_dtypes
26392635 col = columns [1 ]
2640- error_msg = self .dtype_error_msg_template .format (
2641- column = col , method = nselect_method , dtype = df [col ].dtype
2636+ error_msg = (
2637+ f"Column '{ col } ' has dtype { df [col ].dtype } , "
2638+ f"cannot use method '{ nselect_method } ' with this dtype"
26422639 )
26432640 # escape some characters that may be in the repr
26442641 error_msg = (
0 commit comments