Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autotest: ogr_gpsbabel.py: skip if build lacks Expat support (fixes #4420) #4423

Merged
merged 1 commit into from
Sep 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions autotest/ogr/ogr_gpsbabel.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,27 @@
from osgeo import gdal
import pytest

def gpsbabel_binary_found():
try:
ret = gdaltest.runexternal('gpsbabel -V')
return 'GPSBabel' in ret
except OSError:
return False


pytestmark = [ pytest.mark.require_driver('GPSBabel'),
pytest.mark.require_driver('GPX') ]
pytest.mark.require_driver('GPX'),
pytest.mark.skipif(not gpsbabel_binary_found(), reason='GPSBabel utility not found') ]

###############################################################################
@pytest.fixture(autouse=True, scope='module')
def startup_and_cleanup():

# Test if the gpsbabel is accessible
try:
ret = gdaltest.runexternal('gpsbabel -V')
except OSError:
ret = ''
if ret.find('GPSBabel') == -1:
pytest.skip('Cannot access GPSBabel utility')
# Check that the GPX driver has read support
with gdaltest.error_handler():
if ogr.Open('data/gpx/test.gpx') is None:
assert 'Expat' in gdal.GetLastErrorMsg()
pytest.skip('GDAL build without Expat support')

###############################################################################
# Test reading with explicit subdriver
Expand Down
8 changes: 5 additions & 3 deletions autotest/ogr/ogr_gpx.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@

pytestmark = pytest.mark.require_driver('GPX')


###############################################################################
@pytest.fixture(autouse=True, scope='module')
def startup_and_cleanup():

if ogr.Open('data/gpx/test.gpx') is None:
pytest.skip()
# Check that the GPX driver has read support
with gdaltest.error_handler():
if ogr.Open('data/gpx/test.gpx') is None:
assert 'Expat' in gdal.GetLastErrorMsg()
pytest.skip('GDAL build without Expat support')

yield

Expand Down