|
7 | 7 | import pandas as pd |
8 | 8 | import pytest |
9 | 9 |
|
10 | | -from larray.tests.common import assert_array_nan_equal, inputpath, tmp_path, meta, needs_xlwings |
| 10 | +from larray.tests.common import (assert_array_nan_equal, inputpath, tmp_path, meta, |
| 11 | + needs_xlwings, needs_pytables, needs_xlrd) |
11 | 12 | from larray import (Session, Axis, Array, Group, isnan, zeros_like, ndtest, ones_like, ones, full, |
12 | 13 | local_arrays, global_arrays, arrays) |
13 | 14 | from larray.util.misc import pickle, PY2 |
@@ -54,22 +55,27 @@ def test_init_session(meta): |
54 | 55 | s = Session(b, b024, a, a01, a2=a2, anonymous=anonymous, ano01=ano01, c=c, d=d, e=e, f=f, g=g, h=h) |
55 | 56 | assert s.names == ['a', 'a01', 'a2', 'ano01', 'anonymous', 'b', 'b024', 'c', 'd', 'e', 'f', 'g', 'h'] |
56 | 57 |
|
57 | | - s = Session(inputpath('test_session.h5')) |
58 | | - assert s.names == ['e', 'f', 'g'] |
59 | | - |
60 | | - # this needs xlwings installed |
61 | | - # s = Session('test_session_ef.xlsx') |
62 | | - # assertEqual(s.names, ['e', 'f']) |
63 | | - |
64 | 58 | # TODO: format autodetection does not work in this case |
65 | 59 | # s = Session('test_session_csv') |
66 | | - # assertEqual(s.names, ['e', 'f', 'g']) |
| 60 | + # assert s.names == ['e', 'f', 'g'] |
67 | 61 |
|
68 | 62 | # metadata |
69 | 63 | s = Session(b, b024, a, a01, a2=a2, anonymous=anonymous, ano01=ano01, c=c, d=d, e=e, f=f, g=g, h=h, meta=meta) |
70 | 64 | assert s.meta == meta |
71 | 65 |
|
72 | 66 |
|
| 67 | +@needs_xlwings |
| 68 | +def test_init_session_xlsx(): |
| 69 | + s = Session(inputpath('demography_eurostat.xlsx')) |
| 70 | + assert s.names == ['births', 'deaths', 'immigration', 'pop', 'pop_benelux'] |
| 71 | + |
| 72 | + |
| 73 | +@needs_pytables |
| 74 | +def test_init_session_hdf(): |
| 75 | + s = Session(inputpath('test_session.h5')) |
| 76 | + assert s.names == ['e', 'f', 'g'] |
| 77 | + |
| 78 | + |
73 | 79 | def test_getitem(session): |
74 | 80 | assert session['a'] is a |
75 | 81 | assert session['a2'] is a2 |
@@ -219,11 +225,13 @@ def _test_io(fpath, session, meta, engine): |
219 | 225 | assert s.meta == meta |
220 | 226 |
|
221 | 227 |
|
| 228 | +@needs_pytables |
222 | 229 | def test_h5_io(tmpdir, session, meta): |
223 | 230 | fpath = tmp_path(tmpdir, 'test_session.h5') |
224 | 231 | _test_io(fpath, session, meta, engine='pandas_hdf') |
225 | 232 |
|
226 | 233 |
|
| 234 | +@needs_xlrd |
227 | 235 | def test_xlsx_pandas_io(tmpdir, session, meta): |
228 | 236 | fpath = tmp_path(tmpdir, 'test_session.xlsx') |
229 | 237 | _test_io(fpath, session, meta, engine='pandas_excel') |
|
0 commit comments