123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- import pytest
-
-
- @pytest.mark.parametrize(
- "in_,out_unicode, out_html",
- [
- ("", "", ""),
- (" ", " ", " "),
- ("A very simple test", "A very simple\u00a0test", "A very simple test"),
- ("Test", "Test", "Test"),
- (" Test", " Test", " Test"),
- (
- "<ul><li>Test</p></li><ul>",
- "<ul><li>Test</p></li><ul>",
- "<ul><li>Test</p></li><ul>",
- ),
- (
- "<ul><li> Test</p></li><ul>",
- "<ul><li> Test</p></li><ul>",
- "<ul><li> Test</p></li><ul>",
- ),
- (
- "<p>In a couple of paragraphs</p><p>paragraph two</p>",
- "<p>In a couple of\u00a0paragraphs</p><p>paragraph\u00a0two</p>",
- "<p>In a couple of paragraphs</p><p>paragraph two</p>",
- ),
- (
- '<h1><a href="#">In a link inside a heading</i> </a></h1>',
- '<h1><a href="#">In a link inside a\u00a0heading</i> </a></h1>',
- '<h1><a href="#">In a link inside a heading</i> </a></h1>',
- ),
- (
- '<h1><a href="#">In a link</a> followed by other text</h1>',
- '<h1><a href="#">In a link</a> followed by other\u00a0text</h1>',
- '<h1><a href="#">In a link</a> followed by other text</h1>',
- ),
- (
- '<h1><a href="#"></a></h1>',
- '<h1><a href="#"></a></h1>',
- '<h1><a href="#"></a></h1>',
- ),
- (
- "<div>Divs get no love!</div>",
- "<div>Divs get no love!</div>",
- "<div>Divs get no love!</div>",
- ),
- (
- "<pre>Neither do PREs</pre>",
- "<pre>Neither do PREs</pre>",
- "<pre>Neither do PREs</pre>",
- ),
- (
- "<div><p>But divs with paragraphs do!</p></div>",
- "<div><p>But divs with paragraphs\u00a0do!</p></div>",
- "<div><p>But divs with paragraphs do!</p></div>",
- ),
- (
- "<p>With <mark>my friend Mark.</mark></p>",
- "<p>With <mark>my friend\u00a0Mark.</mark></p>",
- "<p>With <mark>my friend Mark.</mark></p>",
- ),
- (
- "Really. Good.",
- "Really. Good.",
- "Really. Good.",
- ),
- (
- "With, punctuation",
- "With, punctuation",
- "With, punctuation",
- ),
- (
- "<details><summary>Unfold for content</summary></details>",
- "<details><summary>Unfold for\u00a0content</summary></details>",
- "<details><summary>Unfold for content</summary></details>",
- ),
- # TODISCUSS: we probably want to widont the summary too?
- (
- (
- "<details><summary>Unfold for content</summary>"
- "<p>This is the content.</p></details>"
- ),
- (
- "<details><summary>Unfold for content</summary>"
- "<p>This is the\u00a0content.</p></details>"
- ),
- (
- "<details><summary>Unfold for content</summary>"
- "<p>This is the content.</p></details>"
- ),
- ),
- ],
- )
- def test_widont(in_, out_unicode, out_html):
- from widont import widont
-
- assert widont(in_) == out_unicode
- assert widont(out_unicode) == out_unicode
- assert widont(in_, html=True) == out_html
- # TODO
- # assert widont(out_html, html=True) == out_html
|