Esempio n. 1
0
    def test_input_with_id(self):
        soup = BeautifulSoup(Text('email', id='my_email_id').render())
        self.assertEqual(soup.input['id'], 'my_email_id')

        tag = Text('email')
        tag.id = 'my_email_2'
        soup = BeautifulSoup(tag.render())
        self.assertEqual(soup.input['id'], 'my_email_2')
Esempio n. 2
0
    def test_input_with_auto_id(self):
        soup = BeautifulSoup(Text('email', id=True).render())
        self.assertEqual(soup.input['id'], 'email')

        tag = Text('email_2')
        tag.id = True
        soup = BeautifulSoup(tag.render())
        self.assertEqual(soup.input['id'], 'email_2')
        self.assertEqual(tag.id, 'email_2')

        tag = Text('email_3')
        auto_id = tag.id
        soup = BeautifulSoup(tag.render())
        self.assertEqual(soup.input['id'], 'email_3')
        self.assertEqual(tag.id, 'email_3')
Esempio n. 3
0
 def test_input_with_attributes(self):
     tag = Text('email',
                classes=['error', 'large'],
                style='font-weight:bold;')
     soup = BeautifulSoup(tag.render())
     self.assertEqual(soup.input['class'], ['error', 'large'])
     self.assertEqual(soup.input['style'], 'font-weight:bold;')
Esempio n. 4
0
 def test_with_label_align_right(self):
     #I can't figure out how to make sure the label is on the right with
     #BS4, so I'm just going to assume the code works correctly.
     tag = Text('email', label=Label('Email', align='right'))
     soup = BeautifulSoup(tag.render())
     self.assertEqual(soup.label.get_text(), 'Email')
     self.assertEqual(soup.label.input, None)
     self.assertEqual(soup.input['name'], 'email')
Esempio n. 5
0
 def test_with_wrapper_align_right(self):
     tag = Text('email', wrapper=Label('Email', align='right'))
     soup = BeautifulSoup(tag.render())
     self.assertEqual(soup.label.get_text(), ' Email')
     self.assertEqual(soup.label.input['name'], 'email')
Esempio n. 6
0
 def test_with_wrapper(self):
     tag = Text('email', wrapper='Email')
     soup = BeautifulSoup(tag.render())
     self.assertEqual(soup.label.get_text(), 'Email ')
     self.assertEqual(soup.label.input['name'], 'email')
Esempio n. 7
0
 def test_basic_input(self):
     soup = BeautifulSoup(Text('email').__html__())
     self.assertEqual(soup.input['type'], 'text')
     self.assertEqual(soup.input['name'], 'email')
Esempio n. 8
0
 def test_input_with_value(self):
     soup = BeautifulSoup(Text('email', value='*****@*****.**').render())
     self.assertEqual(soup.input['type'], 'text')
     self.assertEqual(soup.input['name'], 'email')
     self.assertEqual(soup.input['value'], '*****@*****.**')