Skip to content
Permalink
Browse files
Update Python code to meet flake8 linting standards, remove custom te…
…st runner code, and rename files to match pytest naming conventions
  • Loading branch information
geographika committed Sep 9, 2018
1 parent 265c7e0 commit 2ccbe0d408406484d779f6c49c8f27d466687e6e
Show file tree
Hide file tree
Showing 27 changed files with 435 additions and 1,460 deletions.
@@ -1,12 +1,10 @@
# $Id$
#
# Project: MapServer
# Purpose: xUnit style Python mapscript tests of classObj
# Author: Sean Gillies, sgillies@frii.com
#
# ===========================================================================
# Copyright (c) 2004, Sean Gillies
#
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
@@ -25,38 +23,29 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
# ===========================================================================
#
# Execute this module as a script from mapserver/mapscript/python
#
# python tests/cases/classtest.py -v
#
# ===========================================================================

import os, sys
import unittest
import mapscript
from .testing import MapTestCase

# the testing module helps us import the pre-installed mapscript
from .testing import mapscript, MapTestCase

# ===========================================================================
# Test begins now

class ClassObjTestCase(unittest.TestCase):

def testConstructorNoArg(self):
c = mapscript.classObj()
assert c.thisown == 1
assert c.layer == None
assert c.layer is None
assert c.numstyles == 0

def testConstructorWithArg(self):
l = mapscript.layerObj()
l.name = 'foo'
c = mapscript.classObj(l)
lyr = mapscript.layerObj()
lyr.name = 'foo'
c = mapscript.classObj(lyr)
assert c.thisown == 1
assert c.layer.name == l.name
assert c.layer.name == lyr.name
assert c.numstyles == 0


class ClassCloningTestCase(unittest.TestCase):

def testCloneClass(self):
@@ -69,7 +58,7 @@ def testCloneClass(self):


class ClassIconTestCase(MapTestCase):

"""testing for bug 1250"""

def testAlphaTransparentPixmap(self):
@@ -109,10 +98,6 @@ def testIndexedTransparentPixmapJPG(self):
im = co.createLegendIcon(self.map, lo, 32, 32)
im.save('testIndexedTransparentPixmapIcon.jpg')


# ===========================================================================
# Run the tests outside of the main suite

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

@@ -1,12 +1,10 @@
# $Id$
#
# Project: MapServer
# Purpose: xUnit style Python mapscript tests of map cloning
# Author: Sean Gillies, sgillies@frii.com
#
# ===========================================================================
# Copyright (c) 2004, Sean Gillies
#
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
@@ -25,37 +23,23 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
# ===========================================================================
#
# Execute this module as a script from mapserver/mapscript/python
#
# python tests/cases/clonetest.py -v
#
# ===========================================================================

import os, sys
import unittest

# the testing module helps us import the pre-installed mapscript

from .testing import mapscript
import mapscript
from .testing import TESTMAPFILE

# ===========================================================================
# Base class

class MapCloneTestCase(unittest.TestCase):
"""Base class for testing with a map fixture"""

def setUp(self):
self.mapobj_orig = mapscript.mapObj(TESTMAPFILE)
self.mapobj_clone = self.mapobj_orig.clone()

def tearDown(self):
self.mapobj_orig = None
self.mapobj_clone = None

# ===========================================================================
# Tests begin here

class MapCloningTestCase(MapCloneTestCase):

@@ -72,12 +56,12 @@ def testClonedLayers(self):
def testSetFontSet(self):
"""MapCloningTestCase.testSetFontSet: the number of fonts in a cloned map equal original"""
assert self.mapobj_clone.fontset.numfonts == 2

def testSetSymbolSet(self):
"""MapCloningTestCase.testSetSymbolSet: the number of symbols in a cloned map equal original"""
num = self.mapobj_clone.symbolset.numsymbols
assert num == 5, num

def testDrawClone(self):
"""drawing a cloned map works properly"""
msimg = self.mapobj_clone.draw()
@@ -112,6 +96,6 @@ def testDrawClonePNG24(self):
fh.write(data)
fh.close()


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

This file was deleted.

@@ -1,12 +1,10 @@
# $Id$
#
# Project: MapServer
# Purpose: xUnit style Python mapscript tests of hashTableObj
# Author: Sean Gillies, sgillies@frii.com
#
# ===========================================================================
# Copyright (c) 2004, Sean Gillies
#
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
@@ -25,18 +23,11 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
# ===========================================================================
#
# Execute this module as a script from mapserver/mapscript/python
#
# python tests/cases/hashtest.py -v
#
# ===========================================================================

import os, sys
import os
import unittest

# the testing module helps us import the pre-installed mapscript
from .testing import mapscript, TESTMAPFILE, TESTS_PATH
import mapscript
from .testing import TESTS_PATH


class FontTestCase(unittest.TestCase):
@@ -47,17 +38,17 @@ def testSettingFonts(self):
mo.fontset.fonts.set('Vera', os.path.join(TESTS_PATH, 'vera',
'Vera.ttf'))
# NB: this does *not* increment the fonset.numfonts -- new bug

mo.setSize(300, 300)
mo.setExtent(-1.0, -1.0, 1.0, 1.0)

lo = mapscript.layerObj()
lo.type = mapscript.MS_LAYER_POINT
lo.connectiontype = mapscript.MS_INLINE
lo.status = mapscript.MS_DEFAULT

co = mapscript.classObj()
lbl =mapscript.labelObj()
lbl = mapscript.labelObj()
lbl.type = mapscript.MS_TRUETYPE
lbl.font = 'Vera'
lbl.size = 10
@@ -67,13 +58,13 @@ def testSettingFonts(self):
so = mapscript.styleObj()
so.symbol = 0
so.color.setHex('#000000')

co.insertStyle(so)
lo.insertClass(co)
li = mo.insertLayer(lo)
lo = mo.getLayer(li)

point = mapscript.pointObj(0,0)
point = mapscript.pointObj(0, 0)
line = mapscript.lineObj()
line.add(point)
shape = mapscript.shapeObj(lo.type)
@@ -84,16 +75,11 @@ def testSettingFonts(self):

lo.addFeature(shape)
im = mo.draw()
#im = mo.prepareImage()
#shape.draw(mo, lo, im)

# im = mo.prepareImage()
# shape.draw(mo, lo, im)
im.save('testSettingFonts.png')



# ===========================================================================
# Run the tests outside of the main suite

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

0 comments on commit 2ccbe0d

Please sign in to comment.