Exemple #1
0
def run_test(test):
    for xoffsets, expect in zip(test['ranges'], test['expected']):
        if expect is None:
            assert xoffsets is None
        else:
            (x1, i1), (x2, i2) = xoffsets
            html = '<html><body>' + test['html'] + '</body></html>'
            xprange = XpathRange('/html/body' + x1, i1, '/html/body' + x2, i2)
            assert expect == xprange.slice_html(html)
Exemple #2
0
def run_test(test):
    for xoffsets, expect in zip(test['ranges'], test['expected']):
        if expect is None:
            assert xoffsets is None
        else:
            (x1, i1), (x2, i2) = xoffsets
            html = '<html><body>' + test['html'] + '</body></html>'
            xprange = XpathRange('/html/body' + x1, i1, '/html/body' + x2, i2)
            assert expect == xprange.slice_html(html)
 def xpath_slices(self, si, k, root=None):
     if root is None:
         root = XpathRange.html_node(si.body.clean_html)
     for xpranges in self.xpath_ranges(si, k):
         yield ' '.join(xp.slice_node(root) for xp in xpranges)
 def xpath_slices(self, si, k, root=None):
     if root is None:
         root = XpathRange.html_node(si.body.clean_html)
     for xpranges in self.xpath_ranges(si, k):
         yield ' '.join(xp.slice_node(root) for xp in xpranges)