Skip to content

Commit

Permalink
tests: Fix 'called_once_with' used instead of 'assert_called_once_with'.
Browse files Browse the repository at this point in the history
A MagicMock object was being asserted with 'called_once_with()'
instead of 'assert_called_once_with()', likely an accidental
mistake.

As a MagicMock always returns another instance of MagicMock on
anything not previoysly set up, the `assert` was always passing,
even though we updated the Window.connect_zoom() implementation
and that should have failed.

In Python 3.12 this type of typo is caught and throws an exception.
  • Loading branch information
carlosperate committed Dec 27, 2023
1 parent c38a539 commit dc3041d
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions tests/interface/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,11 +483,10 @@ def test_Window_connect_zoom():
w._zoom_out = mock.MagicMock()
w._zoom_out.connect = mock.MagicMock()
widget = mock.MagicMock()
widget.zoomIn = mock.MagicMock()
widget.zoomOut = mock.MagicMock()
widget.set_zoom = mock.MagicMock()
w.connect_zoom(widget)
assert w._zoom_in.connect.called_once_with(widget.zoomIn)
assert w._zoom_out.connect.called_once_with(widget.zoomOut)
w._zoom_in.connect.assert_called_once_with(widget.set_zoom)
w._zoom_out.connect.assert_called_once_with(widget.set_zoom)


def test_Window_current_tab():
Expand Down

0 comments on commit dc3041d

Please sign in to comment.