1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- 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
|