-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OWLoadClassifier: Show message about unpickling error
- Loading branch information
Showing
2 changed files
with
39 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Test methods with long descriptive names can omit docstrings | ||
# pylint: disable=missing-docstring | ||
import os | ||
import pickle | ||
from tempfile import mkstemp | ||
|
||
from Orange.classification.majority import ConstantModel | ||
from Orange.widgets.classify.owloadclassifier import OWLoadClassifier | ||
from Orange.widgets.tests.base import WidgetTest | ||
|
||
|
||
class TestOWMajority(WidgetTest): | ||
def setUp(self): | ||
self.widget = self.create_widget(OWLoadClassifier) | ||
|
||
def test_show_error(self): | ||
self.widget.load("no-such-file.pckls") | ||
self.assertTrue(self.widget.Error.load_error.is_shown()) | ||
|
||
clsf = ConstantModel([1, 1, 1]) | ||
fd, fname = mkstemp(suffix='.pkcls') | ||
try: | ||
pickle.dump(clsf, open(fname, "wb")) | ||
self.widget.load(fname) | ||
self.assertFalse(self.widget.Error.load_error.is_shown()) | ||
|
||
open(fname, "w").write("X") | ||
self.widget.load(fname) | ||
self.assertTrue(self.widget.Error.load_error.is_shown()) | ||
finally: | ||
os.remove(fname) | ||
|