Skip to content

Commit 792c876

Browse files
committed
prevent new xarray tests from execution in a non-xarray environment
1 parent 6a07066 commit 792c876

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

python/test/test_cdo.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -462,12 +462,16 @@ def test_xarray_input(self):
462462

463463
def test_xarray_input_and_output(self):
464464
cdo = Cdo()
465-
ifile = cdo.setcalendar('360_day', input=' -settaxis,1800-01-01,12:00:00,1months -seq,1,10000',options='-f nc -r')
466-
(var,) = cdo.showname(input=ifile)
467-
self.assertEqual('seq',var)
468-
x = cdo.selyear('1985/2100', input=ifile, returnXArray=var)
469-
y = cdo.yearsum(input=x, returnXArray=var)
470-
self.assertEqual(4059768.0,float(y[:,0,0].sum()))
465+
466+
if cdo.hasXarray:
467+
ifile = cdo.setcalendar('360_day', input=' -settaxis,1800-01-01,12:00:00,1months -seq,1,10000',options='-f nc -r')
468+
(var,) = cdo.showname(input=ifile)
469+
self.assertEqual('seq',var)
470+
x = cdo.selyear('1985/2100', input=ifile, returnXArray=var)
471+
y = cdo.yearsum(input=x, returnXArray=var)
472+
self.assertEqual(4059768.0,float(y[:,0,0].sum()))
473+
else:
474+
print("test_xarray_input_and_output needs xarray")
471475

472476
def test_xarray_output(self):
473477
cdo = Cdo()

0 commit comments

Comments
 (0)