Skip to content
Permalink
Browse files

Fix QgsMapLayerRegistry test on Travis builds

  • Loading branch information
nyalldawson committed Jul 4, 2016
1 parent ea32e6a commit a0f329e3040ce4108065350d27f8b910c23c2898
Showing with 6 additions and 2 deletions.
  1. +6 −2 tests/src/python/test_qgsmaplayerregistry.py
@@ -14,7 +14,6 @@

from qgis.core import QgsMapLayerRegistry, QgsVectorLayer, QgsMapLayer
from qgis.testing import start_app, unittest
from qgis.PyQt.QtTest import QSignalSpy
from qgis.PyQt.QtCore import QT_VERSION_STR
import sip

@@ -94,6 +93,8 @@ def test_addMapLayerInvalid(self):
def test_addMapLayerSignals(self):
""" test that signals are correctly emitted when adding map layer"""

QgsMapLayerRegistry.instance().removeAllMapLayers()

layer_was_added_spy = QSignalSpy(QgsMapLayerRegistry.instance().layerWasAdded)
layers_added_spy = QSignalSpy(QgsMapLayerRegistry.instance().layersAdded)
legend_layers_added_spy = QSignalSpy(QgsMapLayerRegistry.instance().legendLayersAdded)
@@ -108,7 +109,7 @@ def test_addMapLayerSignals(self):
self.assertEqual(len(legend_layers_added_spy), 1)

# layer not added to legend
QgsMapLayerRegistry.instance().addMapLayer(createLayer('test'), False)
QgsMapLayerRegistry.instance().addMapLayer(createLayer('test2'), False)
self.assertEqual(len(layer_was_added_spy), 2)
self.assertEqual(len(layers_added_spy), 2)
self.assertEqual(len(legend_layers_added_spy), 1)
@@ -170,6 +171,7 @@ def test_addMapLayersAlreadyAdded(self):
@unittest.skipIf(not use_signal_spy, "No QSignalSpy available")
def test_addMapLayersSignals(self):
""" test that signals are correctly emitted when adding map layers"""
QgsMapLayerRegistry.instance().removeAllMapLayers()

layer_was_added_spy = QSignalSpy(QgsMapLayerRegistry.instance().layerWasAdded)
layers_added_spy = QSignalSpy(QgsMapLayerRegistry.instance().layersAdded)
@@ -465,6 +467,8 @@ def test_addRemoveLayersSignals(self):
self.assertEqual(len(remove_all_spy), 1)

def test_RemoveLayerShouldNotSegFault(self):
QgsMapLayerRegistry.instance().removeAllMapLayers()

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

0 comments on commit a0f329e

Please sign in to comment.
You can’t perform that action at this time.