Example #1
0
def test_tag_half():
    tag = TagFactory(xml=False)
    assert html(tag.foo(bar='baz', _open=False)) == '</foo>'
    assert html(tag.foo(bar='baz', _close=False)) == '<foo bar="baz">'
    assert html(tag.br(foo='bar', _close=False)) == '<br foo="bar">'
    assert html(tag.br(foo='bar', _open=False)) == ''
    assert html(tag.br(foo='bar', _open=False, _close=True)) == '</br>'
    tag = TagFactory(xml=True)
    assert html(tag.foo(bar='baz', _open=False)) == '</foo>'
    # XXX Surely this is wrong?
    assert html(tag.foo(bar='baz', _close=False)) == '<foo bar="baz"/>'
    assert html(tag.br(foo='bar', _close=False)) == '<br foo="bar"/>'
    assert html(tag.br(foo='bar', _open=False)) == ''
    assert html(tag.br(foo='bar', _open=False, _close=True)) == '</br>'
Example #2
0
def test_xml_tag_attrs():
    tag = TagFactory(xml=True)
    assert html(tag.foo(bar='baz')) == '<foo bar="baz"></foo>'
    assert html(tag.foo(bar=101)) == '<foo bar="101"></foo>'
    assert html(tag.foo(bar=True)) == '<foo bar="bar"></foo>'
    assert html(tag.foo(bar=False)) == '<foo></foo>'
    assert html(tag.foo(bar=None)) == '<foo></foo>'
    assert html(tag.br(foo='bar')) == '<br foo="bar"/>'
    assert html(tag.foo(bar=b'baz')) == '<foo bar="baz"></foo>'
    assert html(tag.br(foo=b'm\xc2\xb5')) == '<br foo="mµ"/>'
    assert html(tag.foo(bar=range(5))) == '<foo bar="01234"></foo>'
Example #3
0
def test_tag_contents():
    tag = TagFactory(xml=False)
    assert html(tag.foo(tag.bar('baz'))) == '<foo><bar>baz</bar></foo>'
    assert html(tag.foo('bar', 'baz')) == '<foo>barbaz</foo>'
    assert html(tag.foo(1, ' ', 2, ' ', 3)) == '<foo>1 2 3</foo>'
Example #4
0
def test_html_tag_basics():
    tag = TagFactory(xml=False)
    assert html(tag.a()) == '<a></a>'
    assert html(tag.br()) == '<br>'
    assert html(tag.foo()) == '<foo></foo>'
Example #5
0
def test_str():
    assert html('foo') == 'foo'
    assert html('<foo>') == '&lt;foo&gt;'
    assert html('foo & bar') == 'foo &amp; bar'
Example #6
0
def test_content():
    assert html(content('foo')) == 'foo'
    assert html(content('<foo>')) == '&lt;foo&gt;'
    assert html(content('foo & bar')) == 'foo &amp; bar'
Example #7
0
def test_literals():
    assert html(literal('foo')) == 'foo'
    assert html(literal('<foo>')) == '<foo>'
    assert html(literal('foo & bar')) == 'foo & bar'