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: Make more tests independent #8185

Merged
merged 36 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
7c242a9
autotest test_pct.py: make tests independent, use tmp_path
dbaston Jul 13, 2023
cbd9e55
autotest mask.py: make tests independent
dbaston Jul 13, 2023
065ee78
autotest histogram.py: make tests independent
dbaston Jul 14, 2023
0680ef4
autotest numpy_rw_multidim.py: move setup to fixture
dbaston Jul 14, 2023
2c68e9c
autotest vsicrypt.py: move setup to fixture
dbaston Jul 14, 2023
cb0a255
autotest vsihdfs.py: move setup into fixture
dbaston Jul 19, 2023
bdbfedb
autotest gcore/tiff: make tests independent
dbaston Jun 28, 2023
08f5f97
autotest hfa_rfc40.py: mark to disabled random order
dbaston Jul 19, 2023
cbee9ce
autotest gif.py: make tests independent
dbaston Jul 20, 2023
3cc7299
autotest bsb.py: use pytest.mark.require_driver
dbaston Jul 20, 2023
69948a6
autotest bt.py: use pytest.mark.parameterize, move cleanup to fixture
dbaston Jul 20, 2023
159a11b
autotest vrtrawlink.py: make tests independent, use tmp_path
dbaston Jul 24, 2023
4a84627
autotest vrtwarp.py: combine two interdependent tests
dbaston Jul 24, 2023
29c3fc8
autotest rasterlite.py: combine two interdependent tests
dbaston Jul 28, 2023
327123d
autotest postgisraster.py: move cleanup into fixture, add skip messages
dbaston Jul 28, 2023
bb09421
autotest mbtiles.py: move webserver into fixture
dbaston Jul 28, 2023
c1ccf5c
autotest test_validate_jp2.py: move setup, cleanup into fixture
dbaston Jul 28, 2023
927a698
autotest kmlsuperoverlay.py: move cleanup into fixture
dbaston Jul 28, 2023
7f82c36
autotest jpeg.py: make tests independent
dbaston Jul 28, 2023
f2a02af
autotest hfa.py: combine interdependent tests
dbaston Jul 28, 2023
e2f6248
autotest srtmhgt.py: make tests independent
dbaston Jul 28, 2023
8b4113d
autotest srp.py: parametrize tests, use fixture for cleanup
dbaston Jul 28, 2023
7414e37
autotest ehdr.py: merge two interdependent tests
dbaston Jul 29, 2023
26c20eb
autotest esric.py: use fixture for sample dataset
dbaston Jul 29, 2023
a54f8d6
autotest fast.py: use fixture for test dataset
dbaston Jul 29, 2023
9c3f683
autotest wms.py: update SEDAC url, re-enable tests
dbaston Jul 31, 2023
e20a7bf
autotest wms.py: use new ESRI test server
dbaston Jul 31, 2023
40ce328
autotest wms.py: pull TileCache test server into fixture
dbaston Jul 31, 2023
91ea117
autotest wms.py: make GIBS TWMS tests independent
dbaston Jul 31, 2023
4a6d929
autotest wms.py: fix always-skipped test, use tmp_path for wms cache
dbaston Jul 31, 2023
5c9ea8d
autotest wcs.py: parametrize test_wcs_6, remove global variables
dbaston Aug 3, 2023
57ffa62
autotest wcs.py: use fixture for geoserver.wcs
dbaston Aug 3, 2023
dca0c60
autotest plmosaic.py: make tests independent
dbaston Aug 3, 2023
f8df5fa
autotest nitf.py: move cleanup to fixture, merge interdependent tests
dbaston Aug 3, 2023
e96b69d
autotest: disable random order for gdrivers/ngw.py
dbaston Aug 3, 2023
841acef
autotest pcidsk.py: combine interdependent tests
dbaston Aug 10, 2023
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
2 changes: 2 additions & 0 deletions autotest/gcore/hfa_rfc40.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

from osgeo import gdal

pytestmark = pytest.mark.random_order(disabled=True)

# All tests will be skipped if numpy is unavailable.
np = pytest.importorskip("numpy")

Expand Down
23 changes: 15 additions & 8 deletions autotest/gcore/histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,22 @@ def module_disable_exceptions():
yield


@pytest.fixture()
def utmsmall_tif(tmp_path):
fname = str(tmp_path / "utmsmall.tif")

shutil.copyfile("data/utmsmall.tif", fname)

return fname


###############################################################################
# Fetch simple histogram.


def test_histogram_1():
def test_histogram_1(utmsmall_tif):

ds = gdal.Open("data/utmsmall.tif")
ds = gdal.Open(utmsmall_tif)
hist = ds.GetRasterBand(1).GetHistogram()

