11"""Tests for OWPredictions"""
22import io
3+ from unittest .mock import Mock
4+
35import numpy as np
6+ from Orange .base import Model
47
58from Orange .data .io import TabReader
69from Orange .widgets .tests .base import WidgetTest
@@ -27,7 +30,6 @@ def test_nan_target_input(self):
2730 data = self .iris [::10 ].copy ()
2831 data .Y [1 ] = np .nan
2932 yvec , _ = data .get_column_view (data .domain .class_var )
30- nanmask = np .isnan (yvec )
3133 self .send_signal (self .widget .Inputs .data , data )
3234 self .send_signal (self .widget .Inputs .predictors , ConstantLearner ()(data ), 1 )
3335 pred = self .get_output (self .widget .Outputs .predictions )
@@ -170,3 +172,13 @@ def test_continuous_class(self):
170172 cl_data = ConstantLearner ()(data )
171173 self .send_signal (self .widget .Inputs .predictors , cl_data , 1 )
172174 self .send_signal (self .widget .Inputs .data , data )
175+
176+ def test_predictor_fails (self ):
177+ titanic = Table ("titanic" )
178+ failing_model = ConstantLearner ()(titanic )
179+ failing_model .predict = Mock (side_effect = ValueError ("foo" ))
180+ self .send_signal (self .widget .Inputs .predictors , failing_model , 1 )
181+ self .send_signal (self .widget .Inputs .data , titanic )
182+
183+ model2 = ConstantLearner ()(titanic )
184+ self .send_signal (self .widget .Inputs .predictors , model2 , 2 )
0 commit comments