Skip to content

Commit

Permalink
Remove PHP tests and create tests for cases that are useful to keep (#…
Browse files Browse the repository at this point in the history
…1505)

* Remove PHP tests and create tests for cases that are useful to keep

Resolves #1480

* Update changelog
facelessuser authored Jan 30, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent f2ae4e4 commit 900e85d
Showing 66 changed files with 202 additions and 2,413 deletions.
2 changes: 2 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

* DRY fix in `abbr` extension by introducing method `create_element` (#1483).
* Clean up test directory some removing some redundant tests and port
non-redundant cases to the newer test framework.

### Fixed

3 changes: 0 additions & 3 deletions tests/php/Auto Links.text

This file was deleted.

3 changes: 0 additions & 3 deletions tests/php/Auto Links.xhtml

This file was deleted.

1 change: 0 additions & 1 deletion tests/php/Backslash escapes.text

This file was deleted.

1 change: 0 additions & 1 deletion tests/php/Backslash escapes.xhtml

This file was deleted.

6 changes: 0 additions & 6 deletions tests/php/Code Spans.text

This file was deleted.

6 changes: 0 additions & 6 deletions tests/php/Code Spans.xhtml

This file was deleted.

15 changes: 0 additions & 15 deletions tests/php/Code block in a list item.text

This file was deleted.

18 changes: 0 additions & 18 deletions tests/php/Code block in a list item.xhtml

This file was deleted.

2 changes: 0 additions & 2 deletions tests/php/Code block on second line.text

This file was deleted.

2 changes: 0 additions & 2 deletions tests/php/Code block on second line.xhtml

This file was deleted.

3 changes: 0 additions & 3 deletions tests/php/Email auto links.text

This file was deleted.

3 changes: 0 additions & 3 deletions tests/php/Email auto links.xhtml

This file was deleted.

80 changes: 0 additions & 80 deletions tests/php/Emphasis.text

This file was deleted.

83 changes: 0 additions & 83 deletions tests/php/Emphasis.xhtml

This file was deleted.

35 changes: 0 additions & 35 deletions tests/php/Empty List Item.text

This file was deleted.

47 changes: 0 additions & 47 deletions tests/php/Empty List Item.xhtml

This file was deleted.

9 changes: 0 additions & 9 deletions tests/php/Headers.text

This file was deleted.

39 changes: 0 additions & 39 deletions tests/php/Headers.xhtml

This file was deleted.

29 changes: 0 additions & 29 deletions tests/php/Horizontal Rules.text

This file was deleted.

30 changes: 0 additions & 30 deletions tests/php/Horizontal Rules.xhtml

This file was deleted.

15 changes: 0 additions & 15 deletions tests/php/Inline HTML (Simple).text

This file was deleted.

15 changes: 0 additions & 15 deletions tests/php/Inline HTML (Simple).xhtml

This file was deleted.

4 changes: 0 additions & 4 deletions tests/php/Inline HTML (Span).text

This file was deleted.

4 changes: 0 additions & 4 deletions tests/php/Inline HTML (Span).xhtml

This file was deleted.

9 changes: 0 additions & 9 deletions tests/php/Inline HTML comments.text

This file was deleted.

9 changes: 0 additions & 9 deletions tests/php/Inline HTML comments.xhtml

This file was deleted.

17 changes: 0 additions & 17 deletions tests/php/Ins & del.text

This file was deleted.

17 changes: 0 additions & 17 deletions tests/php/Ins & del.xhtml

This file was deleted.

339 changes: 0 additions & 339 deletions tests/php/License

This file was deleted.

1 change: 0 additions & 1 deletion tests/php/Links, inline style.text

This file was deleted.

1 change: 0 additions & 1 deletion tests/php/Links, inline style.xhtml

This file was deleted.

11 changes: 0 additions & 11 deletions tests/php/MD5 Hashes.text

This file was deleted.

11 changes: 0 additions & 11 deletions tests/php/MD5 Hashes.xhtml

This file was deleted.

13 changes: 0 additions & 13 deletions tests/php/Mixed OLs and ULs.text

This file was deleted.

21 changes: 0 additions & 21 deletions tests/php/Mixed OLs and ULs.xhtml

This file was deleted.

11 changes: 0 additions & 11 deletions tests/php/Nesting.text

This file was deleted.

11 changes: 0 additions & 11 deletions tests/php/Nesting.xhtml

This file was deleted.

22 changes: 0 additions & 22 deletions tests/php/PHP-Specific Bugs.text

This file was deleted.

17 changes: 0 additions & 17 deletions tests/php/PHP-Specific Bugs.xhtml

This file was deleted.

14 changes: 0 additions & 14 deletions tests/php/Parens in URL.text

This file was deleted.

11 changes: 0 additions & 11 deletions tests/php/Parens in URL.xhtml

This file was deleted.

5 changes: 0 additions & 5 deletions tests/php/Quotes in attributes.text

This file was deleted.

5 changes: 0 additions & 5 deletions tests/php/Quotes in attributes.xhtml

This file was deleted.

1 change: 0 additions & 1 deletion tests/php/Tight blocks.text

This file was deleted.

21 changes: 0 additions & 21 deletions tests/php/Tight blocks.xhtml

This file was deleted.

31 changes: 0 additions & 31 deletions tests/php/extra/Abbr.text

This file was deleted.

15 changes: 0 additions & 15 deletions tests/php/extra/Abbr.xhtml

This file was deleted.

115 changes: 0 additions & 115 deletions tests/php/extra/Definition Lists.text

This file was deleted.

155 changes: 0 additions & 155 deletions tests/php/extra/Definition Lists.xhtml

This file was deleted.

80 changes: 0 additions & 80 deletions tests/php/extra/Emphasis.text

This file was deleted.

83 changes: 0 additions & 83 deletions tests/php/extra/Emphasis.xhtml

This file was deleted.

60 changes: 0 additions & 60 deletions tests/php/extra/Fenced Code Blocks.text

This file was deleted.

53 changes: 0 additions & 53 deletions tests/php/extra/Fenced Code Blocks.xhtml

This file was deleted.

61 changes: 0 additions & 61 deletions tests/php/extra/Footnotes.text

This file was deleted.

96 changes: 0 additions & 96 deletions tests/php/extra/Footnotes.xhtml

This file was deleted.

104 changes: 0 additions & 104 deletions tests/php/extra/Inline HTML with Markdown content.text

This file was deleted.

125 changes: 0 additions & 125 deletions tests/php/extra/Inline HTML with Markdown content.xhtml

This file was deleted.

104 changes: 0 additions & 104 deletions tests/php/extra/Tables.text

This file was deleted.

310 changes: 0 additions & 310 deletions tests/php/extra/Tables.xhtml

This file was deleted.

11 changes: 11 additions & 0 deletions tests/test_syntax/blocks/test_code_blocks.py
Original file line number Diff line number Diff line change
@@ -86,3 +86,14 @@ def test_codeblock_escape(self):
"""
)
)

def test_codeblock_second_line(self):
self.assertMarkdownRenders(
'\n Code on the second line',
self.dedent(
"""
<pre><code>Code on the second line
</code></pre>
"""
)
)
26 changes: 26 additions & 0 deletions tests/test_syntax/blocks/test_html_blocks.py
Original file line number Diff line number Diff line change
@@ -1374,6 +1374,32 @@ def test_nested_closed_startendtag(self):
'<div><hr /></div>'
)

def test_multiline_attributes(self):
self.assertMarkdownRenders(
self.dedent(
"""
<div id="foo"
class="bar">
text
</div>
<hr class="foo"
id="bar" >
"""
),
self.dedent(
"""
<div id="foo"
class="bar">
text
</div>
<hr class="foo"
id="bar" >
"""
)
)

def test_auto_links_dont_break_parser(self):
self.assertMarkdownRenders(
self.dedent(
27 changes: 27 additions & 0 deletions tests/test_syntax/blocks/test_paragraphs.py
Original file line number Diff line number Diff line change
@@ -227,3 +227,30 @@ def test_paragraphs_CR_LF(self):
"""
)
)