exp_hist = [
Expand Down Expand Up @@ -323,9 +332,9 @@ def test_histogram_1():
# Fetch histogram with specified sampling, using keywords.


def test_histogram_2():
def test_histogram_2(utmsmall_tif):

ds = gdal.Open("data/utmsmall.tif")
ds = gdal.Open(utmsmall_tif)
hist = ds.GetRasterBand(1).GetHistogram(buckets=16, max=255.5, min=-0.5)

exp_hist = [
Expand Down Expand Up @@ -392,9 +401,9 @@ def test_histogram_4():
# Test GetDefaultHistogram() on the file.


def test_histogram_5():
def test_histogram_5(utmsmall_tif):

ds = gdal.Open("data/utmsmall.tif")
ds = gdal.Open(utmsmall_tif)
hist = ds.GetRasterBand(1).GetDefaultHistogram(force=1)

exp_hist = (
Expand Down Expand Up @@ -665,8 +674,6 @@ def test_histogram_5():

ds = None

gdal.Unlink("data/utmsmall.tif.aux.xml")


###############################################################################
# Test GetDefaultHistogram( force = 0 ) on a JPG file (#3304)
Expand Down
21 changes: 14 additions & 7 deletions autotest/gcore/mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,18 @@ def test_mask_3():

@pytest.mark.require_driver("JPEG")
@pytest.mark.require_driver("PNM")
def test_mask_4():
def test_mask_4(tmp_path):

src_ds = gdal.Open("../gdrivers/data/jpeg/masked.jpg")

assert src_ds is not None, "Failed to open test dataset."

output_ppm = str(tmp_path / "mask_4.ppm")

# NOTE: for now we copy to PNM since it does everything (overviews too)
# externally. Should eventually test with gtiff, hfa.
drv = gdal.GetDriverByName("PNM")
ds = drv.CreateCopy("tmp/mask_4.ppm", src_ds)
ds = drv.CreateCopy(output_ppm, src_ds)
src_ds = None

# confirm we got the custom mask on the copied dataset.
Expand All @@ -174,10 +176,17 @@ def test_mask_4():
# masks built for them.


@pytest.mark.require_driver("JPEG")
@pytest.mark.require_driver("PNM")
def test_mask_5():
def test_mask_5(tmp_path):

ds = gdal.Open("tmp/mask_4.ppm", gdal.GA_Update)
src_ds = gdal.Open("../gdrivers/data/jpeg/masked.jpg")

output_ppm = str(tmp_path / "mask_4.ppm")
drv = gdal.GetDriverByName("PNM")
ds = drv.CreateCopy(output_ppm, src_ds)

ds = gdal.Open(output_ppm, gdal.GA_Update)

assert ds is not None, "Failed to open test dataset."

Expand All @@ -202,7 +211,7 @@ def test_mask_5():
ds = None

# Reopen and confirm we still get same results.
ds = gdal.Open("tmp/mask_4.ppm")
ds = gdal.Open(output_ppm)

# confirm mask flags on overview.
ovr = ds.GetRasterBand(1).GetOverview(1)
Expand All @@ -220,8 +229,6 @@ def test_mask_5():
msk = None
ds = None

gdal.GetDriverByName("PNM").Delete("tmp/mask_4.ppm")


###############################################################################
# Test a TIFF file with 1 band and an embedded mask of 1 bit
Expand Down
16 changes: 2 additions & 14 deletions autotest/gcore/numpy_rw_multidim.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
# verify that we can load Numeric python, and find the Numpy driver.


def test_numpy_rw_multidim_init():
@pytest.fixture(scope="module", autouse=True)
def setup_and_cleanup():

gdaltest.numpy_drv = None
# importing gdal_array will allow numpy driver registration
pytest.importorskip("osgeo.gdal_array")

Expand All @@ -57,8 +57,6 @@ def test_numpy_rw_multidim_init():

def test_numpy_rw_multidim_readasarray_writearray():

if gdaltest.numpy_drv is None:
pytest.skip()
import numpy as np

drv = gdal.GetDriverByName("MEM")
Expand Down Expand Up @@ -100,8 +98,6 @@ def test_numpy_rw_multidim_readasarray_writearray():

def test_numpy_rw_multidim_numpy_array_as_dataset():

if gdaltest.numpy_drv is None:
pytest.skip()
import numpy as np

from osgeo import gdal_array
Expand Down Expand Up @@ -133,8 +129,6 @@ def test_numpy_rw_multidim_numpy_array_as_dataset():

def test_numpy_rw_multidim_readasarray_writearray_negative_strides():

if gdaltest.numpy_drv is None:
pytest.skip()
import numpy as np

drv = gdal.GetDriverByName("MEM")
Expand Down Expand Up @@ -177,8 +171,6 @@ def test_numpy_rw_multidim_readasarray_writearray_negative_strides():

def test_numpy_rw_multidim_numpy_array_as_dataset_negative_strides():

if gdaltest.numpy_drv is None:
pytest.skip()
import numpy as np

from osgeo import gdal_array
Expand Down Expand Up @@ -211,8 +203,6 @@ def test_numpy_rw_multidim_numpy_array_as_dataset_negative_strides():

def test_numpy_rw_multidim_compound_datatype():

if gdaltest.numpy_drv is None:
pytest.skip()
import numpy as np

from osgeo import gdal_array
Expand Down Expand Up @@ -275,8 +265,6 @@ def test_numpy_rw_multidim_compound_datatype():
)
def test_numpy_rw_multidim_datatype(datatype):

if gdaltest.numpy_drv is None:
pytest.skip()
import numpy as np

drv = gdal.GetDriverByName("MEM")
Expand Down
Loading
Loading