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
Showing with 435 additions and 1,460 deletions.
  1. +11 −26 mapscript/python/tests/cases/class_test.py
  2. +6 −22 mapscript/python/tests/cases/clone_test.py
  3. +0 −94 mapscript/python/tests/cases/colort_est.py
  4. +12 −26 mapscript/python/tests/cases/font_test.py
  5. +18 −30 mapscript/python/tests/cases/hash_test.py
  6. +19 −26 mapscript/python/tests/cases/image_test.py
  7. +6 −20 mapscript/python/tests/cases/label_test.py
  8. +71 −71 mapscript/python/tests/cases/layer_test.py
  9. +10 −17 mapscript/python/tests/cases/line_test.py
  10. +71 −53 mapscript/python/tests/cases/map_test.py
  11. +6 −21 mapscript/python/tests/cases/outputformat_test.py
  12. +11 −26 mapscript/python/tests/cases/ows_test.py
  13. +0 −131 mapscript/python/tests/cases/parentreference.py
  14. +11 −12 mapscript/python/tests/cases/pgtest.py
  15. +7 −18 mapscript/python/tests/cases/point_test.py
  16. +10 −24 mapscript/python/tests/cases/rect_test.py
  17. +0 −332 mapscript/python/tests/cases/refcount.py
  18. +16 −30 mapscript/python/tests/cases/resultcache_test.py
  19. +0 −66 mapscript/python/tests/cases/runalltests.py
  20. +29 −38 mapscript/python/tests/cases/shape_test.py
  21. +7 −15 mapscript/python/tests/cases/shapefile_test.py
  22. +28 −30 mapscript/python/tests/cases/style_test.py
  23. +15 −31 mapscript/python/tests/cases/symbol_test.py
  24. +18 −31 mapscript/python/tests/cases/symbolset_test.py
  25. +20 −33 mapscript/python/tests/cases/testing.py
  26. +0 −204 mapscript/python/tests/cases/threadtest.py
  27. +33 −33 mapscript/python/tests/cases/zoom_test.py
@@ -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.

Oops, something went wrong.
@@ -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()

Oops, something went wrong.

0 comments on commit 2ccbe0d

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