Example #1
0
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/>'
Example #2
0
 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/>')
Example #3
0
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 == {}
Example #4
0
def test_ignore_case():
    assert Tag('<s></S>').contents == ''
    assert Tag('<Ref></ref>').contents == ''  # 43
Example #5
0
def test_contents_contains_tl():
    t = Tag('<b>{{text|t}}</b>')
    assert t.contents == '{{text|t}}'
Example #6
0
def test_attrs_without_values():
    assert Tag('<t n1 n2 n3>c</t>').attrs == {'n1': '', 'n2': '', 'n3': ''}
Example #7
0
def test_attrs():
    assert Tag('<t n1=v1 n2="v2" n3>c</t>').attrs == {
        'n1': 'v1',
        'n2': 'v2',
        'n3': ''
    }
Example #8
0
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
Example #9
0
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>'
Example #10
0
def test_get_tags():
    assert repr(Tag('<b><s></s></b>').get_tags()) == "[Tag('<s></s>')]"
Example #11
0
 def test_contents_contains_tl(self):
     t = Tag('<b>{{text|t}}</b>')
     self.assertEqual(t.contents, '{{text|t}}')
Example #12
0
 def test_has_attr(self):
     t = Tag('<t n1=v1>c</t>')
     self.assertTrue(t.has_attr('n1'))
     self.assertFalse(t.has_attr('n2'))
Example #13
0
 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>')