def test_html_branches(self) -> None: html = """ <!-- test --> <!DOCTYPE html> <html> <!-- test --> <head> <title>Test</title> <meta charset="utf-8" /> <link rel="stylesheet" href="style.css" /> </head> <body> <p>Hello<br>world!</p> <p>Goodbye<!-- test -->world!</p> </body> </html> <!-- test --> """ branches = html_branches(html) self.assertEqual(branches[0].text(), 'html head title') self.assertEqual(branches[1].text(), 'html body p br') self.assertEqual(branches[2].text(), 'html body p') self.assertEqual(branches[0].staircase_text(), '\n html\n head\n title\n') self.assertEqual( branches[1].staircase_text(), '\n html\n body\n p\n br\n') self.assertEqual(branches[2].staircase_text(), '\n html\n body\n p\n')
def test_html_branches(self) -> None: html = """ <!-- test --> <!DOCTYPE html> <html> <!-- test --> <head> <title>Test</title> <meta charset="utf-8" /> <link rel="stylesheet" href="style.css" /> </head> <body> <p>Hello<br>world!</p> <p>Goodbye<!-- test -->world!</p> </body> </html> <!-- test --> """ branches = html_branches(html) self.assertEqual( [(branch.text(), branch.staircase_text()) for branch in branches], [ ("html head title", "\n html\n head\n title\n"), ("html head meta", "\n html\n head\n meta\n"), ("html head link", "\n html\n head\n link\n"), ("html body p br", "\n html\n body\n p\n br\n"), ("html body p p", "\n html\n body\n p\n p\n"), ], )
def test_html_branches(self): # type: () -> None html = """ <!-- test --> <!DOCTYPE html> <html> <!-- test --> <head> <title>Test</title> <meta charset="utf-8" /> <link rel="stylesheet" href="style.css" /> </head> <body> <p>Hello<br />world!</p> <p>Goodbye<!-- test -->world!</p> </body> </html> <!-- test --> """ branches = html_branches(html) self.assertEqual(branches[0].text(), 'html head title') self.assertEqual(branches[1].text(), 'html body p br') self.assertEqual(branches[2].text(), 'html body p') self.assertEqual(branches[0].staircase_text(), '\n html\n head\n title\n') self.assertEqual(branches[1].staircase_text(), '\n html\n body\n p\n br\n') self.assertEqual(branches[2].staircase_text(), '\n html\n body\n p\n')