def setup_editor(qtbot, monkeypatch): """Set up the Editor plugin.""" app = qapplication() os.environ['SPY_TEST_USE_INTROSPECTION'] = 'True' monkeypatch.setattr('spyder.dependencies', Mock()) from spyder.plugins.editor import Editor monkeypatch.setattr('spyder.plugins.editor.add_actions', Mock()) class MainMock(QWidget): def __getattr__(self, attr): if attr.endswith('actions'): return [] else: return Mock() def get_spyder_pythonpath(*args): return [] editor = Editor(MainMock()) qtbot.addWidget(editor) editor.show() editor.new(fname="test.py", text="") editor.introspector.set_editor_widget(editor.editorstacks[0]) yield editor, qtbot # teardown os.environ['SPY_TEST_USE_INTROSPECTION'] = 'False' editor.introspector.plugin_manager.close()
def setup_editor(qtbot, monkeypatch): """Set up the Editor plugin.""" qapplication() monkeypatch.setattr('spyder.dependencies', Mock()) from spyder.plugins.editor import Editor monkeypatch.setattr('spyder.plugins.editor.IntrospectionManager', Mock()) monkeypatch.setattr('spyder.plugins.editor.add_actions', Mock()) class MainMock(QWidget): def __getattr__(self, attr): if attr.endswith('actions'): return [] elif attr == 'projects': projects = Mock() projects.get_active_project.return_value = None return projects else: return Mock() def get_spyder_pythonpath(*args): return [] editor = Editor(MainMock()) qtbot.addWidget(editor) editor.show() yield editor, qtbot
def setup_editor(qtbot, monkeypatch): """Set up the Editor plugin.""" monkeypatch.setattr('spyder.dependencies', Mock()) from spyder.plugins.editor import Editor monkeypatch.setattr('spyder.plugins.editor.IntrospectionManager', Mock()) monkeypatch.setattr('spyder.plugins.editor.add_actions', Mock()) class MainMock(QWidget): def __getattr__(self, attr): if attr.endswith('actions'): return [] else: return Mock() editor = Editor(MainMock()) qtbot.addWidget(editor) editor.show() return editor, qtbot
def setup_editor(qtbot, monkeypatch): """Set up the Editor plugin.""" app = qapplication() os.environ['SPY_TEST_USE_INTROSPECTION'] = 'True' monkeypatch.setattr('spyder.dependencies', Mock()) from spyder.plugins.editor import Editor monkeypatch.setattr('spyder.plugins.editor.add_actions', Mock()) class MainMock(QWidget): def __init__(self, parent): QWidget.__init__(self, parent) self.lspmanager = LSPManager(parent=self) def __getattr__(self, attr): if attr.endswith('actions'): return [] if attr == 'lspmanager': return self.lspmanager else: return Mock() def get_spyder_pythonpath(*args): return [] editor = Editor(MainMock(None)) editor.register_plugin() qtbot.addWidget(editor) editor.show() with qtbot.waitSignal(editor.sig_lsp_notification, timeout=30000): editor.new(fname="test.py", text="") # editor.introspector.set_editor_widget(editor.editorstacks[0]) code_editor = editor.get_focus_widget() with qtbot.waitSignal(code_editor.lsp_response_signal, timeout=30000): code_editor.document_did_open() yield editor, qtbot # teardown os.environ['SPY_TEST_USE_INTROSPECTION'] = 'False' editor.main.lspmanager.closing_plugin()