@@ -2589,11 +2589,6 @@ def df_main_dtypes():
2589
2589
2590
2590
class TestNLargestNSmallest :
2591
2591
2592
- dtype_error_msg_template = (
2593
- "Column {column!r} has dtype {dtype}, cannot "
2594
- "use method {method!r} with this dtype"
2595
- )
2596
-
2597
2592
# ----------------------------------------------------------------------
2598
2593
# Top / bottom
2599
2594
@pytest .mark .parametrize (
@@ -2620,8 +2615,9 @@ def test_n(self, df_strings, nselect_method, n, order):
2620
2615
df = df_strings
2621
2616
if "b" in order :
2622
2617
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"
2625
2621
)
2626
2622
with pytest .raises (TypeError , match = error_msg ):
2627
2623
getattr (df , nselect_method )(n , order )
@@ -2637,8 +2633,9 @@ def test_n(self, df_strings, nselect_method, n, order):
2637
2633
def test_n_error (self , df_main_dtypes , nselect_method , columns ):
2638
2634
df = df_main_dtypes
2639
2635
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"
2642
2639
)
2643
2640
# escape some characters that may be in the repr
2644
2641
error_msg = (
0 commit comments