Skip to content
Permalink
Browse files
Fix console import menu and add tests
  • Loading branch information
m-kuhn committed Apr 15, 2016
1 parent df23468 commit 8047a569e3cf26be9505490dcf6ea6e7a6596270
Showing with 39 additions and 2 deletions.
  1. +4 −2 python/console/console.py
  2. +1 −0 tests/src/python/CMakeLists.txt
  3. +34 −0 tests/src/python/test_console.py
@@ -31,6 +31,7 @@
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 @@ def __init__(self, parent=None):
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)
@@ -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()

0 comments on commit 8047a56

Please sign in to comment.