Skip to content

Commit

Permalink
Tweak the IDs in parametrized tests to be more useful
Browse files Browse the repository at this point in the history
  • Loading branch information
craigds committed Dec 10, 2018
1 parent b54e910 commit 46e92b7
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 25 deletions.
13 changes: 9 additions & 4 deletions autotest/gcore/hfa_srs.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,9 @@
from osgeo import osr



###############################################################################
# Write a HFA/Imagine and read it back to check its SRS

@pytest.mark.parametrize('epsg_code,epsg_broken', [
epsg_list = [
[2758, False], # tmerc
[2036, True], # sterea # failure caused by revert done in r22803
[2046, False], # tmerc
Expand All @@ -59,7 +57,14 @@
[2056, False], # somerc
[2027, False], # utm
[4326, False], # longlat
])
]


@pytest.mark.parametrize(
'epsg_code,epsg_broken',
epsg_list,
ids=[str(r[0]) for r in epsg_list],
)
def test_hfa_srs(epsg_code, epsg_broken):
sr = osr.SpatialReference()
sr.ImportFromEPSG(epsg_code)
Expand Down
15 changes: 10 additions & 5 deletions autotest/gcore/tiff_srs.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
from osgeo import osr




###############################################################################
# Test fix for #4677:

Expand Down Expand Up @@ -397,8 +395,7 @@ def _test_tiff_srs(sr, expect_fail):
###############################################################################
# Write a geotiff and read it back to check its SRS

@pytest.mark.parametrize('use_epsg_code', [0, 1])
@pytest.mark.parametrize('epsg_code,epsg_proj4_broken', [
epsg_list = [
[2758, False], # tmerc
[2036, False], # sterea
[2046, False], # tmerc
Expand Down Expand Up @@ -434,7 +431,15 @@ def _test_tiff_srs(sr, expect_fail):
[31491, False], # Germany Zone projection
[3857, True], # Web Mercator
[102113, True], # ESRI WGS_1984_Web_Mercator
])
]


@pytest.mark.parametrize('use_epsg_code', [0, 1])
@pytest.mark.parametrize(
'epsg_code,epsg_proj4_broken',
epsg_list,
ids=[str(r[0]) for r in epsg_list],
)
def test_tiff_srs(use_epsg_code, epsg_code, epsg_proj4_broken):
sr = osr.SpatialReference()
sr.ImportFromEPSG(epsg_code)
Expand Down
11 changes: 9 additions & 2 deletions autotest/gdrivers/mrf.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import gdaltest


@pytest.mark.parametrize('src_filename,chksum,chksum_after_reopening,options', [
mrf_list = [
('byte.tif', 4672, [4672], []),
('byte.tif', 4672, [4672], ['COMPRESS=DEFLATE']),
('byte.tif', 4672, [4672], ['COMPRESS=NONE']),
Expand Down Expand Up @@ -73,7 +73,14 @@
('rgbsmall.tif', 21212, [21261, 21209, 21254, 21215], ['INTERLEAVE=PIXEL', 'COMPRESS=JPEG', 'QUALITY=99', 'PHOTOMETRIC=RGB']),
('rgbsmall.tif', 21212, [21283, 21127, 21278, 21124], ['INTERLEAVE=PIXEL', 'COMPRESS=JPEG', 'QUALITY=99', 'PHOTOMETRIC=YCC']),
('12bit_rose_extract.jpg', 30075, [29650, 29680, 29680, 29650], ['COMPRESS=JPEG']),
])
]


@pytest.mark.parametrize(
'src_filename,chksum,chksum_after_reopening,options',
mrf_list,
ids=['{0}-{3}'.format(*r) for r in mrf_list],
)
def test_mrf(src_filename, chksum, chksum_after_reopening, options):
if src_filename == '12bit_rose_extract.jpg':
import jpeg
Expand Down
8 changes: 4 additions & 4 deletions autotest/ogr/ogr_gml_geom.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@


@pytest.mark.parametrize(
'unit',
'filename',
[
f[:-4] for f in os.listdir(os.path.join(os.path.dirname(__file__), 'data/wkb_wkt'))
f for f in os.listdir(os.path.join(os.path.dirname(__file__), 'data/wkb_wkt'))
if f[-4:] == '.wkt'
]
)
def test_gml_geom(unit):
raw_wkt = open('data/wkb_wkt/' + unit + '.wkt').read()
def test_gml_geom(filename):
raw_wkt = open('data/wkb_wkt/' + filename).read()

######################################################################
# Convert WKT to GML.
Expand Down
3 changes: 2 additions & 1 deletion autotest/ogr/ogr_sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -1520,7 +1520,8 @@ def test_ogr_spatialite_4(require_spatialite):

@pytest.mark.parametrize(
'bUseComprGeom',
[False, True]
[False, True],
ids=['dont-compress-geometries', 'compress-geometries']
)
def test_ogr_spatialite_5(require_spatialite, bUseComprGeom):
if bUseComprGeom and require_spatialite == '2.3.1':
Expand Down
6 changes: 5 additions & 1 deletion autotest/ogr/ogr_wfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ def ogr_wfs_init():
pytest.skip('failed to open test file.')


@pytest.fixture(params=['NO', None], scope='module')
@pytest.fixture(
params=['NO', None],
scope='module',
ids=['without-streaming', 'with-streaming']
)
def with_and_without_streaming(request):
with gdaltest.config_option('OGR_WFS_USE_STREAMING', request.param):
yield
Expand Down
10 changes: 5 additions & 5 deletions autotest/ogr/ogr_wkbwkt_geom.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@


@pytest.mark.parametrize(
'unit',
'filename',
[
f[:-4] for f in os.listdir(os.path.join(os.path.dirname(__file__), 'data/wkb_wkt'))
f for f in os.listdir(os.path.join(os.path.dirname(__file__), 'data/wkb_wkt'))
if f[-4:] == '.wkb'
]
)
def test_wkbwkt_geom(unit):
raw_wkb = open('data/wkb_wkt/' + unit + '.wkb', 'rb').read()
raw_wkt = open('data/wkb_wkt/' + unit + '.wkt').read()
def test_wkbwkt_geom(filename):
raw_wkb = open('data/wkb_wkt/' + filename, 'rb').read()
raw_wkt = open('data/wkb_wkt/' + os.path.splitext(filename)[0] + '.wkt').read()

######################################################################
# Compare the WKT derived from the WKB file to the WKT provided
Expand Down
12 changes: 9 additions & 3 deletions autotest/ogr/ogr_wktempty.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@

from osgeo import ogr


@pytest.mark.parametrize("test_input,expected", [
wkt_list = [
('GEOMETRYCOLLECTION(EMPTY)', 'GEOMETRYCOLLECTION EMPTY'),
('MULTIPOLYGON( EMPTY )', 'MULTIPOLYGON EMPTY'),
('MULTILINESTRING(EMPTY)', 'MULTILINESTRING EMPTY'),
Expand All @@ -48,7 +47,14 @@
('POINT EMPTY', 'POINT EMPTY'),
('LINESTRING EMPTY', 'LINESTRING EMPTY'),
('POLYGON EMPTY', 'POLYGON EMPTY')
])
]


@pytest.mark.parametrize(
"test_input,expected",
wkt_list,
ids=[r[0] for r in wkt_list]
)
def test_empty_wkt(test_input, expected):
geom = ogr.CreateGeometryFromWkt(test_input)
wkt = geom.ExportToWkt()
Expand Down

0 comments on commit 46e92b7

Please sign in to comment.