Skip to content
Permalink
Browse files

Add unit tests

  • Loading branch information
m-kuhn committed Dec 23, 2020
1 parent 6ddb13a commit 2b4a2332af29e567523c314809b20bcdfda99785
Showing with 15 additions and 0 deletions.
  1. +15 −0 tests/src/python/test_qgsmaplayer.py
@@ -15,6 +15,7 @@
import tempfile
import glob
import shutil
import sip

from qgis.core import (QgsReadWriteContext,
QgsVectorLayer,
@@ -185,6 +186,20 @@ def testIsTemporary(self):
self.assertTrue(rl.isValid())
self.assertTrue(rl.isTemporary())

def testQgsMapLayerProject(self):
layer = QgsVectorLayer(os.path.join(TEST_DATA_DIR, 'points.shp'), "layer", "ogr")
self.assertIsNone(layer.project())
project = QgsProject()
project.addMapLayer(layer)
self.assertEqual(layer.project(), project)
project2 = QgsProject()
project2.addMapLayer(layer)
self.assertEqual(layer.project(), project2)
project.removeMapLayer(layer)
self.assertFalse(sip.isdeleted(layer))
project2.removeMapLayer(layer)
self.assertTrue(sip.isdeleted(layer))


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

0 comments on commit 2b4a233

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