Skip to content

Commit 1690636

Browse files
authored
Fix test that loads realistic GRIB file (#2665)
1 parent dd1e29c commit 1690636

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

doc/develop/preprocessor_function.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,13 @@ and add the following content:
244244
"""Test function `esmvalcore.preprocessor.example_preprocessor_function`."""
245245
from pathlib import Path
246246
247-
import esmvaltool_sample_data
248247
import iris
249248
import pytest
250249
251250
from esmvalcore.preprocessor import example_preprocessor_function
252251
252+
esmvaltool_sample_data = pytest.importorskip("esmvaltool_sample_data")
253+
253254
254255
@pytest.mark.use_sample_data
255256
def test_example_preprocessor_function():

tests/integration/preprocessor/_io/test_load.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
import tempfile
55
import unittest
66
import warnings
7+
from importlib.resources import files as importlib_files
78
from pathlib import Path
89

910
import iris
1011
import numpy as np
1112
from iris.coords import DimCoord
1213
from iris.cube import Cube, CubeList
1314

14-
import esmvalcore
1515
from esmvalcore.preprocessor._io import load
1616

1717

@@ -56,12 +56,11 @@ def test_load(self):
5656

5757
def test_load_grib(self):
5858
"""Test loading a grib file."""
59-
grib_path = Path(
60-
Path(esmvalcore.__file__).parents[1],
61-
"tests",
62-
"sample_data",
63-
"iris-sample-data",
64-
"polar_stereo.grib2",
59+
grib_path = (
60+
Path(importlib_files("tests"))
61+
/ "sample_data"
62+
/ "iris-sample-data"
63+
/ "polar_stereo.grib2"
6564
)
6665
cubes = load(grib_path)
6766

0 commit comments

Comments
 (0)