Permalink
Browse files

Use tests paths to find polygon.shp

  • Loading branch information...
geographika committed Mar 19, 2018
1 parent 4ccc7a7 commit 8499edce3406a4e60b324d59b2fbdadba526259d
Showing with 9 additions and 7 deletions.
  1. +9 −7 mapscript/python/tests/cases/shapefiletest.py
@@ -33,9 +33,10 @@
# ===========================================================================
import unittest
import os
# the testing module helps us import the pre-installed mapscript
from testing import mapscript
from testing import mapscript, TESTS_PATH
class AddShapeTestCase(unittest.TestCase):
@@ -47,12 +48,13 @@ def testAddEmpty(self):
self.assertRaises(mapscript.MapServerError, sf.add, so)
def testGetDBFInfo(self):
"""Fetch dbf information from shapefile"""
sf = mapscript.shapefileObj('../../../../tests/polygon.shp')
assert sf.getDBF() != None, sf.getDBF()
assert sf.getDBF().nFields == 2, sf.getDBF().nFields
assert sf.getDBF().getFieldName(0) == 'FID', sf.getDBF().getFieldName(0)
assert sf.getDBF().getFieldName(1) == 'FNAME', sf.getDBF().getFieldName(1)
"""Fetch dbf information from shapefile"""
pth = os.path.join(TESTS_PATH, "polygon.shp")
sf = mapscript.shapefileObj(pth)
assert sf.getDBF() != None, sf.getDBF()
assert sf.getDBF().nFields == 2, sf.getDBF().nFields
assert sf.getDBF().getFieldName(0) == 'FID', sf.getDBF().getFieldName(0)
assert sf.getDBF().getFieldName(1) == 'FNAME', sf.getDBF().getFieldName(1)
if __name__ == '__main__':

0 comments on commit 8499edc

Please sign in to comment.