Skip to content

Commit

Permalink
🔬 more test cases, related to #25
Browse files Browse the repository at this point in the history
  • Loading branch information
chfw committed Dec 8, 2017
1 parent 7dad0f3 commit 3ec21dd
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
Binary file added tests/fixtures/complex-merged-cells-sheet.xls
Binary file not shown.
31 changes: 31 additions & 0 deletions tests/test_merged_cells.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
from pyexcel_xls import get_data
from pyexcel_xls.xlsr import MergedCell
from nose.tools import eq_


Expand All @@ -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'])

0 comments on commit 3ec21dd

Please sign in to comment.