Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TST: Barn-door testing of SaveButtons clicks #1436

Merged
merged 1 commit into from
Mar 19, 2015
Merged

TST: Barn-door testing of SaveButtons clicks #1436

merged 1 commit into from
Mar 19, 2015

Conversation

ericdill
Copy link
Contributor

Opening up canny_simple.py and clicking the file button produces the following stacktrace that this PR fixes.

(nikea2)edill@edill-810g:~/dev/python/scikit-image/viewer_examples/plugins (master $ u=)$ git describe --long --tags
v0.11.0-29-g6051ff2
(nikea2)edill@edill-810g:~/dev/python/scikit-image/viewer_examples/plugins (master $ u=)$ python canny_simple.py
Traceback (most recent call last):
  File "/home/edill/dev/python/scikit-image/skimage/viewer/widgets/history.py", line 91, in save_to_file
    io.imsave(filename, image)
  File "/home/edill/dev/python/scikit-image/skimage/io/_io.py", line 160, in imsave
    return call_plugin('imsave', fname, arr, plugin=plugin, **plugin_args)
  File "/home/edill/dev/python/scikit-image/skimage/io/manage_plugins.py", line 207, in call_plugin
    return func(*args, **kwargs)
  File "/home/edill/dev/python/scikit-image/skimage/io/_plugins/pil_plugin.py", line 265, in imsave
    img.save(fname, format=format_str)
  File "/home/edill/anaconda/envs/nikea2/lib/python2.7/site-packages/PIL/Image.py", line 1439, in save
    save_handler(self, fp, filename)
  File "/home/edill/anaconda/envs/nikea2/lib/python2.7/site-packages/PIL/PngImagePlugin.py", line 514, in _save
    fp.write(_MAGIC)
AttributeError: 'bool' object has no attribute 'write'

The canny_simple.py demo in viewer_examples/plugins has a save that raises an AttributeError in PIL because the button is passing 'False' to the SaveButtons.save_to_file function which expects a filename or None. The False comes from the clicked signal on the Qt PushButton object which is emitting a boolean value in its signal to state if the button is checked. This boolean value is being passed to the filename input parameter to SaveButtons.save_file() which is causing havoc in pil.

@@ -80,7 +80,7 @@ def save_to_stack(self):
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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be changed as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@coveralls
Copy link

Coverage Status

Coverage increased (+0.01%) to 92.71% when pulling 847b876 on ericdill:save-buttons-fix into 6051ff2 on scikit-image:master.

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.
@coveralls
Copy link

Coverage Status

Coverage increased (+0.01%) to 92.71% when pulling 8af4373 on ericdill:save-buttons-fix into 6051ff2 on scikit-image:master.

@blink1073
Copy link
Member

Great, thanks @ericdill!

blink1073 added a commit that referenced this pull request Mar 19, 2015
TST: Barn-door testing of SaveButtons clicks
@blink1073 blink1073 merged commit e91dcba into scikit-image:master Mar 19, 2015
@stefanv
Copy link
Member

stefanv commented Mar 19, 2015

Nice one!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants