Skip to content

Commit

Permalink
Added simple python vector layer test
Browse files Browse the repository at this point in the history
  • Loading branch information
timlinux committed Sep 7, 2012
1 parent 85b4a36 commit 2e8d82f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/src/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ ADD_PYTHON_TEST(PyQGisApp test_qgisapp.py)
ADD_PYTHON_TEST(PyQgsComposerHtml test_qgscomposerhtml.py)
ADD_PYTHON_TEST(PyQgsComposerMap test_qgscomposermap.py)
ADD_PYTHON_TEST(PyQgsGeometry test_qgsgeometry.py)
ADD_PYTHON_TEST(PyQgsVectorLayer test_qgsvectorlayer.py)
ADD_PYTHON_TEST(PyQgsRasterLayer test_qgsrasterlayer.py)
ADD_PYTHON_TEST(PyQgsRasterFileWriter test_qgsrasterfilewriter.py)
ADD_PYTHON_TEST(PyQgsMemoryProvider test_qgsmemoryprovider.py)
Expand Down
24 changes: 24 additions & 0 deletions tests/src/python/test_qgsvectorlayer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import os
import unittest

from PyQt4.QtCore import QDir

from qgis.core import QgsVectorLayer
from utilities import getQgisTestApp, unitTestDataPath

QGISAPP, CANVAS, IFACE, PARENT = getQgisTestApp()


class TestQgsVectorLayer(unittest.TestCase):

def test_FeatureCount(self):
myPath = os.path.join(unitTestDataPath(), 'lines.shp')
myLayer = QgsVectorLayer(myPath, 'Lines', 'ogr')
myCount = myLayer.featureCount()
myExpectedCount = 6
myMessage = '\nExpected: %s\nGot: %s' % (myCount, myExpectedCount)
assert myCount == myExpectedCount, myMessage

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

0 comments on commit 2e8d82f

Please sign in to comment.