File: test_tutorial.py

package info (click to toggle)
python-xarray 0.16.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 6,568 kB
  • sloc: python: 60,570; makefile: 236; sh: 38
file content (34 lines) | stat: -rw-r--r-- 1,040 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import os
from contextlib import suppress

import pytest

from xarray import DataArray, tutorial

from . import assert_identical, network


@network
class TestLoadDataset:
    @pytest.fixture(autouse=True)
    def setUp(self):
        self.testfile = "tiny"
        self.testfilepath = os.path.expanduser(
            os.sep.join(("~", ".xarray_tutorial_data", self.testfile))
        )
        with suppress(OSError):
            os.remove(f"{self.testfilepath}.nc")
        with suppress(OSError):
            os.remove(f"{self.testfilepath}.md5")

    @pytest.mark.xfail
    def test_download_from_github(self):
        ds = tutorial.open_dataset(self.testfile).load()
        tiny = DataArray(range(5), name="tiny").to_dataset()
        assert_identical(ds, tiny)

    @pytest.mark.xfail
    def test_download_from_github_load_without_cache(self):
        ds_nocache = tutorial.open_dataset(self.testfile, cache=False).load()
        ds_cache = tutorial.open_dataset(self.testfile).load()
        assert_identical(ds_cache, ds_nocache)