MCPcopy
hub / github.com/pydata/xarray / test_netcdf4_entrypoint

Function test_netcdf4_entrypoint

xarray/tests/test_backends.py:7444–7473  ·  view source on GitHub ↗
(tmp_path: Path)

Source from the content-addressed store, hash-verified

7442
7443@requires_netCDF4
7444def test_netcdf4_entrypoint(tmp_path: Path) -> None:
7445 entrypoint = NetCDF4BackendEntrypoint()
7446 ds = create_test_data()
7447
7448 path = tmp_path / "foo"
7449 ds.to_netcdf(path, format="NETCDF3_CLASSIC")
7450 _check_guess_can_open_and_open(entrypoint, path, engine="netcdf4", expected=ds)
7451 _check_guess_can_open_and_open(entrypoint, str(path), engine="netcdf4", expected=ds)
7452
7453 path = tmp_path / "bar"
7454 ds.to_netcdf(path, format="NETCDF4_CLASSIC")
7455 _check_guess_can_open_and_open(entrypoint, path, engine="netcdf4", expected=ds)
7456 _check_guess_can_open_and_open(entrypoint, str(path), engine="netcdf4", expected=ds)
7457
7458 # Remote URLs without extensions return True (backward compatibility)
7459 assert entrypoint.guess_can_open("http://something/remote")
7460 # Remote URLs with netCDF extensions are also claimed
7461 assert entrypoint.guess_can_open("http://something/remote.nc")
7462 assert entrypoint.guess_can_open("something-local.nc")
7463 assert entrypoint.guess_can_open("something-local.nc4")
7464 assert entrypoint.guess_can_open("something-local.cdf")
7465 assert not entrypoint.guess_can_open("not-found-and-no-extension")
7466
7467 contents = ds.to_netcdf(engine="netcdf4")
7468 _check_guess_can_open_and_open(entrypoint, contents, engine="netcdf4", expected=ds)
7469
7470 path = tmp_path / "baz"
7471 with open(path, "wb") as f:
7472 f.write(b"not-a-netcdf-file")
7473 assert not entrypoint.guess_can_open(path)
7474
7475
7476@requires_scipy

Callers

nothing calls this directly

Calls 5

guess_can_openMethod · 0.95
create_test_dataFunction · 0.85
to_netcdfMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…