🔬 more test cases, related to #25

This commit is contained in:
chfw 2017-12-08 23:17:21 +00:00
parent 7dad0f3261
commit 3ec21dd737
2 changed files with 31 additions and 0 deletions

BIN
tests/fixtures/complex-merged-cells-sheet.xls vendored Executable file

Binary file not shown.

View File

@ -1,5 +1,6 @@
import os
from pyexcel_xls import get_data
from pyexcel_xls.xlsr import MergedCell
from nose.tools import eq_
@ -9,3 +10,33 @@ def test_merged_cells():
library="pyexcel-xls")
expected = [[1, 2, 3], [1, 5, 6], [1, 8, 9], [10, 11, 11]]
eq_(data['Sheet1'], expected)
def test_complex_merged_cells():
data = get_data(
os.path.join("tests", "fixtures", "complex-merged-cells-sheet.xls"),
detect_merged_cells=True,
library="pyexcel-xls")
expected = [
[1, 1, 2, 3, 15, 16, 22, 22, 24, 24],
[1, 1, 4, 5, 15, 17, 22, 22, 24, 24],
[6, 7, 8, 9, 15, 18, 22, 22, 24, 24],
[10, 11, 11, 12, 19, 19, 23, 23, 24, 24],
[13, 11, 11, 14, 20, 20, 23, 23, 24, 24],
[21, 21, 21, 21, 21, 21, 23, 23, 24, 24],
[25, 25, 25, 25, 25, 25, 25, 25, 25, 25],
[25, 25, 25, 25, 25, 25, 25, 25, 25, 25]
]
eq_(data['Sheet1'], expected)
def test_merged_cell_class():
test_dict = {}
merged_cell = MergedCell(1, 4, 1, 4)
merged_cell.register_cells(test_dict)
keys = list(test_dict.keys())
expected = ['2-2', '2-3', '2-1', '1-1',
'1-3', '1-2', '3-3', '3-2',
'3-1']
eq_(keys, expected)
eq_(merged_cell, test_dict['3-1'])