示例#1
0
def test_parse_cals_row__nature_from_parent(tag, nature):
    # --without namespaces
    cals_parent = etree.Element(tag)
    cals_row = etree.SubElement(cals_parent, "row")
    parser = CalsParser(BaseBuilder())
    parser.setup_table()
    parser._state.next_row()
    state = parser.parse_cals_row(cals_row)
    row = state.table.rows[1]
    assert row.nature == nature
示例#2
0
def test_parse_cals_row__overrides_parent_valign():
    # --without namespaces
    cals_tbody = etree.Element("tbody", valign="top")
    cals_row = etree.SubElement(cals_tbody, "row", valign="middle")
    parser = CalsParser(BaseBuilder())
    parser.setup_table()
    parser._state.next_row()
    state = parser.parse_cals_row(cals_row)
    row = state.table.rows[1]
    assert row.styles["vertical-align"] == "middle"
示例#3
0
def test_parse_cals_row(attrib, styles, nature):
    # --without namespaces
    cals_row = etree.Element("row", attrib=attrib)
    parser = CalsParser(BaseBuilder())
    parser.setup_table()
    parser._state.next_row()
    state = parser.parse_cals_row(cals_row)
    row = state.table.rows[1]
    assert row.styles == styles
    assert row.nature == nature

    # --with default namespaces
    cals_row_attrib = {cals(k): v for k, v in attrib.items()}
    cals_row = etree.Element(cals("row"),
                             attrib=cals_row_attrib,
                             nsmap={None: CALS_NS})
    parser = CalsParser(BaseBuilder(), cals_ns=CALS_NS)
    parser.setup_table()
    parser._state.next_row()
    state = parser.parse_cals_row(cals_row)
    row = state.table.rows[1]
    assert row.styles == styles
    assert row.nature == nature