Skip to content

Commit 5793ab7

Browse files
committed
makes netCDF4 optional for examples/run_all.py
If you do not have netCDF4 installed, some tests will give ImportErrors. This patch makes netCDF4 optional for run_all.py. It imports netCDF4, if that package is not available, it removes tests that require netCDF4. There may be some of the tests in the lines above the try-statement that could be put below the except-statement. I did not look at that aspect.
1 parent 2d2d73e commit 5793ab7

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

examples/run_all.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@
1212
test_files.remove('plothighsandlows.py') # requires scipy
1313
test_files.remove('lic_demo.py')
1414
test_files.remove('testwmsimage.py')
15+
try:
16+
from netCDF4 import Dataset
17+
except ImportError:
18+
# remove tests requiring netCDF4
19+
test_files.remove('streamplot_demo.py')
20+
test_files.remove('plotprecip.py')
21+
test_files.remove('test_rotpole.py')
22+
test_files.remove('ccsm_popgrid.py')
23+
test_files.remove('ploticos.py')
24+
1525
py_path = os.environ.get('PYTHONPATH')
1626
if py_path is None:
1727
py_path = '.'

0 commit comments

Comments
 (0)