def test_title_parsing(self): def get_title(html): factory = Factory() response = test_html_response(html) factory.set_response(response) return factory.title html = (b"""\ <html><head> <title>T>itle</title> </head><body><p>Blah.<p></body></html> """) self.assertEqual(get_title(html), u'T>itle') html = ("""\ <html><head> <title> Ti<script type="text/strange">alert("this is valid HTML -- yuck!")</script> tle && </title> </head><body><p>Blah.<p></body></html> """) self.assertEqual( str(get_title(html)), 'Ti<script type="text/strange">alert("this is valid HTML -- yuck!")</script> tle &&') html = ("""\ <html><head> <title>""") self.assertEqual(get_title(html), u'')
def test_title_parsing(self): html = ("""\ <html><head> <title> Title\n Test</title> </head><body><p>Blah.<p></body></html> """) self.assertEqual(get_title(content_parser(html)), 'Title Test')