38 lines
1.2 KiB
Python

"""Contains common helpers for tests."""
# Standard library
from datetime import timedelta
import os.path
# Hypothesis testing
from hypothesis import settings
# Geo libraries
import rasterio
# DataSetAccess getting the path to the example data set
from pyrate.common.raster_datasets import DataSetAccess
# Pyrate
from pyrate.common.testing import IS_EXTENDED_TESTING
# do more tests on the CI server as that one has more patience
# see: https://hypothesis.readthedocs.io/en/latest/settings.html#settings-profiles
settings.register_profile("normal", deadline=timedelta(seconds=5), print_blob=True, max_examples=500)
settings.register_profile("extended", parent=settings.get_profile("normal"), max_examples=10_000)
if IS_EXTENDED_TESTING:
settings.load_profile("extended")
else:
settings.load_profile("normal")
def _open_test_geo_dataset() -> DataSetAccess:
"""Tries to return a Earth2014 20 arc-minute grid resolution dataset."""
path = os.path.join(
os.path.dirname(__file__), "common/raster_datasets/Earth2014.TBI2014.30min.geod.geo.tif"
)
assert os.path.exists(path), "The downscaled Earth2014 testing dataset is missing"
return DataSetAccess(rasterio.open(path))