-
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
test_tutorial.py
33 lines (25 loc) · 1.06 KB
/
test_tutorial.py
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
from __future__ import absolute_import, division, print_function
import os
import pytest
from xarray import DataArray, tutorial
from xarray.core.pycompat import suppress
from . import assert_identical, network
@network
class TestLoadDataset(object):
@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('{}.nc'.format(self.testfilepath))
with suppress(OSError):
os.remove('{}.md5'.format(self.testfilepath))
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)
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)