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
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
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
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
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
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)
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
def test_quote(): assert html.quote('<hey>!') == '<hey>!' assert html.quote(uni_value) == uni_value.encode('utf-8') assert html.quote(None) == '' assert html.str(None) == '' assert str(html.b('<hey>')) == '<b><hey></b>'
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=" " />'
def test_quote(): assert html.quote("<hey>!") == "<hey>!" assert html.quote(uni_value) == str_value assert html.quote(None) == "" assert html.str(None) == "" assert str(html.b("<hey>")) == "<b><hey></b>"
def test_quote(): assert html.quote('<hey>!') == '<hey>!' assert html.quote(uni_value) == str_value assert html.quote(None) == '' assert html.str(None) == '' assert str(html.b('<hey>')) == '<b><hey></b>'
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=" " />'
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