diff --git a/src/georinex/tests/test_header.py b/src/georinex/tests/test_header.py index 5b44368..466d045 100644 --- a/src/georinex/tests/test_header.py +++ b/src/georinex/tests/test_header.py @@ -3,10 +3,6 @@ import georinex as gr -try: - import netCDF4 -except ImportError: - netCDF4 = None R = Path(__file__).parent / "data" @@ -24,8 +20,8 @@ ids=["obs2", "obs3", "nav2", "nav3", "Cobs1", "NetCDF_obs2"], ) def test_header(fn, rtype, vers): - if fn.suffix == ".nc" and netCDF4 is None: - pytest.skip("no netCDF4") + if fn.suffix == ".nc": + pytest.importorskip("netCDF4") hdr = gr.rinexheader(fn) assert isinstance(hdr, dict) diff --git a/src/georinex/versions.py b/src/georinex/versions.py index 2e59f0d..31971bb 100644 --- a/src/georinex/versions.py +++ b/src/georinex/versions.py @@ -2,7 +2,10 @@ import numpy import sys import pandas -import netCDF4 +try: + import netCDF4 +except ImportError: + pass from . import __version__ @@ -11,7 +14,10 @@ print("xarray", xarray.__version__) print("Numpy", numpy.__version__) print("Pandas", pandas.__version__) -print("NetCDF4", netCDF4.__version__) +try: + print("NetCDF4", netCDF4.__version__) +except NameError: + print("netCDF4 not available") try: import pytest