Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 8 additions & 18 deletions xarray/tests/test_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,27 @@
class TestLoadDataset:
def test_download_from_github(self, tmp_path) -> None:
cache_dir = tmp_path / tutorial._default_cache_dir_name
ds = tutorial.open_dataset("tiny", cache_dir=cache_dir).load()
ds = tutorial.load_dataset("tiny", cache_dir=cache_dir)
tiny = DataArray(range(5), name="tiny").to_dataset()
assert_identical(ds, tiny)

def test_download_from_github_load_without_cache(
self, tmp_path, monkeypatch
) -> None:
def test_download_from_github_load_without_cache(self, tmp_path) -> None:
cache_dir = tmp_path / tutorial._default_cache_dir_name

ds_nocache = tutorial.open_dataset(
"tiny", cache=False, cache_dir=cache_dir
).load()
ds_cache = tutorial.open_dataset("tiny", cache_dir=cache_dir).load()
ds_nocache = tutorial.load_dataset("tiny", cache=False, cache_dir=cache_dir)
ds_cache = tutorial.load_dataset("tiny", cache_dir=cache_dir)
assert_identical(ds_cache, ds_nocache)


@network
class TestLoadDataTree:
def test_download_from_github(self, tmp_path) -> None:
cache_dir = tmp_path / tutorial._default_cache_dir_name
ds = tutorial.open_datatree("tiny", cache_dir=cache_dir).load()
ds = tutorial.load_datatree("tiny", cache_dir=cache_dir)
tiny = DataTree.from_dict({"/": DataArray(range(5), name="tiny").to_dataset()})
assert_identical(ds, tiny)

def test_download_from_github_load_without_cache(
self, tmp_path, monkeypatch
) -> None:
def test_download_from_github_load_without_cache(self, tmp_path) -> None:
cache_dir = tmp_path / tutorial._default_cache_dir_name

ds_nocache = tutorial.open_datatree(
"tiny", cache=False, cache_dir=cache_dir
).load()
ds_cache = tutorial.open_datatree("tiny", cache_dir=cache_dir).load()
ds_nocache = tutorial.load_datatree("tiny", cache=False, cache_dir=cache_dir)
ds_cache = tutorial.load_datatree("tiny", cache_dir=cache_dir)
assert_identical(ds_cache, ds_nocache)
Loading