def test_loadtxt_static(): @renders( loadtxt("tests/assets/html_components/component.html", static=True)) def render_component(): return {"foo": "bar"} assert render_component() == txt("<p>{foo}</p>")
def test_render(): assert render(" ") == "&nbsp;" assert render(txt(" ")) == "&nbsp;" assert render(b" ") == " " assert render(raw(" ")) == " " assert render(e.p(), e.p()) == "<p></p><p></p>" with pytest.raises(ValueError): render(1)
def test_composite_tag(): assert render(composite_tag("p")()()) == "<p></p>" assert render(p()(txt("x"))) == "<p>x</p>" assert render(p(class_="y")(txt("x"))) == '<p class="y">x</p>' assert render(p("a")(txt("x"))) == "<p a>x</p>" assert render(p("a", b="c")(txt("x"))) == '<p a b="c">x</p>' assert render(p(b="c")(txt("x"))) == '<p b="c">x</p>' assert render(p(b="c")(p()(txt("x")))) == '<p b="c"><p>x</p></p>'
def test_switch(): assert ly(YAML_COMPONENTS, ("switch", "case", True)) == txt("true") assert ly(YAML_COMPONENTS, ("switch", "case", False)) == txt("false")
def test_somevalue(): assert ly(YAML_COMPONENTS, "somevalue.foo") == txt("bar") assert ly(YAML_COMPONENTS, ("somevalue", "foo")) == txt("bar")
def test_loadtxt_dynamic(): @renders(loadtxt("tests/assets/html_components/component.html")) def render_component(): return {"foo": "bar"} assert render_component() == txt("<p>bar</p>")