def test_format_void_tag(): html = """<body><img src="self-closing.png"/><img src="void.png"></body>""" if (format( html ) != """<body>\n <img src="self-closing.png">\n <img src="void.png">\n</body>""" ): raise AssertionError
def test_format_invalid_void_tag_fail(): html = """<body><xxx src="void.png"></body>""" with pytest.raises(ExpatError): format(html, fail=True)
def test_format_void_tag(): html = """<body><img src="self-closing.png"/><img src="void.png"></body>""" assert ( format(html) == """<body>\n <img src="self-closing.png">\n <img src="void.png">\n</body>""" )
def test_format_fail(): html = """<div><ul><li>Item</li><li>Item</li></ul>""" with pytest.raises(ExpatError): format(html, fail=True)
def test_format(): html = """<ul><li>Item</li><li>Item</li></ul>""" assert format(html) == "<ul>\n <li>Item</li>\n <li>Item</li>\n</ul>"
def test_format_fail_closing_order(): with pytest.raises(ExpatError): html = """<div><ul><li>Item</li><li>Item</li></div></ul>""" format(html, fail=True)
def test_format_whitespace_inside_tag(): html = """<ul><li>Item</li><li>I t e m</li></ul>""" assert format(html) == "<ul>\n <li>Item</li>\n <li>I t e m</li>\n</ul>"
def test_format_trailing_text(): with pytest.raises(ExpatError): html = """<ul><li>Item</li><li>Item</li></ul>Trailing Text""" format(html, fail=True)
def test_format_leading_text(): with pytest.raises(ExpatError): html = """Leading Text<ul><li>Item</li><li>Item</li></ul>""" format(html, fail=True)
def test_format_whitespace_inside_tag(): html = """<ul><li>Item</li><li>I t e m</li></ul>""" if format(html) != "<ul>\n <li>Item</li>\n <li>I t e m</li>\n</ul>": raise AssertionError
def test_format(): html = """<ul><li>Item</li><li>Item</li></ul>""" if format(html) != "<ul>\n <li>Item</li>\n <li>Item</li>\n</ul>": raise AssertionError