File tree Expand file tree Collapse file tree 1 file changed +5
-12
lines changed
Expand file tree Collapse file tree 1 file changed +5
-12
lines changed Original file line number Diff line number Diff line change 11import datetime
22import faulthandler
3+ from importlib .util import find_spec
34import unittest
45
56faulthandler .enable () # to debug seg faults and timeouts
1011# ESMF renamed its Python module to `esmpy` at ESMF version 8.4.0. Allow
1112# either for now for backwards compatibility.
1213esmpy_imported = False
13- try :
14- import esmpy
15-
14+ # Note: here only need esmpy for cf under-the-hood code, not in test
15+ # directly, so no need to actually import esmpy, just test it is there.
16+ if find_spec ( "esmpy" ) or find_spec ( "ESMF" ):
1617 esmpy_imported = True
17- except ImportError :
18- try :
19- # Take the new name to use in preference to the old one.
20- import ESMF as esmpy
21-
22- esmpy_imported = True
23- except ImportError :
24- pass
2518
2619
2720class RegridOperatorTest (unittest .TestCase ):
2821
2922 def setUp (self ):
3023 src = cf .example_field (0 )
3124 dst = cf .example_field (1 )
32- r = src .regrids (dst , "linear" , return_operator = True )
25+ self . r = src .regrids (dst , "linear" , return_operator = True )
3326
3427 @unittest .skipUnless (esmpy_imported , "Requires esmpy/ESMF package." )
3528 def test_RegridOperator_attributes (self ):
You can’t perform that action at this time.
0 commit comments