Beispiel #1
0
def test_format_xml(filename):
    path = data.path(filename)
    with open(path) as f:
        input = f.read()
    with open(path.replace(".", "-formatted.")) as f:
        expected = f.read()
    tokens = xml_html.tokenize(input)
    assert xml_html.format_xml(tokens) == expected
Beispiel #2
0
def test_format_xml(filename, tdata):
    path = tdata.path(datadir + filename)
    with open(path) as f:
        input = f.read()
    with open("-formatted.".join(path.rsplit(".", 1))) as f:
        expected = f.read()
    tokens = xml_html.tokenize(input)
    assert xml_html.format_xml(tokens) == expected
Beispiel #3
0
def test_format_xml(filename, tdata):
    path = tdata.path(datadir + filename)
    with open(path) as f:
        input = f.read()
    with open("-formatted.".join(path.rsplit(".", 1))) as f:
        expected = f.read()
    tokens = xml_html.tokenize(input)
    assert xml_html.format_xml(tokens) == expected
Beispiel #4
0
def format_xml_if_available(xml: str) -> str:
    """
    Formats the xml if the XML formatter is installed,
    returns it unmodified otherwise
    """
    if not xml_html:
        return xml
    tokens = xml_html.tokenize(xml)
    return xml_html.format_xml(tokens)