Skip to content

Commit

Permalink
Merge pull request biolab#1840 from janezd/scatter-no-report-empty
Browse files Browse the repository at this point in the history
[FIX] Scatter plot: don't crash on report without data
(cherry picked from commit d098ccb)
  • Loading branch information
ajdapretnar authored and astaric committed Jan 10, 2017
1 parent 45b2451 commit 70f4fbf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Orange/widgets/visualize/owscatterplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,8 @@ def get_widget_name_extension(self):
return "{} vs {}".format(self.attr_x.name, self.attr_y.name)

def send_report(self):
if self.data is None:
return
def name(var):
return var and var.name
caption = report.render_items_vert((
Expand Down
11 changes: 11 additions & 0 deletions Orange/widgets/visualize/tests/test_owscatterplot.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Test methods with long descriptive names can omit docstrings
# pylint: disable=missing-docstring
from unittest.mock import MagicMock

import numpy as np

from AnyQt.QtCore import QRectF
Expand Down Expand Up @@ -91,3 +93,12 @@ def test_error_message(self):
self.assertTrue(self.widget.Warning.missing_coords.is_shown())
self.send_signal("Data", None)
self.assertFalse(self.widget.Warning.missing_coords.is_shown())

def test_report_on_empty(self):
self.widget.report_plot = MagicMock()
self.widget.report_caption = MagicMock()
self.widget.report_items = MagicMock()
self.widget.send_report() # Essentially, don't crash
self.widget.report_plot.assert_not_called()
self.widget.report_caption.assert_not_called()
self.widget.report_items.assert_not_called()

0 comments on commit 70f4fbf

Please sign in to comment.