Exemple #1
0
    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.')
Exemple #2
0
    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.')
Exemple #3
0
 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
Exemple #4
0
 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
Exemple #5
0
 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