Skip to content

Commit

Permalink
Fix mock asserts
Browse files Browse the repository at this point in the history
  • Loading branch information
astrofrog committed Jul 12, 2024
1 parent 8fa75cd commit fc97440
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions glue_qt/app/tests/test_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,12 @@ def test_new_data_defaults(self):
d1 = Data(x=np.array([1, 2, 3]))

self.app.choose_new_data_viewer(data=d1)
assert pc.call_count == 1
args, kwargs = pc.call_args
assert kwargs['default'] is ScatterViewer

self.app.choose_new_data_viewer(data=d2)
assert pc.call_count == 2
args, kwargs = pc.call_args
assert kwargs['default'] is ImageViewer

Expand All @@ -195,7 +197,7 @@ def test_drop_load_data(self):
e.mimeData.return_value = m

self.app.dropEvent(e)
assert load_data.called_once_with('test.fits')
load_data.assert_called_once_with(['test.fits'])
assert load_session.call_count == 0

load_data.reset_mock()
Expand All @@ -204,7 +206,7 @@ def test_drop_load_data(self):
m.setUrls([QtCore.QUrl('test1.fits'), QtCore.QUrl('test2.fits')])
e.mimeData.return_value = m
self.app.dropEvent(e)
assert load_data.called_once_with(['test1.fits', 'test2.fits'])
load_data.assert_called_once_with(['test1.fits', 'test2.fits'])
assert load_session.call_count == 0

load_data.reset_mock()
Expand All @@ -214,7 +216,7 @@ def test_drop_load_data(self):
e.mimeData.return_value = m
self.app.dropEvent(e)
assert load_data.call_count == 0
assert load_session.called_once_with(['test.glu'])
load_session.assert_called_once_with('test.glu')

load_data.reset_mock()

Expand Down
4 changes: 2 additions & 2 deletions glue_qt/utils/tests/test_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def decorated_working_function():
with patch('qtpy.QtWidgets.QMessageBox') as mb:
decorated_failing_function()
assert mb.call_args[0][2] == 'An error occurred\nDialog failure'
assert exit.called_once_with(1)
exit.assert_called_once_with(1)

with patch('sys.exit') as exit:
with patch('qtpy.QtWidgets.QMessageBox') as mb:
Expand All @@ -86,7 +86,7 @@ def decorated_working_function():
with die_on_error('An error occurred'):
failing_function()
assert mb.call_args[0][2] == 'An error occurred\nDialog failure'
assert exit.called_once_with(1)
exit.assert_called_once_with(1)

with patch('sys.exit') as exit:
with patch('qtpy.QtWidgets.QMessageBox') as mb:
Expand Down

0 comments on commit fc97440

Please sign in to comment.