12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- 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>Avec <mark>mon ami Marc.</mark></p>",
- "<p>Avec <mark>mon ami\u00a0Marc.</mark></p>",
- "<p>Avec <mark>mon ami Marc.</mark></p>",
- ),
- (
- "Vraiment. Bien.",
- "Vraiment. Bien.",
- "Vraiment. Bien.",
- ),
- ],
- )
- 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
|