caterpillar_test.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:caterpillar 作者: chromium 项目源码 文件源码
def test_no_duplicate_metas(self):
    """Tests that existing meta tags aren't duplicated."""
    chrome_app_manifest = {'description': 'a déscription'}
    root_path = 'path'
    html = """
<!DOCTYPE html>
<html>
 <head>
  <title>
   Hello Wó®ld
  </title>
  <meta name="description" content="tést description"/>
  <link href="styles/main.css" rel="stylesheet"/>
 </head>
 <body>
  <h1>
   Héllo, World! ÚÑÍ¢ÓÐÉ
  </h1>
 </body>
</html>"""
    soup = bs4.BeautifulSoup(html)
    caterpillar.inject_misc_tags(soup, chrome_app_manifest, root_path, '')
    metas = soup.findAll('meta', {'name': 'description'})
    self.assertEqual(len(metas), 1)
    self.assertEqual(metas[0]['content'], 'tést description')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号