Skip to content

Commit

Permalink
Merge pull request #5476 from csabella/issue5475
Browse files Browse the repository at this point in the history
PR: Fix EditorSplitter menu_actions and add test.
  • Loading branch information
ccordoba12 authored Oct 19, 2017
2 parents 22748ff + 10efaab commit 05d12d4
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
7 changes: 3 additions & 4 deletions spyder/widgets/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,10 +516,9 @@ def __init__(self, parent, actions):
text= _("Show in external file explorer")
external_fileexp_action = create_action(self, text,
triggered=self.show_in_external_file_explorer)

actions.append(external_fileexp_action)

self.menu_actions = actions + [None, fileswitcher_action,

self.menu_actions = actions + [external_fileexp_action,
None, fileswitcher_action,
symbolfinder_action,
copy_to_cb_action, None, close_right,
close_all_but_this]
Expand Down
37 changes: 36 additions & 1 deletion spyder/widgets/tests/test_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

# Local imports
from spyder.utils.fixtures import setup_editor
from spyder.widgets.editor import EditorStack
from spyder.widgets.editor import EditorStack, EditorSplitter
from spyder.widgets.findreplace import FindReplace
from spyder.py3compat import PY2

Expand Down Expand Up @@ -82,6 +82,16 @@ def editor_cells_bot(base_editor_bot):
return editor_stack, finfo.editor, qtbot


@pytest.fixture
def editor_splitter_bot(qtbot):
"""Create editor splitter."""
editor_splitter = EditorSplitter(None, Mock(), [], first=True)
qtbot.addWidget(editor_splitter)
editor_splitter.show()
yield editor_splitter
editor_splitter.destroy()


# Tests
#-------------------------------
def test_find_number_matches(qtbot):
Expand Down Expand Up @@ -395,5 +405,30 @@ def test_get_current_word(base_editor_bot):
assert editor.get_current_word() == 'valid_python_word'


def test_editor_splitter_init(editor_splitter_bot):
""""Test EditorSplitter.__init__."""
es = editor_splitter_bot
assert es.orientation() == Qt.Horizontal
assert es.testAttribute(Qt.WA_DeleteOnClose)
assert not es.childrenCollapsible()
assert not es.toolbar_list
assert not es.menu_list
assert es.register_editorstack_cb == es.plugin.register_editorstack
assert es.unregister_editorstack_cb == es.plugin.unregister_editorstack

# No menu actions in parameter call.
assert not es.menu_actions
# EditorStack adds its own menu actions to the existing actions.
assert es.editorstack.menu_actions

assert isinstance(es.editorstack, EditorStack)
es.plugin.register_editorstack.assert_called_with(es.editorstack)
es.plugin.unregister_editorstack.assert_not_called()
es.plugin.clone_editorstack.assert_not_called()

assert es.count() == 1
assert es.widget(0) == es.editorstack


if __name__ == "__main__":
pytest.main()

0 comments on commit 05d12d4

Please sign in to comment.