Skip to content

Commit

Permalink
Added test for QgsMapLayerRegistry
Browse files Browse the repository at this point in the history
See: PR #2534
  • Loading branch information
elpaso authored and m-kuhn committed Dec 5, 2015
1 parent 0e82974 commit 5a7ee20
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/src/python/CMakeLists.txt
Expand Up @@ -61,6 +61,8 @@ ADD_PYTHON_TEST(PyQgsVectorColorRamp test_qgsvectorcolorramp.py)
ADD_PYTHON_TEST(PyQgsVectorFileWriter test_qgsvectorfilewriter.py)
ADD_PYTHON_TEST(PyQgsVectorLayer test_qgsvectorlayer.py)
ADD_PYTHON_TEST(PyQgsZonalStatistics test_qgszonalstatistics.py)
ADD_PYTHON_TEST(PyQgsMapLayerRegistry test_qgsmaplayerregistry.py)


IF (NOT WIN32)
ADD_PYTHON_TEST(PyQgsLogger test_qgslogger.py)
Expand Down
31 changes: 31 additions & 0 deletions tests/src/python/test_qgsmaplayerregistry.py
@@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
"""QGIS Unit tests for QgsServer.
.. 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__ = 'Alessandro Pasotti'
__date__ = '04/12/2015'
__copyright__ = 'Copyright 2015, The QGIS Project'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

import unittest
from qgis.core import QgsMapLayerRegistry


class TestQgsMapLayerRegistry(unittest.TestCase):

def setUp(self):
pass

def test_removeMapLayer(self):

This comment has been minimized.

Copy link
@NathanW2

NathanW2 Dec 7, 2015

Member

Might want to give you test methods at a better name: test_RemoveLayerShouldNotSegFault I like descriptive test method name :) Don't feel bad using long names no one is going to type it out.

reg = QgsMapLayerRegistry.instance()
# Should not segfault
reg.removeMapLayers(['not_exists'])


if __name__ == '__main__':
unittest.main()

0 comments on commit 5a7ee20

Please sign in to comment.