Example #1
0
def test_set_attr_value():
    t = Tag('<t n1=v1 n2=v2 n1=\'v3\'>c</t>')
    t.set_attr('n1', 'v4')
    t.set_attr('n2', 'v5')
    assert t.string == '<t n1=v1 n2="v5" n1="v4">c</t>'
    t.set_attr('id', '1')
    assert t.string == '<t n1=v1 n2="v5" n1="v4" id="1">c</t>'
    t = Tag('<t>c</t>')
    t.set_attr('n', '')
    assert t.string == '<t n>c</t>'
Example #2
0
 def test_set_attr_value(self):
     t = Tag('<t n1=v1 n2=v2 n1=\'v3\'>c</t>')
     t.set_attr('n1', 'v4')
     t.set_attr('n2', 'v5')
     self.assertEqual(t.string, '<t n1=v1 n2="v5" n1="v4">c</t>')
     t.set_attr('id', '1')
     self.assertEqual(t.string, '<t n1=v1 n2="v5" n1="v4" id="1">c</t>')
     t = Tag('<t>c</t>')
     t.set_attr('n', '')
     self.assertEqual(t.string, '<t n>c</t>')