Exemplo n.º 1
0
 def test_print_on_basic(self):
     stream = StringIO()
     element = HTMLElement('div')
     element.attributes['class'] = 'column-4 medium'
     element.print_on(stream, newlines=False)
     output = stream.getvalue()
     self.assertEqual('<div class="column-4 medium"></div>', output)
Exemplo n.º 2
0
 def test_add_children(self):
     kids = [HTMLElement() for i in range(0, 10)]
     test_parent = HTMLElement()
     test_parent.add_children(kids)
     all_present = True
     for kid in kids:
         if kid not in test_parent.children:
             all_present = False
     self.assertTrue(all_present)
Exemplo n.º 3
0
 def test_print_on_with_content_nested(self):
     stream = StringIO()
     content = HTMLTextContent('this is content')
     parent = HTMLElement('div', children=[content])
     parent.attributes['class'] = 'column-4 medium'
     parent.print_on(stream, newlines=False)
     output = stream.getvalue()
     test_out = ('<div class="column-4 medium">this is content' + '</div>')
     # we don't care about white spaces or new linesso much
     output = re.sub(r'\s{2,}', '', output)
     output = re.sub(r'\n', '', output)
     self.assertEqual(test_out, output)
Exemplo n.º 4
0
 def test_set_attribute(self):
     element = HTMLElement()
     element.set_attribute('role', 'primary')
     element.set_attribute('class', 'window column-4 centered')
     self.assertEqual(element.attributes['role'], 'primary')
     self.assertEqual(element.attributes['class'],
                      'window column-4 centered')
Exemplo n.º 5
0
 def test_with_children(self):
     element = HTMLElement('div')
     child_one = HTMLElement('img')
     child_two = HTMLElement('article')
     element.with_children(child_one, child_two)
     self.assertTrue(child_one in element.children)
     self.assertTrue(child_two in element.children)
Exemplo n.º 6
0
 def test_remove_class_on_empty(self):
     element = HTMLElement()
     element.remove_class("test")
     self.assertTrue("class" not in element.attributes)
Exemplo n.º 7
0
 def test_summary_constructor(self):
     element = HTMLElement.summary()
     self.assertEqual(element.tag_name, 'summary')
     self.assertFalse(element.is_self_closing)
Exemplo n.º 8
0
 def test_add_class_on_empty(self):
     element = HTMLElement()
     element.add_class("column-4")
     class_list = element.attributes["class"].split()
     self.assertTrue("column-4" in class_list)
Exemplo n.º 9
0
 def test_source_constructor(self):
     element = HTMLElement.source()
     self.assertEqual(element.tag_name, 'source')
     self.assertTrue(element.is_self_closing)
Exemplo n.º 10
0
 def test_nav_constructor(self):
     element = HTMLElement.nav()
     self.assertEqual(element.tag_name, 'nav')
     self.assertFalse(element.is_self_closing)
Exemplo n.º 11
0
 def test_wbr_constructor(self):
     element = HTMLElement.wbr()
     self.assertEqual(element.tag_name, 'wbr')
     self.assertTrue(element.is_self_closing)
Exemplo n.º 12
0
 def test_progress_constructor(self):
     element = HTMLElement.progress()
     self.assertEqual(element.tag_name, 'progress')
     self.assertFalse(element.is_self_closing)
Exemplo n.º 13
0
 def test_textarea_constructor(self):
     element = HTMLElement.textarea()
     self.assertEqual(element.tag_name, 'textarea')
     self.assertFalse(element.is_self_closing)
Exemplo n.º 14
0
 def test_picture_constructor(self):
     element = HTMLElement.picture()
     self.assertEqual(element.tag_name, 'picture')
     self.assertFalse(element.is_self_closing)
Exemplo n.º 15
0
 def test_add_class(self):
     element = HTMLElement(attributes={'class': 'one two'})
     element.add_class("three")
     self.assertEqual(element.attributes['class'], "one two three")
Exemplo n.º 16
0
 def test_param_constructor(self):
     element = HTMLElement.param()
     self.assertEqual(element.tag_name, 'param')
     self.assertTrue(element.is_self_closing)
Exemplo n.º 17
0
 def test_output_constructor(self):
     element = HTMLElement.output()
     self.assertEqual(element.tag_name, 'output')
     self.assertFalse(element.is_self_closing)
Exemplo n.º 18
0
 def test_optgroup_constructor(self):
     element = HTMLElement.optgroup()
     self.assertEqual(element.tag_name, 'optgroup')
     self.assertFalse(element.is_self_closing)
Exemplo n.º 19
0
 def test_svg_constructor(self):
     element = HTMLElement.svg()
     self.assertEqual(element.tag_name, 'svg')
     self.assertFalse(element.is_self_closing)
Exemplo n.º 20
0
 def test_tr_constructor(self):
     element = HTMLElement.tr()
     self.assertEqual(element.tag_name, 'tr')
     self.assertFalse(element.is_self_closing)
Exemplo n.º 21
0
 def test_template_constructor(self):
     element = HTMLElement.template()
     self.assertEqual(element.tag_name, 'template')
     self.assertFalse(element.is_self_closing)
Exemplo n.º 22
0
 def test_ul_constructor(self):
     element = HTMLElement.ul()
     self.assertEqual(element.tag_name, 'ul')
     self.assertFalse(element.is_self_closing)
Exemplo n.º 23
0
 def test_ruby_constructor(self):
     element = HTMLElement.ruby()
     self.assertEqual(element.tag_name, 'ruby')
     self.assertFalse(element.is_self_closing)
Exemplo n.º 24
0
 def test_meta_constructor(self):
     element = HTMLElement.meta()
     self.assertEqual(element.tag_name, 'meta')
     self.assertTrue(element.is_self_closing)
Exemplo n.º 25
0
 def test_track_constructor(self):
     element = HTMLElement.track()
     self.assertEqual(element.tag_name, 'track')
     self.assertTrue(element.is_self_closing)
Exemplo n.º 26
0
 def test_remove_class(self):
     element = HTMLElement(attributes={"class": "one two three"})
     element.remove_class("two")
     self.assertEqual(element.attributes['class'], "one three")
Exemplo n.º 27
0
 def test_video_constructor(self):
     element = HTMLElement.video()
     self.assertEqual(element.tag_name, 'video')
     self.assertFalse(element.is_self_closing)
Exemplo n.º 28
0
 def test_section_constructor(self):
     element = HTMLElement.section()
     self.assertEqual(element.tag_name, 'section')
     self.assertFalse(element.is_self_closing)
Exemplo n.º 29
0
 def test_script_constructor(self):
     element = HTMLElement.script()
     self.assertEqual(element.tag_name, 'script')
     self.assertFalse(element.is_self_closing)
Exemplo n.º 30
0
 def test_menuitem_constructor(self):
     element = HTMLElement.menuitem()
     self.assertEqual(element.tag_name, 'menuitem')
     self.assertFalse(element.is_self_closing)