def test_name(): t = Tag('<t>c</t>') assert t.name == 't' t.name = 'a' assert repr(t) == "Tag('<a>c</a>')" t = Tag('<t/>') assert t.name == 't' t.name = 'n' assert t.string == '<n/>'
def test_name(self): ae = self.assertEqual t = Tag('<t>c</t>') ae(t.name, 't') t.name = 'a' ae(repr(t), "Tag('<a>c</a>')") t = Tag('<t/>') ae(t.name, 't') t.name = 'n' ae(t.string, '<n/>')
def test_ref_with_invalid_attr(): # 47,48 assert Tag('<ref name="a"3></ref>').attrs == {'name': 'a'} assert Tag('<ref name=""></ref>').attrs == {'name': ''} assert Tag('<ref "16/32"></ref>').attrs == {}
def test_ignore_case(): assert Tag('<s></S>').contents == '' assert Tag('<Ref></ref>').contents == '' # 43
def test_contents_contains_tl(): t = Tag('<b>{{text|t}}</b>') assert t.contents == '{{text|t}}'
def test_attrs_without_values(): assert Tag('<t n1 n2 n3>c</t>').attrs == {'n1': '', 'n2': '', 'n3': ''}
def test_attrs(): assert Tag('<t n1=v1 n2="v2" n3>c</t>').attrs == { 'n1': 'v1', 'n2': 'v2', 'n3': '' }
def test_has_attr(): t = Tag('<t n1=v1>c</t>') assert t.has_attr('n1') is True assert t.has_attr('n2') is False
def test_attr_deletion(): t = Tag('<t n1=v1 n1=v333 n2=v22>c</t>') t.del_attr('n1') assert t.string == '<t n2=v22>c</t>'
def test_get_tags(): assert repr(Tag('<b><s></s></b>').get_tags()) == "[Tag('<s></s>')]"
def test_contents_contains_tl(self): t = Tag('<b>{{text|t}}</b>') self.assertEqual(t.contents, '{{text|t}}')
def test_has_attr(self): t = Tag('<t n1=v1>c</t>') self.assertTrue(t.has_attr('n1')) self.assertFalse(t.has_attr('n2'))
def test_attr_deletion(self): t = Tag('<t n1=v1 n1=v333 n2=v22>c</t>') t.del_attr('n1') self.assertEqual(t.string, '<t n2=v22>c</t>')