Пример #1
0
def lsp_codeeditor(lsp_plugin, qtbot_module, request):
    """CodeEditor instance with LSP services activated."""
    # Create a CodeEditor instance
    editor = codeeditor_factory()
    qtbot_module.addWidget(editor)
    editor.show()

    # Redirect editor LSP requests to lsp_manager
    editor.sig_perform_completion_request.connect(lsp_plugin.send_request)

    editor.filename = 'test.py'
    editor.language = 'Python'
    lsp_plugin.register_file('python', 'test.py', editor)
    server_settings = lsp_plugin.main.editor.lsp_editor_settings['python']
    editor.start_completion_services()
    editor.update_completion_configuration(server_settings)

    with qtbot_module.waitSignal(editor.lsp_response_signal, timeout=30000):
        editor.document_did_open()

    def teardown():
        editor.hide()
        editor.completion_widget.hide()

    request.addfinalizer(teardown)
    lsp_plugin = lsp_plugin.get_client('lsp')
    return editor, lsp_plugin
Пример #2
0
def lsp_plugin(qtbot_module, request):
    # Activate pycodestyle and pydocstyle
    CONF.set('lsp-server', 'pycodestyle', True)
    CONF.set('lsp-server', 'pydocstyle', True)
    CONF.set('lsp-server', 'stdio', False)
    CONF.set('lsp-server', 'code_snippets', False)

    # Create the manager
    os.environ['SPY_TEST_USE_INTROSPECTION'] = 'True'

    main = MainWindowMock()
    completions = CompletionManager(main, ['lsp'])
    completions.start()
    with qtbot_module.waitSignal(
            main.editor.sig_lsp_initialized, timeout=30000):
        completions.start_client('python')

    def teardown():
        completions.shutdown()
        os.environ['SPY_TEST_USE_INTROSPECTION'] = 'False'
        CONF.set('lsp-server', 'pycodestyle', False)
        CONF.set('lsp-server', 'pydocstyle', False)

    request.addfinalizer(teardown)
    return completions
Пример #3
0
def fallback_completions(qtbot_module, request):
    fallback = FallbackPlugin(None)
    completions = CompletionManagerMock(None)
    qtbot_module.addWidget(fallback)
    qtbot_module.addWidget(completions)

    with qtbot_module.waitSignal(fallback.sig_plugin_ready, timeout=30000):
        fallback.start()

    def teardown():
        fallback.shutdown()

    request.addfinalizer(teardown)

    fallback.sig_response_ready.connect(completions.handle_response)
    return fallback, completions
Пример #4
0
def snippets_completions(qtbot_module, request):
    snippets = SnippetsPlugin(None)
    completions = CompletionManagerMock(None)
    qtbot_module.addWidget(snippets)
    qtbot_module.addWidget(completions)

    with qtbot_module.waitSignal(snippets.sig_plugin_ready, timeout=30000):
        snippets.start()

    def teardown():
        snippets.shutdown()

    request.addfinalizer(teardown)

    snippets.sig_response_ready.connect(completions.handle_response)
    return snippets, completions
Пример #5
0
def lsp_codeeditor(lsp_plugin, qtbot_module, request, capsys):
    """CodeEditor instance with LSP services activated."""
    # Create a CodeEditor instance
    editor = codeeditor_factory()
    qtbot_module.addWidget(editor)

    # Redirect editor LSP requests to lsp_manager
    editor.sig_perform_completion_request.connect(lsp_plugin.send_request)

    editor.filename = 'test.py'
    editor.language = 'Python'
    lsp_plugin.register_file('python', 'test.py', editor)
    capabilities = lsp_plugin.main.editor.completion_capabilities['python']
    editor.start_completion_services()
    editor.register_completion_capabilities(capabilities)

    with qtbot_module.waitSignal(editor.lsp_response_signal, timeout=30000):
        editor.document_did_open()

    def teardown():
        editor.completion_widget.hide()
        editor.tooltip_widget.hide()
        editor.hide()

        # Capture stderr and assert there are no errors
        sys_stream = capsys.readouterr()
        sys_err = sys_stream.err

        if PY2:
            sys_err = to_text_string(sys_err).encode('utf-8')
        assert sys_err == ''

    request.addfinalizer(teardown)
    lsp_plugin = lsp_plugin.get_client('lsp')

    editor.show()

    return editor, lsp_plugin