Permalink
Browse files

Merge pull request #5670 from geographika/pylint-and-examples

Add Flake8 checks for Python test code
  • Loading branch information...
geographika committed Sep 28, 2018
2 parents 265c7e0 + d392122 commit 3d2495489806413f23117216d8e57d5d219460c0
Showing with 454 additions and 1,463 deletions.
  1. +3 −0 appveyor.yml
  2. +14 −2 mapscript/python/CMakeLists.txt
  3. +2 −1 mapscript/python/requirements-dev.txt
  4. +11 −26 mapscript/python/tests/cases/class_test.py
  5. +6 −22 mapscript/python/tests/cases/clone_test.py
  6. +0 −94 mapscript/python/tests/cases/colort_est.py
  7. +12 −26 mapscript/python/tests/cases/font_test.py
  8. +18 −30 mapscript/python/tests/cases/hash_test.py
  9. +19 −26 mapscript/python/tests/cases/image_test.py
  10. +6 −20 mapscript/python/tests/cases/label_test.py
  11. +71 −71 mapscript/python/tests/cases/layer_test.py
  12. +10 −17 mapscript/python/tests/cases/line_test.py
  13. +71 −53 mapscript/python/tests/cases/map_test.py
  14. +6 −21 mapscript/python/tests/cases/outputformat_test.py
  15. +11 −26 mapscript/python/tests/cases/ows_test.py
  16. +0 −131 mapscript/python/tests/cases/parentreference.py
  17. +11 −12 mapscript/python/tests/cases/pgtest.py
  18. +7 −18 mapscript/python/tests/cases/point_test.py
  19. +10 −24 mapscript/python/tests/cases/rect_test.py
  20. +0 −332 mapscript/python/tests/cases/refcount.py
  21. +16 −30 mapscript/python/tests/cases/resultcache_test.py
  22. +0 −66 mapscript/python/tests/cases/runalltests.py
  23. +29 −38 mapscript/python/tests/cases/shape_test.py
  24. +7 −15 mapscript/python/tests/cases/shapefile_test.py
  25. +28 −30 mapscript/python/tests/cases/style_test.py
  26. +15 −31 mapscript/python/tests/cases/symbol_test.py
  27. +18 −31 mapscript/python/tests/cases/symbolset_test.py
  28. +20 −33 mapscript/python/tests/cases/testing.py
  29. +0 −204 mapscript/python/tests/cases/threadtest.py
  30. +33 −33 mapscript/python/tests/cases/zoom_test.py
View
@@ -4,6 +4,9 @@ platform:
- x64
- x86
cache:
- '%LOCALAPPDATA%\pip\Cache'
environment:
matrix:
# VS 2017
@@ -92,22 +92,34 @@ add_custom_command(
OUTPUT mapscriptvenvpop.stamp
WORKING_DIRECTORY ${OUTPUT_FOLDER}
COMMENT "Installing the required packages into the virtual environment"
COMMAND ${PYTHON_VENV_SCRIPTS}/python -m pip install pip --upgrade
COMMAND ${PYTHON_VENV_SCRIPTS}/python -m pip install pip --upgrade --force-reinstall
COMMAND ${PYTHON_VENV_SCRIPTS}/pip install -r ${PROJECT_SOURCE_DIR}/mapscript/python/requirements-dev.txt
)
add_custom_command(
DEPENDS mapscriptvenvpop.stamp
OUTPUT mapscriptlinting.stamp
WORKING_DIRECTORY ${OUTPUT_FOLDER}
COMMENT "Linting test code files with flake8"
COMMAND ${PYTHON_VENV_SCRIPTS}/flake8 $<TARGET_FILE_DIR:${SWIG_MODULE_pythonmapscript_REAL_NAME}>/mapscript/tests --max-line-length=120
)
add_custom_command(
DEPENDS mapscriptlinting.stamp
OUTPUT mapscriptwheel.stamp
WORKING_DIRECTORY ${OUTPUT_FOLDER}
COMMENT "Building the mapscript Python wheel"
COMMENT "Copying files required to build Mapscript"
COMMAND ${CMAKE_COMMAND} -E copy "${PROJECT_SOURCE_DIR}/mapscript/python/mapscript/__init__.py" $<TARGET_FILE_DIR:${SWIG_MODULE_pythonmapscript_REAL_NAME}>/mapscript/__init__.py
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_BINARY_DIR}/mapscript.py" $<TARGET_FILE_DIR:${SWIG_MODULE_pythonmapscript_REAL_NAME}>/mapscript/mapscript.py
COMMAND ${CMAKE_COMMAND} -E copy "$<TARGET_FILE:${SWIG_MODULE_pythonmapscript_REAL_NAME}>" "$<TARGET_FILE_DIR:${SWIG_MODULE_pythonmapscript_REAL_NAME}>/mapscript/$<TARGET_FILE_NAME:${SWIG_MODULE_pythonmapscript_REAL_NAME}>"
COMMAND ${CMAKE_COMMAND} -E copy "${PROJECT_SOURCE_DIR}/mapscript/python/README.rst" $<TARGET_FILE_DIR:${SWIG_MODULE_pythonmapscript_REAL_NAME}>/README.rst
COMMAND ${CMAKE_COMMAND} -E copy_directory "${PROJECT_SOURCE_DIR}/mapscript/python/tests/cases" $<TARGET_FILE_DIR:${SWIG_MODULE_pythonmapscript_REAL_NAME}>/mapscript/tests
# now check the Python test code with flake8
COMMENT "Linting test code files"
COMMAND ${PYTHON_VENV_SCRIPTS}/flake8 $<TARGET_FILE_DIR:${SWIG_MODULE_pythonmapscript_REAL_NAME}>/mapscript/tests --max-line-length=120
COMMAND ${CMAKE_COMMAND} -E copy_directory "${PROJECT_SOURCE_DIR}/tests" $<TARGET_FILE_DIR:${SWIG_MODULE_pythonmapscript_REAL_NAME}>/mapscript/tests/data
COMMAND ${CMAKE_COMMAND} -E copy_directory "${PROJECT_SOURCE_DIR}/mapscript/python/examples" $<TARGET_FILE_DIR:${SWIG_MODULE_pythonmapscript_REAL_NAME}>/mapscript/examples
COMMENT "Building the mapscript Python wheel"
COMMAND ${PYTHON_VENV_SCRIPTS}/python setup.py bdist_wheel
)
@@ -1,4 +1,5 @@
pytest
pillow
wheel>=0.31.1
setuptools>=40.2.0
setuptools>=40.2.0
flake8
@@ -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.
Oops, something went wrong.

0 comments on commit 3d24954

Please sign in to comment.