def test_fragment_get_slice(): hl = Tag("html") hd = Tag("head") m = SelfClosingTag("meta", SelfClosingTagStyle.HTML) b = Tag("body") p = Tag("p") f = +hl + hd + m - hd + b + p + "The Paragraph" assert str(f[3:5]) == "<p>The Paragraph"
def my_tag_with_id_and_classes(my_tag): return Tag("my-tag", id_="title", class_=["heading", "uppercase"])
def my_tag_with_attributes(my_tag): return Tag("my-tag", attr1="val1", attr2="val2")
def my_tag(): return Tag("my-tag")
def test_fragment_minus_tag(): f = Fragment() html = Tag("html") assert str(f - html) == "</html>"
def test_self_closing_tag_inside_balanced_tags(): head = Tag("head") meta = SelfClosingTag("meta", SelfClosingTagStyle.HTML) f = Fragment() assert str(f + head + meta - head) == "<head><meta></head>"
def test_fragment_plus_untyped_tag(): t = Tag("html") f = Fragment() assert str(f + t) == "<html>"
def h1(): return Tag("h1")