Example #1
0
def test_compound():
    output = '<b>Hey <i>you</i>!</b>'
    assert str(html.b('Hey ', html.i('you'), '!')) == output
    assert str(html.b()('Hey ')(html.i()('you'))('!')) == output
    inner = html('Hey ', html.i('you'), '!')
    assert html.str(inner) == 'Hey <i>you</i>!'
    assert str(inner) == 'Hey <i>you</i>!'
    assert str(html.b(inner)) == output
Example #2
0
def test_compound():
    output = "<b>Hey <i>you</i>!</b>"
    assert str(html.b("Hey ", html.i("you"), "!")) == output
    assert str(html.b()("Hey ")(html.i()("you"))("!")) == output
    inner = html("Hey ", html.i("you"), "!")
    assert html.str(inner) == "Hey <i>you</i>!"
    assert str(inner) == "Hey <i>you</i>!"
    assert str(html.b(inner)) == output
Example #3
0
def test_compound():
    output = '<b>Hey <i>you</i>!</b>'
    assert str(html.b('Hey ', html.i('you'), '!')) == output
    assert str(html.b()('Hey ')(html.i()('you'))('!')) == output
    inner = html('Hey ', html.i('you'), '!')
    assert html.str(inner) == 'Hey <i>you</i>!'
    assert str(inner) == 'Hey <i>you</i>!'
    assert str(html.b(inner)) == output
Example #4
0
def test_unicode():
    try:
        uni_value.encode("ascii")
    except ValueError:
        pass
    else:
        assert False, "We need something that can't be ASCII-encoded: %r (%r)" % (uni_value, uni_value.encode("ascii"))
    assert unicode(html.b(uni_value)) == u"<b>%s</b>" % uni_value
Example #5
0
def test_unicode():
    try:
        uni_value.encode('ascii')
    except ValueError:
        pass
    else:
        assert False, (
            "We need something that can't be ASCII-encoded: %r (%r)"
            % (uni_value, uni_value.encode('ascii')))
    assert str(html.b(uni_value)) == '<b>%s</b>' % uni_value
Example #6
0
def test_unicode():
    try:
        uni_value.encode('ascii')
    except ValueError:
        pass
    else:
        assert False, (
            "We need something that can't be ASCII-encoded: %r (%r)"
            % (uni_value, uni_value.encode('ascii')))
    assert unicode(html.b(uni_value)) == u'<b>%s</b>' % uni_value
Example #7
0
    def __init__(self, header='BaseMenu', **args):
        super(BaseMenu, self).__init__(**args)
        super(BaseMenu, self).set('class', 'ctx-menu nav navbar-nav')
        self._menu = {}

        # setup dropdown menu and header anchor
        self.dropdown = html.li()
        self.dropdown.set('class', 'dropdown')
        self.header_anchor = html.a(header, class_='dropdown-toggle')
        self.header_anchor.set('data-toggle', 'dropdown')
        # we append a caret to the end of the header
        # to demonstrate that this is a dropdown menu
        caret = html.b(' ', class_="caret")
        # append the objects
        self.header_anchor.append(caret)
        self.append(self.dropdown)
        self.dropdown.append(self.header_anchor)
        # create and append the menu container
        self.menu_list = UL()
        self.menu_list.set('class', 'dropdown-menu')
        self.dropdown.append(self.menu_list)
Example #8
0
def test_namespace():
    output = '<b tal:content="options/whatever" />'
    assert str(html.b(**{'tal:content': 'options/whatever'})) == output
    assert str(html.b(tal__content='options/whatever')) == output
Example #9
0
def test_quote():
    assert html.quote('<hey>!') == '&lt;hey&gt;!'
    assert html.quote(uni_value) == uni_value.encode('utf-8')
    assert html.quote(None) == ''
    assert html.str(None) == ''
    assert str(html.b('<hey>')) == '<b>&lt;hey&gt;</b>'
Example #10
0
def test_none():
    assert html.str(None) == ''
    assert str(html.b(class_=None)('hey')) == '<b>hey</b>'
    assert str(html.b(class_=' ')(None)) == '<b class=" " />'
Example #11
0
def test_namespace():
    output = '<b tal:content="options/whatever" />'
    assert str(html.b(**{'tal:content': 'options/whatever'})) == output
    assert str(html.b(tal__content='options/whatever')) == output
Example #12
0
def test_quote():
    assert html.quote("<hey>!") == "&lt;hey&gt;!"
    assert html.quote(uni_value) == str_value
    assert html.quote(None) == ""
    assert html.str(None) == ""
    assert str(html.b("<hey>")) == "<b>&lt;hey&gt;</b>"
Example #13
0
def test_none():
    assert html.str(None) == ''
    assert str(html.b(class_=None)('hey')) == '<b>hey</b>'
    assert str(html.b(class_=' ')(None)) == '<b class=" " />'
Example #14
0
def test_quote():
    assert html.quote('<hey>!') == '&lt;hey&gt;!'
    assert html.quote(uni_value) == str_value
    assert html.quote(None) == ''
    assert html.str(None) == ''
    assert str(html.b('<hey>')) == '<b>&lt;hey&gt;</b>'
Example #15
0
def test_none():
    assert html.str(None) == ""
    assert str(html.b(class_=None)("hey")) == "<b>hey</b>"
    assert str(html.b(class_=" ")(None)) == '<b class=" " />'
Example #16
0
def test_quote():
    assert html.quote('<hey>!') == '&lt;hey&gt;!'
    assert html.quote(uni_value) == uni_value.encode('utf-8')
    assert html.quote(None) == ''
    assert html.str(None) == ''
    assert str(html.b('<hey>')) == '<b>&lt;hey&gt;</b>'
Example #17
0
def test_namespace():
    output = '<b tal:content="options/whatever" />'
    assert str(html.b(**{"tal:content": "options/whatever"})) == output
    assert str(html.b(tal__content="options/whatever")) == output