mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
Fix console import menu and add tests
This commit is contained in:
parent
df234681c5
commit
8047a569e3
@ -31,6 +31,7 @@ from .console_editor import EditorTabWidget
|
||||
from .console_settings import optionsDialog
|
||||
from qgis.core import QgsApplication, QgsContextHelp
|
||||
from qgis.gui import QgsFilterLineEdit
|
||||
from functools import partial
|
||||
|
||||
import sys
|
||||
|
||||
@ -58,6 +59,8 @@ def show_console():
|
||||
QgsContextHelp.run("PythonConsole")
|
||||
settings.setValue('pythonConsole/contextHelpOnFirstLaunch', False)
|
||||
|
||||
return _console
|
||||
|
||||
_console_output = None
|
||||
|
||||
# hook for python console so all output will be redirected
|
||||
@ -409,8 +412,7 @@ class PythonConsoleWidget(QWidget):
|
||||
self.classMenu = QMenu()
|
||||
for (title, icon), commands in default_command.items():
|
||||
action = self.classMenu.addAction(icon, title)
|
||||
action.triggered.connect(
|
||||
lambda commands=commands: self.shell.commandConsole(commands))
|
||||
action.triggered.connect(partial(self.shell.commandConsole, commands))
|
||||
|
||||
cM = self.toolBar.widgetForAction(self.actionClass)
|
||||
cM.setMenu(self.classMenu)
|
||||
|
@ -75,6 +75,7 @@ ADD_PYTHON_TEST(PyQgsVirtualLayerProvider test_provider_virtual.py)
|
||||
ADD_PYTHON_TEST(PyQgsVirtualLayerDefinition test_qgsvirtuallayerdefinition.py)
|
||||
ADD_PYTHON_TEST(PyQgsLayerDefinition test_qgslayerdefinition.py)
|
||||
ADD_PYTHON_TEST(PyQgsWFSProvider test_provider_wfs.py)
|
||||
ADD_PYTHON_TEST(PyQgsConsole test_console.py)
|
||||
|
||||
IF (NOT WIN32)
|
||||
ADD_PYTHON_TEST(PyQgsLogger test_qgslogger.py)
|
||||
|
34
tests/src/python/test_console.py
Normal file
34
tests/src/python/test_console.py
Normal file
@ -0,0 +1,34 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""QGIS Unit tests for the console
|
||||
|
||||
.. note:: This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
"""
|
||||
__author__ = 'Matthias Kuhn'
|
||||
__date__ = '15.4.2016'
|
||||
__copyright__ = 'Copyright 2015, The QGIS Project'
|
||||
# This will get replaced with a git SHA1 when you do a git archive
|
||||
__revision__ = '$Format:%H$'
|
||||
|
||||
import qgis # NOQA
|
||||
|
||||
from qgis.testing import unittest, start_app
|
||||
from console import console
|
||||
|
||||
start_app()
|
||||
|
||||
|
||||
class TestConsole(unittest.TestCase):
|
||||
|
||||
def test_show_console(self):
|
||||
my_console = console.show_console()
|
||||
my_console_widget = my_console.console
|
||||
|
||||
for action in my_console_widget.classMenu.actions():
|
||||
action.trigger()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
Loading…
x
Reference in New Issue
Block a user