Exemple #1
0
    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))))
Exemple #2
0
 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"
     }])
Exemple #3
0
 def test_parse_html(self):
     tree = parse_html('<div><h1>test</h1></div>')
     self.assertEqual('test', tree.xpath('//h1')[0].text)