Example #1
0
    def test_empty_single_elements_with_attributes(self):

        from cocktail.html.element import Element

        for tag in ("img", "link", "hr", "br"):
            e = Element()
            e.tag = tag
            e["title"] = "hello world"
            self.assertEqual(self.get_html(e),
                             '<%s title="hello world">' % tag)

        for tag in ("img", "link", "hr", "br"):
            e = Element()
            e.tag = tag
            e["title"] = "hello world"
            e["id"] = "foo"
            html = self.get_html(e)
            self.assertTrue(
                html == '<%s title="hello world" id="foo">' % tag
                or html == '<%s id="foo" title="hello world">' % tag)

        for tag in ("img", "link", "hr", "br"):
            e = Element()
            e.tag = tag
            e["selected"] = True
            e["checked"] = False
            e["id"] = "foo"
            html = self.get_html(e)
            self.assertTrue(html == '<%s selected id="foo">' % tag
                            or html == '<%s id="foo" selected>' % tag)
Example #2
0
    def test_empty_compound_elements_with_attributes(self):

        from cocktail.html.element import Element

        for tag in ("div", "script", "table", "p", "b"):
            e = Element()
            e.tag = tag
            e["title"] = "hello world"
            self.assertEqual(self.get_html(e),
                             '<%s title="hello world"></%s>' % (tag, tag))

        for tag in ("div", "script", "table", "p", "b"):
            e = Element()
            e.tag = tag
            e["selected"] = True
            e["checked"] = False
            e["id"] = "foo"
            html = self.get_html(e)
            self.assertTrue(
                html == '<%s selected="selected" id="foo"></%s>' % (tag, tag)
                or html == '<%s id="foo" selected="selected"></%s>' %
                (tag, tag))

        for tag in ("div", "script", "table", "p", "b"):
            e = Element()
            e.tag = tag
            e["title"] = "hello world"
            e["id"] = "foo"
            html = self.get_html(e)
            self.assertTrue(
                html == '<%s title="hello world" id="foo"></%s>' % (tag, tag)
                or html == '<%s id="foo" title="hello world"></%s>' %
                (tag, tag))
Example #3
0
    def test_empty_compound_elements(self):

        from cocktail.html.element import Element

        for tag in ("div", "script", "table", "p", "b"):
            e = Element()
            e.tag = tag
            self.assertEqual(self.get_html(e), "<%s></%s>" % (tag, tag))
Example #4
0
    def test_empty_single_elements(self):

        from cocktail.html.element import Element

        for tag in ("img", "link", "hr", "br"):
            e = Element()
            e.tag = tag
            self.assertEqual(self.get_html(e), "<%s>" % tag)
Example #5
0
 def test_void_element(self):
     from cocktail.html.element import Element
     e = Element()
     e.tag = None
     self.assertEqual(self.get_html(e), "")