Skip to content

Commit c44c06e

Browse files
committed
Add unit test for automatic links.
1 parent 8d65abc commit c44c06e

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
"""
2+
Python Markdown
3+
4+
A Python implementation of John Gruber's Markdown.
5+
6+
Documentation: https://python-markdown.github.io/
7+
GitHub: https://github.com/Python-Markdown/markdown/
8+
PyPI: https://pypi.org/project/Markdown/
9+
10+
Started by Manfred Stienstra (http://www.dwerg.net/).
11+
Maintained for a few years by Yuri Takhteyev (http://www.freewisdom.org).
12+
Currently maintained by Waylan Limberg (https://github.com/waylan),
13+
Dmitry Shachnev (https://github.com/mitya57) and Isaac Muse (https://github.com/facelessuser).
14+
15+
Copyright 2007-2018 The Python Markdown Project (v. 1.7 and later)
16+
Copyright 2004, 2005, 2006 Yuri Takhteyev (v. 0.2-1.6b)
17+
Copyright 2004 Manfred Stienstra (the original version)
18+
19+
License: BSD (see LICENSE.md for details).
20+
"""
21+
22+
from markdown.test_tools import TestCase
23+
24+
25+
class TestAutomaticLinks(TestCase):
26+
27+
def test_email_address(self):
28+
self.assertMarkdownRenders(
29+
"""asdfasdfadsfasd <yuri@freewisdom.org> or you can say """,
30+
"""<p>asdfasdfadsfasd <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#121;&#117;&#114;&#105;&#64;&#102;&#114;&#101;&#101;&#119;&#105;&#115;&#100;&#111;&#109;&#46;&#111;&#114;&#103;">&#121;&#117;&#114;&#105;&#64;&#102;&#114;&#101;&#101;&#119;&#105;&#115;&#100;&#111;&#109;&#46;&#111;&#114;&#103;</a> or you can say </p>"""
31+
)
32+
33+
def test_mailto_email_address(self):
34+
self.assertMarkdownRenders(
35+
"""instead <mailto:yuri@freewisdom.org>""",
36+
"""<p>instead <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#121;&#117;&#114;&#105;&#64;&#102;&#114;&#101;&#101;&#119;&#105;&#115;&#100;&#111;&#109;&#46;&#111;&#114;&#103;">&#121;&#117;&#114;&#105;&#64;&#102;&#114;&#101;&#101;&#119;&#105;&#115;&#100;&#111;&#109;&#46;&#111;&#114;&#103;</a></p>"""
37+
)
38+
39+
def test_email_address_with_ampersand(self):
40+
self.assertMarkdownRenders(
41+
"""<bob&sue@example.com>""",
42+
"""<p><a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#98;&#111;&#98;&#38;&#115;&#117;&#101;&#64;&#101;&#120;&#97;&#109;&#112;&#108;&#101;&#46;&#99;&#111;&#109;">&#98;&#111;&#98;&amp;&#115;&#117;&#101;&#64;&#101;&#120;&#97;&#109;&#112;&#108;&#101;&#46;&#99;&#111;&#109;</a></p>"""
43+
)
44+
45+
def test_invalid_email_address_local_part(self):
46+
self.assertMarkdownRenders(
47+
"""Missing local-part <@domain>""",
48+
"""<p>Missing local-part &lt;@domain&gt;</p>"""
49+
)
50+
51+
def test_invalid_email_address_domain(self):
52+
self.assertMarkdownRenders(
53+
"""Missing domain <local-part@>""",
54+
"""<p>Missing domain <local-part@></p>"""
55+
)

0 commit comments

Comments
 (0)