def test_paragraphs_no_list(self):
self.assertMarkdownRenders(
self.dedent(
"""
Paragraph:
* no list
Paragraph
* no list
Paragraph:
* no list
Paragraph:
* no list
"""
),
'<p>Paragraph:\n'
'* no list</p>\n'
'<p>Paragraph\n'
' * no list</p>\n'
'<p>Paragraph:\n'
' * no list</p>\n'
'<p>Paragraph:\n'
' * no list</p>',
)
64 changes: 64 additions & 0 deletions tests/test_syntax/inline/test_code.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
"""
Python Markdown
A Python implementation of John Gruber's Markdown.
Documentation: https://python-markdown.github.io/
GitHub: https://github.com/Python-Markdown/markdown/
PyPI: https://pypi.org/project/Markdown/
Started by Manfred Stienstra (http://www.dwerg.net/).
Maintained for a few years by Yuri Takhteyev (http://www.freewisdom.org).
Currently maintained by Waylan Limberg (https://github.com/waylan),
Dmitry Shachnev (https://github.com/mitya57) and Isaac Muse (https://github.com/facelessuser).
Copyright 2007-2019 The Python Markdown Project (v. 1.7 and later)
Copyright 2004, 2005, 2006 Yuri Takhteyev (v. 0.2-1.6b)
Copyright 2004 Manfred Stienstra (the original version)
License: BSD (see LICENSE.md for details).
"""

