From 8af43739c42f69f9b60bdb8443ba73a42f31d1ab Mon Sep 17 00:00:00 2001 From: Eric Dill Date: Wed, 18 Mar 2015 17:30:43 -0400 Subject: [PATCH] TST: Barn-door testing of SaveButtons clicks The canny_simple.py demo in viewer_examples/plugins has a save button that raises an AttributeError in PIL because the button click is passing 'False' to the SaveButtons.save_to_file function when it expects a filename or None. --- skimage/viewer/tests/test_widgets.py | 5 +++++ skimage/viewer/widgets/history.py | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/skimage/viewer/tests/test_widgets.py b/skimage/viewer/tests/test_widgets.py index 66b86fa4..8d0e05e0 100644 --- a/skimage/viewer/tests/test_widgets.py +++ b/skimage/viewer/tests/test_widgets.py @@ -101,6 +101,11 @@ def test_save_buttons(): timer = QtCore.QTimer() timer.singleShot(100, QtGui.QApplication.quit) + # exercise the button clicks + sv.save_stack.click() + sv.save_file.click() + + # call the save functions directly sv.save_to_stack() with expected_warnings(['precision loss']): sv.save_to_file(filename) diff --git a/skimage/viewer/widgets/history.py b/skimage/viewer/widgets/history.py index 3b7f58b0..6229e525 100644 --- a/skimage/viewer/widgets/history.py +++ b/skimage/viewer/widgets/history.py @@ -80,9 +80,9 @@ class SaveButtons(BaseWidget): notify(msg) def save_to_file(self, filename=None): - if filename is None: + if not filename: filename = dialogs.save_file_dialog() - if filename is None: + if not filename: return image = self.plugin.filtered_image if image.dtype == np.bool: