def test_vselect_value_with_unicode_coertion():
    # FIXME: This test may fail in Python 3.4 because of HTML attribute
    # ordering.
    s = mod.vselect('foo', ((1, 'bar'), (2, 'baz')), {'foo': '1'})
    assert mod.tag('option', 'bar', value=1, selected=None) in s
    assert mod.tag('option', 'baz', value=2) in s
    s = mod.vselect('foo', ((1, 'bar'), (2, 'baz')), {'foo': 2})
    assert mod.tag('option', 'bar', value=1) in s
    assert mod.tag('option', 'baz', value=2, selected=None) in s
Beispiel #2
0
 def render(self):
     return html.tag('label',
                     html.html_escape(self.text),
                     _for=self.for_element)
def test_tag_content():
    assert mod.tag('foo', 'bar') == '<foo>bar</foo>'
def test_tag():
    assert mod.tag('foo') == '<foo></foo>'
def test_vselect_empty():
    s = mod.vselect('foo', ((1, 'bar'),), {}, empty='foo')
    assert mod.tag('option', 'foo', value=None) in s
    assert mod.tag('option', 'bar', value=1) in s
def test_vselect_choices():
    s = mod.vselect('foo', ((1, 'bar'), (2, 'baz')), {})
    assert mod.tag('option', 'bar', value=1) in s
    assert mod.tag('option', 'baz', value=2) in s
def test_tag_attribute_with_underscore():
    assert mod.tag('foo', _bar='fam') == '<foo bar="fam"></foo>'
def test_tag_attributes():
    assert mod.tag('foo', bar='fam') == '<foo bar="fam"></foo>'
def test_nonclosing_tag():
    assert mod.tag('foo', nonclosing=True) == '<foo>'
    assert mod.tag('foo', 'bar', nonclosing=True) == '<foo>'
def test_tag_content_html():
    assert mod.tag('foo', '<bar>') == '<foo><bar></foo>'
 def render(self):
     return html.tag('label',
                     self.text,
                     _for=self.for_element)