(tmp_path: Path)
| 7442 | |
| 7443 | @requires_netCDF4 |
| 7444 | def 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 |
nothing calls this directly
no test coverage detected
searching dependent graphs…