mirror of
https://github.com/rbreu/beeref.git
synced 2026-03-11 08:54:28 +00:00
Fix unit tests
This commit is contained in:
parent
3f50c56c18
commit
e5b96589d2
2 changed files with 4 additions and 2 deletions
|
|
@ -553,10 +553,10 @@ class BeeTextItem(BeeItemMixin, QtWidgets.QGraphicsTextItem):
|
|||
# reset selection:
|
||||
self.setTextCursor(QtGui.QTextCursor(self.document()))
|
||||
self.setTextInteractionFlags(Qt.TextInteractionFlag.NoTextInteraction)
|
||||
self.scene().edit_item = None
|
||||
if commit:
|
||||
self.scene().undo_stack.push(
|
||||
commands.ChangeText(self, self.toPlainText(), self.old_text))
|
||||
self.scene().edit_item = None
|
||||
if not self.toPlainText().strip():
|
||||
logger.debug('Removing empty text item')
|
||||
self.scene().undo_stack.push(
|
||||
|
|
|
|||
|
|
@ -244,6 +244,8 @@ def test_exit_edit_mode_when_text_empty(view):
|
|||
assert view.scene.edit_item is None
|
||||
|
||||
|
||||
@patch('PyQt6.QtGui.QTextCursor')
|
||||
@patch('beeref.items.BeeTextItem.setTextCursor')
|
||||
def test_exit_edit_mode_when_commit_false(setcursor_mock, cursor_mock, view):
|
||||
item = BeeTextItem('foo bar')
|
||||
item.edit_mode = True
|
||||
|
|
@ -258,7 +260,7 @@ def test_exit_edit_mode_when_commit_false(setcursor_mock, cursor_mock, view):
|
|||
cursor_mock.assert_called_once_with(item.document())
|
||||
setcursor_mock.assert_called_once_with(cursor_mock.return_value)
|
||||
assert view.scene.edit_item is None
|
||||
assert item.toPlaintText() == 'old'
|
||||
assert item.toPlainText() == 'old'
|
||||
|
||||
|
||||
@patch('PyQt6.QtWidgets.QGraphicsTextItem.keyPressEvent')
|
||||
|
|
|
|||
Loading…
Reference in a new issue