From 80a693a1c91428e73b3c85488034430533c9c383 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Thu, 21 Mar 2024 10:41:55 +0100 Subject: [PATCH 1/2] test_ogr_miramon_test_ogrsf: slightly more idiomatic --- autotest/ogr/ogr_miramon_vector.py | 91 ++++++++---------------------- 1 file changed, 25 insertions(+), 66 deletions(-) diff --git a/autotest/ogr/ogr_miramon_vector.py b/autotest/ogr/ogr_miramon_vector.py index 726527aa37b1..7881651aa103 100644 --- a/autotest/ogr/ogr_miramon_vector.py +++ b/autotest/ogr/ogr_miramon_vector.py @@ -34,12 +34,11 @@ import gdaltest -# from osgeo import gdal, ogr, osr -from osgeo import gdal, ogr - # import ogrtest -# import pytest +import pytest +# from osgeo import gdal, ogr, osr +from osgeo import gdal, ogr ############################################################################### # basic point test @@ -426,70 +425,30 @@ def test_ogr_miramon_3d_pol(): ############################################################################### -def test_ogr_miramon_test_ogrsf(): +@pytest.mark.parametrize( + "filename", + [ + "Points/3dpoints/Some3dPoints.pnt", + "Points/SimplePoints/SimplePointsFile.pnt", + "Points/EmptyPoints/Empty_PNT.pnt", + "Arcs/SimpleArcs/SimpleArcFile.arc", + "Arcs/EmptyArcs/Empty_ARC.arc", + "Arcs/3dArcs/linies_3d_WGS84.arc", + "Polygons/SimplePolygons/SimplePolFile.pol", + "Polygons/EmptyPolygons/Empty_POL.pol", + "Polygons/3dPolygons/tin_3d.pol", + ], +) +def test_ogr_miramon_test_ogrsf(filename): import test_cli_utilities - if test_cli_utilities.get_test_ogrsf_path() is not None: - ret = gdaltest.runexternal( - test_cli_utilities.get_test_ogrsf_path() - + " data/miramon/Points/3dpoints/Some3dPoints.pnt" - ) - - assert ret.find("INFO") != -1 and ret.find("ERROR") == -1 - - ret = gdaltest.runexternal( - test_cli_utilities.get_test_ogrsf_path() - + " data/miramon/Points/SimplePoints/SimplePointsFile.pnt" - ) - - assert ret.find("INFO") != -1 and ret.find("ERROR") == -1 - - ret = gdaltest.runexternal( - test_cli_utilities.get_test_ogrsf_path() - + " data/miramon/Points/EmptyPoints/Empty_PNT.pnt" - ) - - assert ret.find("INFO") != -1 and ret.find("ERROR") == -1 - - ret = gdaltest.runexternal( - test_cli_utilities.get_test_ogrsf_path() - + " data/miramon/Arcs/SimpleArcs/SimpleArcFile.arc" - ) + if test_cli_utilities.get_test_ogrsf_path() is None: + pytest.skip("test_ogrsf not available") - assert ret.find("INFO") != -1 and ret.find("ERROR") == -1 - - ret = gdaltest.runexternal( - test_cli_utilities.get_test_ogrsf_path() - + " data/miramon/Arcs/EmptyArcs/Empty_ARC.arc" - ) - - assert ret.find("INFO") != -1 and ret.find("ERROR") == -1 - - ret = gdaltest.runexternal( - test_cli_utilities.get_test_ogrsf_path() - + " data/miramon/Arcs/3dArcs/linies_3d_WGS84.arc" - ) - - assert ret.find("INFO") != -1 and ret.find("ERROR") == -1 - - ret = gdaltest.runexternal( - test_cli_utilities.get_test_ogrsf_path() - + " data/miramon/Polygons/SimplePolygons/SimplePolFile.pol" - ) - - assert ret.find("INFO") != -1 and ret.find("ERROR") == -1 - - ret = gdaltest.runexternal( - test_cli_utilities.get_test_ogrsf_path() - + " data/miramon/Polygons/EmptyPolygons/Empty_POL.pol" - ) - - assert ret.find("INFO") != -1 and ret.find("ERROR") == -1 - - ret = gdaltest.runexternal( - test_cli_utilities.get_test_ogrsf_path() - + " data/miramon/Polygons/3dPolygons/tin_3d.pol" - ) + ret = gdaltest.runexternal( + test_cli_utilities.get_test_ogrsf_path() + " data/miramon/" + filename + ) - assert ret.find("INFO") != -1 and ret.find("ERROR") == -1 + assert "INFO" in ret + assert "ERROR" not in ret From c297abdc335944568c7e4f8a3a4e1ba92ffaaf12 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Thu, 21 Mar 2024 11:02:22 +0100 Subject: [PATCH 2/2] Skip MiraMon tests when driver not available --- autotest/ogr/ogr_miramon_vector.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/autotest/ogr/ogr_miramon_vector.py b/autotest/ogr/ogr_miramon_vector.py index 7881651aa103..414f6185c6a1 100644 --- a/autotest/ogr/ogr_miramon_vector.py +++ b/autotest/ogr/ogr_miramon_vector.py @@ -40,6 +40,8 @@ # from osgeo import gdal, ogr, osr from osgeo import gdal, ogr +pytestmark = pytest.mark.require_driver("MiraMonVector") + ############################################################################### # basic point test