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')
评论列表
文章目录