def test_set_attributes(self): #And then the set_attributes method tag = Tag('img') tag.set_attributes({ 'src': 'http://i.imgur.com/iWHK2.gif', 'alt': 'Cats are liquid, not solid.' }) soup = BeautifulSoup(tag.render()) self.assertEqual(soup.img.name, 'img') self.assertEqual(soup.img['src'], 'http://i.imgur.com/iWHK2.gif') self.assertEqual(soup.img['alt'], 'Cats are liquid, not solid.')
def prerender(self): """Return a Tag or TagContent object.""" tag = Tag('input', type_='text', name=self.name, value=self.value, id=self._id) tag.set_attributes(self.attributes) if self.label: if self.label.align == 'left': args = [self.label.label(self), ' ', tag] else: args = [tag, ' ', self.label.label(self)] tag = TagContent(*args) if self.wrapper: tag = self.wrapper.wrap(tag, self) return tag
def prerender(self): """Return a Tag or TagContent object.""" tag = Tag('input', type_='text', name=self.name, value=self.value, id=self.id) tag.set_attributes(self.attributes) return tag