from markdown.test_tools import TestCase


class TestCode(TestCase):

def test_code_comments(self):
self.assertMarkdownRenders(
self.dedent(
"""
Some code `<!--` that is not HTML `-->` in a paragraph.
Some code `<!--`
that is not HTML `-->`
in a paragraph.
"""
),
self.dedent(
"""
<p>Some code <code>&lt;!--</code> that is not HTML <code>--&gt;</code> in a paragraph.</p>
<p>Some code <code>&lt;!--</code>
that is not HTML <code>--&gt;</code>
in a paragraph.</p>
"""
)
)

def test_code_html(self):
self.assertMarkdownRenders(
self.dedent(
"""
<p>html</p>
Paragraph with code: `<p>test</p>`.
"""
),
self.dedent(
"""
<p>html</p>
<p>Paragraph with code: <code>&lt;p&gt;test&lt;/p&gt;</code>.</p>
"""
)
)
21 changes: 21 additions & 0 deletions tests/test_syntax/inline/test_emphasis.py
Original file line number Diff line number Diff line change
@@ -170,3 +170,24 @@ def test_complex_multple_emphasis_type_variant2(self):
'on the **1-4 row** of the AP Combat Table ***and*** receive',
'<p>on the <strong>1-4 row</strong> of the AP Combat Table <strong><em>and</em></strong> receive</p>'
)

def test_link_emphasis_outer(self):

self.assertMarkdownRenders(
'**[text](url)**',
'<p><strong><a href="url">text</a></strong></p>'
)

def test_link_emphasis_inner(self):

self.assertMarkdownRenders(
'[**text**](url)',
'<p><a href="url"><strong>text</strong></a></p>'
)

def test_link_emphasis_inner_outer(self):

self.assertMarkdownRenders(
'**[**text**](url)**',
'<p><strong><a href="url"><strong>text</strong></a></strong></p>'
)
52 changes: 51 additions & 1 deletion tests/test_syntax/inline/test_links.py
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
Currently maintained by Waylan Limberg (https://github.com/waylan),
Dmitry Shachnev (https://github.com/mitya57) and Isaac Muse (https://github.com/facelessuser).
Copyright 2007-2023 The Python Markdown Project (v. 1.7 and later)
Copyright 2007-2019 The Python Markdown Project (v. 1.7 and later)
Copyright 2004, 2005, 2006 Yuri Takhteyev (v. 0.2-1.6b)
Copyright 2004 Manfred Stienstra (the original version)
@@ -36,6 +36,30 @@ def test_nested_round_brackets(self):
"""<p><a href="http://link.com/(((((((()))))))())">Text</a> more text</p>"""
)

def test_nested_escaped_brackets(self):
self.assertMarkdownRenders(
R"""[Text](/url\(test\) "title").""",
"""<p><a href="/url(test)" title="title">Text</a>.</p>"""
)

def test_nested_escaped_brackets_and_angles(self):
self.assertMarkdownRenders(
R"""[Text](</url\(test\)> "title").""",
"""<p><a href="/url(test)" title="title">Text</a>.</p>"""
)

def test_nested_unescaped_brackets(self):
self.assertMarkdownRenders(
R"""[Text](/url(test) "title").""",
"""<p><a href="/url(test)" title="title">Text</a>.</p>"""
)

def test_nested_unescaped_brackets_and_angles(self):
self.assertMarkdownRenders(
R"""[Text](</url(test)> "title").""",
"""<p><a href="/url(test)" title="title">Text</a>.</p>"""
)

def test_uneven_brackets_with_titles1(self):
self.assertMarkdownRenders(
"""[Text](http://link.com/("title") more text""",
@@ -134,6 +158,12 @@ def test_amp_in_url(self):
'<p><a href="http://example.com/?a=1&#x26;b=2">title</a></p>'
)

def test_angles_and_nonsense_url(self):
self.assertMarkdownRenders(
'[test nonsense](<?}]*+|&)>).',
'<p><a href="?}]*+|&amp;)">test nonsense</a>.</p>'
)


class TestReferenceLinks(TestCase):

@@ -384,3 +414,23 @@ def test_ref_link_nested_right_bracket(self):
"""
)
)

def test_ref_round_brackets(self):
self.assertMarkdownRenders(
self.dedent(
"""
[Text][1].
[Text][2].
[1]: /url(test) "title"
[2]: </url(test)> "title"
"""
),
self.dedent(
"""
<p><a href="/url(test)" title="title">Text</a>.</p>
<p><a href="/url(test)" title="title">Text</a>.</p>
"""
)
)

0 comments on commit 900e85d

Please sign in to comment.