Lines Matching refs:soup
26 def soup(self, markup, **kwargs): member in SoupTest
59 doctype_str, soup = self._document_with_doctype(doctype_fragment)
62 doctype = soup.contents[0]
65 self.assertEqual(str(soup)[:len(doctype_str)], doctype_str)
69 self.assertEqual(soup.p.contents[0], 'foo')
75 soup = self.soup(markup)
76 return doctype, soup
85 soup = self.soup("<!DOCTYPE>")
86 doctype = soup.contents[0]
112 soup = self.soup(markup)
114 soup.encode("utf-8").replace(b"\n", b""),
131 soup = self.soup("<p/>")
132 self.assertFalse(soup.p.is_empty_element)
133 self.assertEqual(str(soup.p), "<p></p>")
151 soup = self.soup("<br></br>")
152 self.assertTrue(soup.br.is_empty_element)
153 self.assertEqual(str(soup.br), "<br/>")
163 soup = self.soup(markup)
164 comment = soup.find(text="foobar")
168 foo = soup.find(text="foo")
170 baz = soup.find(text="baz")
191 soup = self.soup('<blockquote><p><b>Foo</b></p></blockquote>')
192 blockquote = soup.blockquote
221 soup = self.soup(markup)
222 self.assertEqual(["css"], soup.div.div['class'])
253 soup = self.soup("<html><h2>\nfoo</h2><p></p></html>")
254 self.assertEqual("p", soup.h2.string.next_element.name)
255 self.assertEqual("p", soup.p.name)
263 soup = self.soup(markup)
264 self.assertEqual(markup, soup.encode())
265 html = soup.html
266 self.assertEqual('http://www.w3.org/1999/xhtml', soup.html['xmlns'])
268 'http://www.w3.org/1998/Math/MathML', soup.html['xmlns:mathml'])
270 'http://www.w3.org/2000/svg', soup.html['xmlns:svg'])
274 soup = self.soup(markup)
275 self.assertEqual(['foo', 'bar'], soup.a['class'])
289 soup = self.soup(markup)
290 self.assertEqual(u'Sacr\xe9 bleu!', soup.body.string)
295 soup = self.soup("A <b>bold</b> <meta/> <i>statement</i>",
297 self.assertEqual(soup.decode(), "<b>bold</b>")
309 soup = self.soup(text)
310 soup.foo['attr'] = 'Brawls happen at "Bob\'s Bar"'
312 soup.foo.decode(),
337 soup = self.soup(quote)
339 soup.p.string,
343 soup = self.soup("<a> </a>")
344 self.assertEqual(soup.a.string, u"\N{NO-BREAK SPACE}" * 2)
349 soup = self.soup(text)
350 self.assertEqual(soup.p.encode("utf-8"), expected)
364 soup = self.soup(iso_latin_html)
366 result = soup.encode("utf-8")
389 soup = self.soup(unicode_html)
393 self.assertEqual(soup.encode("utf-8"), unicode_html.encode("utf-8"))
394 self.assertEqual(soup.encode("euc_jp"), unicode_html.encode("euc_jp"))
400 soup = self.soup(
402 self.assertEqual(soup.original_encoding, 'iso8859-8')
404 soup.encode('utf-8'),
418 soup = self.soup(shift_jis_html)
421 parsed_meta = soup.find('meta', {'http-equiv': 'Content-type'})
445 soup = self.soup(shift_jis_html)
448 parsed_meta = soup.find('meta', id="encoding")
460 data = self.soup("<a>text</a>")
467 soup = self.soup("<root/>")
469 soup.encode(), b'<?xml version="1.0" encoding="utf-8"?>\n<root/>')
479 soup = self.soup(markup)
481 soup.encode("utf-8"), markup)
488 soup = BeautifulSoup(doc, "xml")
491 soup.script.string = 'console.log("< < hey > > ");'
492 encoded = soup.encode()
497 soup = self.soup(markup)
498 self.assertEqual(u'Sacr\xe9 bleu!', soup.root.string)
502 soup = self.soup(markup)
504 unicode(soup.rss), markup)
507 soup = self.soup("<root/>")
509 soup.encode("latin1"),
517 soup = self.soup(markup)
518 self.assertEqual(soup.encode("utf-8"), markup)
527 soup = self.soup(markup)
528 root = soup.root
534 soup = self.soup(markup)
535 self.assertEqual(unicode(soup.p), markup)
539 soup = self.soup(markup)
540 self.assertEqual(unicode(soup.foo), markup)
544 soup = self.soup(markup)
545 self.assertEqual(unicode(soup.foo), markup)
557 soup = self.soup(markup)
558 self.assertEqual("http://www.w3.org/1999/xhtml", soup.a.namespace)
562 soup = self.soup(markup)
564 self.assertEqual(namespace, soup.svg.namespace)
565 self.assertEqual(namespace, soup.circle.namespace)
570 soup = self.soup(markup)
572 self.assertEqual(namespace, soup.math.namespace)
573 self.assertEqual(namespace, soup.msqrt.namespace)
577 soup = self.soup(markup)
578 self.assertTrue(isinstance(soup.contents[0], Comment))
579 self.assertEqual(soup.contents[0], '?xml version="1.0" encoding="utf-8"?')
580 self.assertEqual("html", soup.contents[0].next_element.name)