@@ -1524,7 +1524,8 @@ def test_check_is_fitted():
1524
1524
rnk = lgb .LGBMRanker (n_estimators = 5 )
1525
1525
models = (est , clf , reg , rnk )
1526
1526
for model in models :
1527
- with pytest .raises (lgb .compat .LGBMNotFittedError ):
1527
+ err_msg = f"This { type (model ).__name__ } instance is not fitted yet. Call 'fit' with appropriate arguments before using this estimator."
1528
+ with pytest .raises (lgb .compat .LGBMNotFittedError , match = err_msg ):
1528
1529
check_is_fitted (model )
1529
1530
est .fit (X , y )
1530
1531
clf .fit (X , y )
@@ -1623,7 +1624,8 @@ def test_getting_feature_names_in_np_input(estimator_class):
1623
1624
model = estimator_class (** {** params , "objective" : "binary" })
1624
1625
else :
1625
1626
model = estimator_class (** params )
1626
- with pytest .raises (lgb .compat .LGBMNotFittedError ):
1627
+ err_msg = f"This { estimator_class .__name__ } instance is not fitted yet. Call 'fit' with appropriate arguments before using this estimator."
1628
+ with pytest .raises (lgb .compat .LGBMNotFittedError , match = err_msg ):
1627
1629
check_is_fitted (model )
1628
1630
if isinstance (model , lgb .LGBMRanker ):
1629
1631
model .fit (X , y , group = [X .shape [0 ]])
@@ -1644,7 +1646,8 @@ def test_getting_feature_names_in_pd_input(estimator_class):
1644
1646
model = estimator_class (** {** params , "objective" : "binary" })
1645
1647
else :
1646
1648
model = estimator_class (** params )
1647
- with pytest .raises (lgb .compat .LGBMNotFittedError ):
1649
+ err_msg = f"This { estimator_class .__name__ } instance is not fitted yet. Call 'fit' with appropriate arguments before using this estimator."
1650
+ with pytest .raises (lgb .compat .LGBMNotFittedError , match = err_msg ):
1648
1651
check_is_fitted (model )
1649
1652
if isinstance (model , lgb .LGBMRanker ):
1650
1653
model .fit (X , y , group = [X .shape [0 ]])
0 commit comments