Python bs4.dammit.markup() Examples
The following are 30
code examples of bs4.dammit.markup().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
bs4.dammit
, or try the search function
.
Example #1
Source File: test_soup.py From stopstalk-deployment with MIT License | 5 votes |
def test_smart_quote_substitution(self): # MS smart quotes are a common source of frustration, so we # give them a special test. quotes = b"\x91\x92foo\x93\x94" dammit = UnicodeDammit(quotes) self.assertEqual(self.sub.substitute_html(dammit.markup), "‘’foo“”")
Example #2
Source File: test_soup.py From MARA_Framework with GNU Lesser General Public License v3.0 | 5 votes |
def test_smart_quote_substitution(self): # MS smart quotes are a common source of frustration, so we # give them a special test. quotes = b"\x91\x92foo\x93\x94" dammit = UnicodeDammit(quotes) self.assertEqual(self.sub.substitute_html(dammit.markup), "‘’foo“”")
Example #3
Source File: test_soup.py From CrisisMappingToolkit with Apache License 2.0 | 5 votes |
def test_attribute_name_containing_unicode_characters(self): markup = u'<div><a \N{SNOWMAN}="snowman"></a></div>' self.assertEqual(self.soup(markup).div.encode("utf8"), markup.encode("utf8"))
Example #4
Source File: test_soup.py From MARA_Framework with GNU Lesser General Public License v3.0 | 5 votes |
def test_unicode_input(self): markup = u"I'm already Unicode! \N{SNOWMAN}" dammit = UnicodeDammit(markup) self.assertEqual(dammit.unicode_markup, markup)
Example #5
Source File: test_soup.py From MARA_Framework with GNU Lesser General Public License v3.0 | 5 votes |
def test_smart_quotes_to_unicode(self): markup = b"<foo>\x91\x92\x93\x94</foo>" dammit = UnicodeDammit(markup) self.assertEqual( dammit.unicode_markup, u"<foo>\u2018\u2019\u201c\u201d</foo>")
Example #6
Source File: test_soup.py From MARA_Framework with GNU Lesser General Public License v3.0 | 5 votes |
def test_attribute_name_containing_unicode_characters(self): markup = u'<div><a \N{SNOWMAN}="snowman"></a></div>' self.assertEqual(self.soup(markup).div.encode("utf8"), markup.encode("utf8"))
Example #7
Source File: test_soup.py From CrisisMappingToolkit with Apache License 2.0 | 5 votes |
def test_smart_quotes_to_ascii(self): markup = b"<foo>\x91\x92\x93\x94</foo>" dammit = UnicodeDammit(markup, smart_quotes_to="ascii") self.assertEqual( dammit.unicode_markup, """<foo>''""</foo>""")
Example #8
Source File: test_soup.py From CrisisMappingToolkit with Apache License 2.0 | 5 votes |
def test_smart_quotes_to_html_entities(self): markup = b"<foo>\x91\x92\x93\x94</foo>" dammit = UnicodeDammit(markup, smart_quotes_to="html") self.assertEqual( dammit.unicode_markup, "<foo>‘’“”</foo>")
Example #9
Source File: test_soup.py From CrisisMappingToolkit with Apache License 2.0 | 5 votes |
def test_smart_quotes_to_unicode(self): markup = b"<foo>\x91\x92\x93\x94</foo>" dammit = UnicodeDammit(markup) self.assertEqual( dammit.unicode_markup, u"<foo>\u2018\u2019\u201c\u201d</foo>")
Example #10
Source File: test_soup.py From CrisisMappingToolkit with Apache License 2.0 | 5 votes |
def test_unicode_input(self): markup = u"I'm already Unicode! \N{SNOWMAN}" dammit = UnicodeDammit(markup) self.assertEqual(dammit.unicode_markup, markup)
Example #11
Source File: test_soup.py From MARA_Framework with GNU Lesser General Public License v3.0 | 5 votes |
def test_parse_with_soupstrainer(self): markup = "No<b>Yes</b><a>No<b>Yes <c>Yes</c></b>" strainer = SoupStrainer("b") soup = self.soup(markup, parse_only=strainer) self.assertEqual(soup.encode(), b"<b>Yes</b><b>Yes <c>Yes</c></b>")
Example #12
Source File: test_soup.py From stopstalk-deployment with MIT License | 5 votes |
def test_smart_quotes_to_html_entities(self): markup = b"<foo>\x91\x92\x93\x94</foo>" dammit = UnicodeDammit(markup, smart_quotes_to="html") self.assertEqual( dammit.unicode_markup, "<foo>‘’“”</foo>")
Example #13
Source File: test_soup.py From stopstalk-deployment with MIT License | 5 votes |
def test_smart_quotes_to_unicode(self): markup = b"<foo>\x91\x92\x93\x94</foo>" dammit = UnicodeDammit(markup) self.assertEqual( dammit.unicode_markup, u"<foo>\u2018\u2019\u201c\u201d</foo>")
Example #14
Source File: test_soup.py From stopstalk-deployment with MIT License | 5 votes |
def test_unicode_input(self): markup = u"I'm already Unicode! \N{SNOWMAN}" dammit = UnicodeDammit(markup) self.assertEqual(dammit.unicode_markup, markup)
Example #15
Source File: test_soup.py From stopstalk-deployment with MIT License | 5 votes |
def test_attribute_name_containing_unicode_characters(self): markup = u'<div><a \N{SNOWMAN}="snowman"></a></div>' self.assertEqual(self.soup(markup).div.encode("utf8"), markup.encode("utf8"))
Example #16
Source File: test_soup.py From stopstalk-deployment with MIT License | 5 votes |
def test_smart_quotes_to_ascii(self): markup = b"<foo>\x91\x92\x93\x94</foo>" dammit = UnicodeDammit(markup, smart_quotes_to="ascii") self.assertEqual( dammit.unicode_markup, """<foo>''""</foo>""")
Example #17
Source File: test_soup.py From stopstalk-deployment with MIT License | 5 votes |
def test_parse_with_soupstrainer(self): markup = "No<b>Yes</b><a>No<b>Yes <c>Yes</c></b>" strainer = SoupStrainer("b") soup = self.soup(markup, parse_only=strainer) self.assertEqual(soup.encode(), b"<b>Yes</b><b>Yes <c>Yes</c></b>")
Example #18
Source File: test_soup.py From B.E.N.J.I. with MIT License | 5 votes |
def test_smart_quotes_to_ascii(self): markup = b"<foo>\x91\x92\x93\x94</foo>" dammit = UnicodeDammit(markup, smart_quotes_to="ascii") self.assertEqual( dammit.unicode_markup, """<foo>''""</foo>""")
Example #19
Source File: test_soup.py From B.E.N.J.I. with MIT License | 5 votes |
def test_smart_quotes_to_html_entities(self): markup = b"<foo>\x91\x92\x93\x94</foo>" dammit = UnicodeDammit(markup, smart_quotes_to="html") self.assertEqual( dammit.unicode_markup, "<foo>‘’“”</foo>")
Example #20
Source File: test_soup.py From B.E.N.J.I. with MIT License | 5 votes |
def test_smart_quotes_to_unicode(self): markup = b"<foo>\x91\x92\x93\x94</foo>" dammit = UnicodeDammit(markup) self.assertEqual( dammit.unicode_markup, "<foo>\u2018\u2019\u201c\u201d</foo>")
Example #21
Source File: test_soup.py From B.E.N.J.I. with MIT License | 5 votes |
def test_unicode_input(self): markup = "I'm already Unicode! \N{SNOWMAN}" dammit = UnicodeDammit(markup) self.assertEqual(dammit.unicode_markup, markup)
Example #22
Source File: test_soup.py From B.E.N.J.I. with MIT License | 5 votes |
def test_attribute_name_containing_unicode_characters(self): markup = '<div><a \N{SNOWMAN}="snowman"></a></div>' self.assertEqual(self.soup(markup).div.encode("utf8"), markup.encode("utf8"))
Example #23
Source File: test_soup.py From B.E.N.J.I. with MIT License | 5 votes |
def test_smart_quote_substitution(self): # MS smart quotes are a common source of frustration, so we # give them a special test. quotes = b"\x91\x92foo\x93\x94" dammit = UnicodeDammit(quotes) self.assertEqual(self.sub.substitute_html(dammit.markup), "‘’foo“”")
Example #24
Source File: test_soup.py From B.E.N.J.I. with MIT License | 5 votes |
def test_parse_with_soupstrainer(self): markup = "No<b>Yes</b><a>No<b>Yes <c>Yes</c></b>" strainer = SoupStrainer("b") soup = self.soup(markup, parse_only=strainer) self.assertEqual(soup.encode(), b"<b>Yes</b><b>Yes <c>Yes</c></b>")
Example #25
Source File: test_soup.py From Gank-Alfred-Workflow with MIT License | 5 votes |
def test_smart_quotes_to_ascii(self): markup = b"<foo>\x91\x92\x93\x94</foo>" dammit = UnicodeDammit(markup, smart_quotes_to="ascii") self.assertEqual( dammit.unicode_markup, """<foo>''""</foo>""")
Example #26
Source File: test_soup.py From Gank-Alfred-Workflow with MIT License | 5 votes |
def test_smart_quotes_to_xml_entities(self): markup = b"<foo>\x91\x92\x93\x94</foo>" dammit = UnicodeDammit(markup, smart_quotes_to="xml") self.assertEqual( dammit.unicode_markup, "<foo>‘’“”</foo>")
Example #27
Source File: test_soup.py From Gank-Alfred-Workflow with MIT License | 5 votes |
def test_smart_quotes_to_unicode(self): markup = b"<foo>\x91\x92\x93\x94</foo>" dammit = UnicodeDammit(markup) self.assertEqual( dammit.unicode_markup, u"<foo>\u2018\u2019\u201c\u201d</foo>")
Example #28
Source File: test_soup.py From Gank-Alfred-Workflow with MIT License | 5 votes |
def test_smart_quote_substitution(self): # MS smart quotes are a common source of frustration, so we # give them a special test. quotes = b"\x91\x92foo\x93\x94" dammit = UnicodeDammit(quotes) self.assertEqual(self.sub.substitute_html(dammit.markup), "‘’foo“”")
Example #29
Source File: test_soup.py From Gank-Alfred-Workflow with MIT License | 5 votes |
def test_parse_with_soupstrainer(self): markup = "No<b>Yes</b><a>No<b>Yes <c>Yes</c></b>" strainer = SoupStrainer("b") soup = self.soup(markup, parse_only=strainer) self.assertEqual(soup.encode(), b"<b>Yes</b><b>Yes <c>Yes</c></b>")
Example #30
Source File: test_soup.py From Gank-Alfred-Workflow with MIT License | 5 votes |
def test_beautifulstonesoup(self): with warnings.catch_warnings(record=True) as w: soup = BeautifulStoneSoup("<markup>") self.assertTrue(isinstance(soup, BeautifulSoup)) self.assertTrue("BeautifulStoneSoup class is deprecated")