summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchfw <wangc_2011@hotmail.com>2016-07-12 16:46:49 (GMT)
committerchfw <wangc_2011@hotmail.com>2016-07-12 16:46:49 (GMT)
commit3261ce5dd56c263cfe0488bffe3c6a45998c49c5 (patch)
treec9d45c222f1633686c0efbe4ab38480754733efb
parent36083163941f74d0b415327455a1fa948d52ef8c (diff)
downloadpython-pyexcel-xls-3261ce5dd56c263cfe0488bffe3c6a45998c49c5.zip
python-pyexcel-xls-3261ce5dd56c263cfe0488bffe3c6a45998c49c5.tar.gz
python-pyexcel-xls-3261ce5dd56c263cfe0488bffe3c6a45998c49c5.tar.bz2
resolve #9: test skip_hidden_sheets
-rw-r--r--CHANGELOG.rst2
-rw-r--r--tests/base.py4
-rw-r--r--tests/fixtures/hidden_sheets.xlsbin0 -> 18432 bytes
-rw-r--r--tests/test_bug_fixes.py15
-rw-r--r--tests/test_formatters.py4
5 files changed, 20 insertions, 5 deletions
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 4d66803..3773581 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -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
diff --git a/tests/base.py b/tests/base.py
index 5945b15..b12e825 100644
--- a/tests/base.py
+++ b/tests/base.py
@@ -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
diff --git a/tests/fixtures/hidden_sheets.xls b/tests/fixtures/hidden_sheets.xls
new file mode 100644
index 0000000..2cc2942
--- /dev/null
+++ b/tests/fixtures/hidden_sheets.xls
Binary files differ
diff --git a/tests/test_bug_fixes.py b/tests/test_bug_fixes.py
index 5f87fad..cca61f2 100644
--- a/tests/test_bug_fixes.py
+++ b/tests/test_bug_fixes.py
@@ -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']])
diff --git a/tests/test_formatters.py b/tests/test_formatters.py
index ed8dbc2..59ba062 100644
--- a/tests/test_formatters.py
+++ b/tests/test_formatters.py
@@ -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