def test_structured_table_reference_boundaries(ref, expected): Column = namedtuple('Column', 'name') class Table: def __init__(self, ref, header_rows, totals_rows): self.ref = ref self.headerRowCount = header_rows self.totalsRowCount = totals_rows self.tableColumns = tuple( Column(name) for name in 'col1 col2 col3 col4 col5'.split()) class Excel: def __init__(self, table): self.a_table = table def table(self, name): if name == 'a_table': return self.a_table, None else: return None, None class Cell: def __init__(self, table, address): self.excel = Excel(table) self.address = AddressCell(address) cell = Cell(Table('A1:E8', 1, 1), 'E5') if isinstance(expected, PyCelException): with pytest.raises(PyCelException): structured_reference_boundaries(ref, cell=cell) elif expected is None: with pytest.raises(PyCelException): structured_reference_boundaries(ref, cell=None) else: ref_bound = structured_reference_boundaries(ref, cell=cell) expected_bound = range_boundaries(expected, cell=cell) assert ref_bound == expected_bound expected_ref = range_boundaries(ref, cell=cell) assert ref_bound == expected_ref