Skip to content
Permalink
Browse files

Merge branch 'master' of github.com:qgis/Quantum-GIS

  • Loading branch information
etiennesky committed Sep 7, 2012
2 parents 09c3693 + 2e8d82f commit 595d2a5f70c10176dd2205884e512af93314e8d7
Showing with 43 additions and 1 deletion.
  1. +1 −0 tests/src/python/CMakeLists.txt
  2. +24 −0 tests/src/python/test_qgsvectorlayer.py
  3. +18 −1 tests/src/python/utilities.py
@@ -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)
@@ -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()

@@ -67,8 +67,25 @@ def getQgisTestApp():

if QGISAPP is None:
myGuiFlag = True # All test will run qgis in gui mode

QGISAPP = QgsApplication(sys.argv, myGuiFlag)
# Note: QGIS_PREFIX_PATH is set by cmake to the output dir
if 'QGIS_PREFIX_PATH' in os.environ:
myPath = os.environ['QGIS_PREFIX_PATH']
myUseDefaultPathFlag = True
QGISAPP.setPrefixPath(myPath, myUseDefaultPathFlag)

if sys.platform.startswith('darwin'):
# override resource paths, otherwise looks for Resources in app
if 'QGIS_MAC_PKGDATA_DIR' in os.environ:
myPkgPath = os.environ['QGIS_MAC_PKGDATA_DIR']
QGISAPP.setPkgDataPath(myPkgPath)
if 'QGIS_MAC_SVG_DIR' in os.environ:
mySVGPath = os.environ['QGIS_MAC_SVG_DIR']
mySVGPaths = QGISAPP.svgPaths()
# doesn't get rid of incorrect path, just adds correct one
mySVGPaths.prepend(mySVGPath)
QGISAPP.setDefaultSvgPaths(mySVGPaths)

QGISAPP.initQgis()
s = QGISAPP.showSettings()
print s

0 comments on commit 595d2a5

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