Skip to content

Commit

Permalink
msautotest: add mspython in subdirectories explored by pytest, and sk…
Browse files Browse the repository at this point in the history
…ip properly mspython tests if mapscript not available
  • Loading branch information
rouault committed Feb 4, 2020
1 parent 98deaeb commit 5a6f8e8
Show file tree
Hide file tree
Showing 14 changed files with 80 additions and 20 deletions.
3 changes: 1 addition & 2 deletions msautotest/gdal/run_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,4 @@ def test(map, out_file, command, extra_args):
# main()

if __name__ == '__main__':
sys.argv[0] = 'run_test.py'
sys.exit(pytest.main())
sys.exit(mstestlib.pytest_main())
3 changes: 1 addition & 2 deletions msautotest/misc/run_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,4 @@ def test(map, out_file, command, extra_args):
# main()

if __name__ == '__main__':
sys.argv[0] = 'run_test.py'
sys.exit(pytest.main())
sys.exit(mstestlib.pytest_main())
10 changes: 8 additions & 2 deletions msautotest/mspython/test_bug_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,14 @@

import pmstestlib

import mapscript

mapscript_available = False
try:
import mapscript
mapscript_available = True
except ImportError:
pass

pytestmark = pytest.mark.skipif(not mapscript_available, reason="mapscript not available")

def get_relpath_to_this(filename):
return os.path.join(os.path.dirname(__file__), filename)
Expand Down
10 changes: 9 additions & 1 deletion msautotest/mspython/test_mapio.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,15 @@

import os
import pytest
import mapscript

mapscript_available = False
try:
import mapscript
mapscript_available = True
except ImportError:
pass

pytestmark = pytest.mark.skipif(not mapscript_available, reason="mapscript not available")


def get_relpath_to_this(filename):
Expand Down
9 changes: 8 additions & 1 deletion msautotest/mspython/test_ogr_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,14 @@

import pmstestlib

import mapscript
mapscript_available = False
try:
import mapscript
mapscript_available = True
except ImportError:
pass

pytestmark = pytest.mark.skipif(not mapscript_available, reason="mapscript not available")

###############################################################################
# Dump query result set ... used when debugging this test script.
Expand Down
10 changes: 9 additions & 1 deletion msautotest/mspython/test_rq.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,16 @@
import math

import pmstestlib
import pytest

import mapscript
mapscript_available = False
try:
import mapscript
mapscript_available = True
except ImportError:
pass

pytestmark = pytest.mark.skipif(not mapscript_available, reason="mapscript not available")

###############################################################################
# Dump query result set ... used when debugging this test script.
Expand Down
9 changes: 8 additions & 1 deletion msautotest/mspython/test_wkt.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@

import pytest

import mapscript
mapscript_available = False
try:
import mapscript
mapscript_available = True
except ImportError:
pass

pytestmark = pytest.mark.skipif(not mapscript_available, reason="mapscript not available")

###############################################################################
# Test simple geometries that should convert back to same thing - OGR only.
Expand Down
9 changes: 8 additions & 1 deletion msautotest/mspython/test_xmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,14 @@
import os
import pytest

import mapscript
mapscript_available = False
try:
import mapscript
mapscript_available = True
except ImportError:
pass

pytestmark = pytest.mark.skipif(not mapscript_available, reason="mapscript not available")


def get_relpath_to_this(filename):
Expand Down
23 changes: 23 additions & 0 deletions msautotest/pymod/mstestlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,3 +726,26 @@ def run_pytest(map, out_file, command, extra_args):

ret, msg = _run(map, out_file, command, extra_args)
assert ret, msg

###############################################################################


def pytest_main():
maps = []
new_argv = []
help = False
for arg in sys.argv:
if arg.endswith('.map'):
maps.append(arg[0:-4])
else:
if arg == '--help':
help = True
new_argv.append(arg)
sys.argv = new_argv
if maps:
sys.argv.append('-k')
sys.argv.append(' or '.join(maps))
ret = pytest.main()
if help:
print('\nMapServer note: you can also specify one or several .map filenames')
return ret
2 changes: 1 addition & 1 deletion msautotest/pytest.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[pytest]
python_files = *.py
testpaths = misc gdal query renderers wxs sld
testpaths = misc gdal query renderers wxs sld mspython

3 changes: 1 addition & 2 deletions msautotest/query/run_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,4 @@ def test(map, out_file, command, extra_args):
# main()

if __name__ == '__main__':
sys.argv[0] = 'run_test.py'
sys.exit(pytest.main())
sys.exit(mstestlib.pytest_main())
3 changes: 1 addition & 2 deletions msautotest/renderers/run_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,4 @@ def test(map, out_file, command, extra_args):
# main()

if __name__ == '__main__':
sys.argv[0] = 'run_test.py'
sys.exit(pytest.main())
sys.exit(mstestlib.pytest_main())
3 changes: 1 addition & 2 deletions msautotest/sld/run_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,4 @@ def test(map, out_file, command, extra_args):
# main()

if __name__ == '__main__':
sys.argv[0] = 'run_test.py'
sys.exit(pytest.main())
sys.exit(mstestlib.pytest_main())
3 changes: 1 addition & 2 deletions msautotest/wxs/run_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,4 @@ def test(map, out_file, command, extra_args):
# main()

if __name__ == '__main__':
sys.argv[0] = 'run_test.py'
sys.exit(pytest.main())
sys.exit(mstestlib.pytest_main())

0 comments on commit 5a6f8e8

Please sign in to comment.