summaryrefslogtreecommitdiff
path: root/src/lxml/html/tests/test_elementsoup.py
blob: e1dbabce1ea776c0410a13ba5d04ed19ae01ed7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import unittest, sys
from lxml.tests.common_imports import make_doctest, HelperTestCase

try:
    import BeautifulSoup
    BS_INSTALLED = True
except ImportError:
    BS_INSTALLED = False

if BS_INSTALLED:
    class SoupParserTestCase(HelperTestCase):
        from lxml.html import soupparser

        def test_broken_attribute(self):
            html = """\
              <html><head></head><body>
                <form><input type='text' disabled size='10'></form>
              </body></html>
            """
            root = self.soupparser.fromstring(html)
            self.assert_(root.find('.//input').get('disabled') is not None)


def test_suite():
    suite = unittest.TestSuite()
    if sys.version_info >= (2,4):
        if BS_INSTALLED:
            suite.addTests([unittest.makeSuite(SoupParserTestCase)])
            suite.addTests([make_doctest('../../../../doc/elementsoup.txt')])
    return suite

if __name__ == '__main__':
    unittest.main()