def test_addremove(self): self.assertEqual(self.map.length, 0) self.map.setNamedItem(self.attr) self.assertEqual(self.map.length, 1) self.assertEqual(self.map.getNamedItem('src').value, 'a') self.assertIsNone(self.map.getNamedItem('aaa')) self.map.removeNamedItem(Attr('aaa')) self.assertEqual(self.map.length, 1) self.map.removeNamedItem(Attr('src')) self.assertEqual(self.map.length, 0)
def createAttribute(self, name: str) -> Attr: """Create Attribute object with ``name``.""" return Attr(name)
def test_boolean_attr(self): hidden = Attr('hidden') hidden.value = True self.assertEqual(hidden.html, 'hidden') hidden.value = False self.assertEqual(hidden.html, '')
def setUp(self): self.map = NamedNodeMap(self) self.attr = Attr('src', value='a')
def setUp(self): self.id = Attr('id') self.cls = Attr('class') self.src = Attr('src')