Skip to content

Commit 24ff582

Browse files
authored
Conditionally run rasterio unit tests.
1 parent 81766cf commit 24ff582

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

xee/ext_integration_test.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,17 @@
2323
import numpy as np
2424
import xarray as xr
2525
from xarray.core import indexing
26-
import rioxarray
27-
import rasterio
2826
import xee
2927

3028
import ee
3129

30+
_SKIP_RASTERIO_TESTS = False
31+
try:
32+
import rasterio # pylint: disable=g-import-not-at-top
33+
import rioxarray # pylint: disable=g-import-not-at-top,unused-import
34+
except ImportError:
35+
_SKIP_RASTERIO_TESTS = True
36+
3237
_CREDENTIALS_PATH_KEY = 'GOOGLE_APPLICATION_CREDENTIALS'
3338
_SCOPES = [
3439
'https://www.googleapis.com/auth/cloud-platform',
@@ -400,6 +405,7 @@ def test_validate_band_attrs(self):
400405
for _, value in variable.attrs.items():
401406
self.assertIsInstance(value, valid_types)
402407

408+
@absltest.skipIf(_SKIP_RASTERIO_TESTS, 'rioxarray module not loaded')
403409
def test_write_projected_dataset_to_raster(self):
404410
# ensure that a projected dataset written to a raster intersects with the
405411
# point used to create the initial image collection
@@ -436,6 +442,7 @@ def test_write_projected_dataset_to_raster(self):
436442
intersects = bbox.intersects(point, 1, proj=proj)
437443
self.assertTrue(intersects.getInfo())
438444

445+
@absltest.skipIf(_SKIP_RASTERIO_TESTS, 'rioxarray module not loaded')
439446
def test_write_dataset_to_raster(self):
440447
# ensure that a dataset written to a raster intersects with the point used
441448
# to create the initial image collection

0 commit comments

Comments
 (0)