resolve #9: test skip_hidden_sheets

This commit is contained in:
chfw 2016-07-12 17:46:49 +01:00
parent 3608316394
commit 3261ce5dd5
5 changed files with 20 additions and 5 deletions

View File

@ -7,7 +7,7 @@ Change log
Added
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#. `skip_hidden_sheets` is added. By default, hidden sheets are skipped when reading all sheets. Reading sheet by name or by index are not affected.
#. `#9 <https://github.com/pyexcel/pyexcel-xls/issues/9>`_, `skip_hidden_sheets` is added. By default, hidden sheets are skipped when reading all sheets. Reading sheet by name or by index are not affected.
0.2.0 - 01.06.2016

View File

@ -23,7 +23,7 @@ class PyexcelHatWriterBase:
def test_series_table(self):
pyexcel.save_as(adict=self.content, dest_file_name=self.testfile)
r = pyexcel.SeriesReader(self.testfile)
r = pyexcel.get_sheet(file_name=self.testfile, name_columns_by_row=0)
actual = pyexcel.utils.to_dict(r)
assert actual == self.content
@ -47,7 +47,7 @@ class PyexcelWriterBase:
def test_write_array(self):
self._create_a_file(self.testfile)
r = pyexcel.Reader(self.testfile)
r = pyexcel.get_sheet(file_name=self.testfile)
actual = pyexcel.utils.to_array(r.rows())
assert actual == self.content

BIN
tests/fixtures/hidden_sheets.xls vendored Normal file

Binary file not shown.

View File

@ -8,6 +8,7 @@ import os
import pyexcel as pe
from pyexcel_xls import save_data
from _compact import OrderedDict
from nose.tools import eq_
import datetime
@ -30,3 +31,17 @@ class TestBugFix:
data.update({"test": array})
save_data("test.xls", data)
os.unlink("test.xls")
def test_issue_9_hidden_sheet(self):
test_file = os.path.join("tests", "fixtures", "hidden_sheets.xls")
book_dict = pe.get_book_dict(file_name=test_file)
assert "hidden" not in book_dict
eq_(book_dict['shown'], [['A', 'B']])
def test_issue_9_hidden_sheet_2(self):
test_file = os.path.join("tests", "fixtures", "hidden_sheets.xls")
book_dict = pe.get_book_dict(file_name=test_file,
skip_hidden_sheets=False)
assert "hidden" in book_dict
eq_(book_dict['shown'], [['A', 'B']])
eq_(book_dict['hidden'], [['a', 'b']])

View File

@ -15,7 +15,7 @@ class TestDateFormat:
01/01/15 13:13:13
0.0 0.0
"""
r = pe.Reader(os.path.join("tests", "fixtures", "date_field.xls"))
r = pe.get_sheet(file_name=os.path.join("tests", "fixtures", "date_field.xls"))
assert isinstance(r[1, 0], datetime.date) is True
assert r[1, 0].strftime("%d/%m/%y") == "25/12/14"
assert isinstance(r[1, 1], datetime.time) is True
@ -29,7 +29,7 @@ class TestDateFormat:
datetime.time(11, 11, 11),
datetime.datetime(2014, 12, 25, 11, 11, 11)]]
pe.save_as(dest_file_name=excel_filename, array=data)
r = pe.Reader(excel_filename)
r = pe.get_sheet(file_name=excel_filename)
assert isinstance(r[0, 0], datetime.date) is True
assert r[0, 0].strftime("%d/%m/%y") == "25/12/14"
assert isinstance(r[0, 1], datetime.time) is True