44
55from  sklearn .utils .testing  import  assert_almost_equal 
66from  sklearn .utils .testing  import  assert_raises 
7- from  sklearn .utils .testing  import  assert_raise_message 
7+ from  sklearn .utils .testing  import  assert_raises_regexp 
88from  sklearn .utils .testing  import  assert_true 
99from  sklearn .utils .testing  import  ignore_warnings 
1010
@@ -58,7 +58,9 @@ def predict(self, X):
5858def  test_check_scoring ():
5959    """Test all branches of check_scoring""" 
6060    estimator  =  EstimatorWithoutFit ()
61-     assert_raise_message (TypeError , "'fit' method" , check_scoring , estimator )
61+     assert_raises_regexp (TypeError ,
62+         r"estimator should a be an estimator implementing 'fit' method, .* " 
63+         "was passed" , check_scoring , estimator )
6264
6365    estimator  =  EstimatorWithFitAndScore ()
6466    estimator .fit ([[1 ]], [1 ])
@@ -67,14 +69,17 @@ def test_check_scoring():
6769
6870    estimator  =  EstimatorWithFitAndPredict ()
6971    estimator .fit ([[1 ]], [1 ])
70-     assert_raise_message (TypeError , "no scoring" , check_scoring , estimator )
72+     assert_raises_regexp (TypeError ,
73+         r"If no scoring is specified, the estimator passed should have a " 
74+         "'score' method\. The estimator .* does not." , check_scoring , estimator )
7175
7276    scorer  =  check_scoring (estimator , "accuracy" )
7377    assert_almost_equal (scorer (estimator , [[1 ]], [1 ]), 1.0 )
7478
7579    estimator  =  EstimatorWithFit ()
76-     assert_raise_message (TypeError , "'score' or a 'predict'" , check_scoring ,
77-                          estimator , "accuracy" )
80+     assert_raises_regexp (TypeError ,
81+         r"The estimator passed should have a 'score' or a 'predict' method. " 
82+         "The estimator .* does not." , check_scoring , estimator , "accuracy" )
7883
7984    estimator  =  EstimatorWithFit ()
8085    scorer  =  check_scoring (estimator , allow_none = True )
0 commit comments