def test_get_function(self): func = Player.get_function('height1') html = '<html><body><height>3' self.assertEquals(3, func(XpathSelector(parse_html(html)))) func = Player.get_function('height2') html = '<html><body><height>3' self.assertEquals(3, func(XpathSelector(parse_html(html))))
def test_it_works(self): tree = parse_html(XML) result = TreeInterface(tree).structured_xpath( '//issue', title='./title/text()', date='./date/text()', about='./about/text()', number=('./number/text()', int), home_url='./home-url/text()', ) self.assertEqual(result, [{ "date": "12.09.98", "about": "XML", "home_url": "www.j.ru/issues/", "number": 448, "title": "XML today" }])
def test_parse_html(self): tree = parse_html('<div><h1>test</h1></div>') self.assertEqual('test', tree.xpath('//h1')[0].text)