def test_combine_parts(self): docs = [ HTMLFeatureInfoDoc('<p>foo</p>'), HTMLFeatureInfoDoc('<body><p>bar</p></body>'), HTMLFeatureInfoDoc('<html><head><title>Hello<body><p>baz</p><p>baz2'), ] result = HTMLFeatureInfoDoc.combine(docs) assert (b'<body><p>foo</p><p>bar</p><p>baz</p><p>baz2</p></body>' in result.as_string()) eq_(result.info_type, 'html')
def test_combine(self): docs = [ HTMLFeatureInfoDoc(b'<html><head><title>Hello<body><p>baz</p><p>baz2'), HTMLFeatureInfoDoc(b'<p>foo</p>'), HTMLFeatureInfoDoc(b'<body><p>bar</p></body>'), ] result = HTMLFeatureInfoDoc.combine(docs) eq_(b"<html><head><title>Hello<body><p>baz</p>" b"<p>baz2\n<p>foo</p>\n<body><p>bar</p></body>", result.as_string()) eq_(result.info_type, 'text')
def test_combine_parts(self): docs = [ HTMLFeatureInfoDoc("<p>foo</p>"), HTMLFeatureInfoDoc("<body><p>bar</p></body>"), HTMLFeatureInfoDoc( "<html><head><title>Hello<body><p>baz</p><p>baz2"), ] result = HTMLFeatureInfoDoc.combine(docs) assert (b"<body><p>foo</p><p>bar</p><p>baz</p><p>baz2</p></body>" in result.as_string()) assert result.info_type == "html"
def test_as_etree(self): doc = HTMLFeatureInfoDoc('<p>hello</p>') eq_(doc.as_etree().find('body/p').text, 'hello')
def test_as_string(self): input_tree = html.fromstring('<p>Foo') doc = HTMLFeatureInfoDoc(input_tree) assert b'<body><p>Foo</p></body>' in strip_whitespace(doc.as_string())
def test_as_etree(self): doc = HTMLFeatureInfoDoc("<p>hello</p>") assert doc.as_etree().find("body/p").text == "hello"