Debian Codegraph @

tests/test_legacy.py

raw
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-2023 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 LegacyTestCase, Kwargs
23 import os
24 import warnings
25
26 # Warnings should cause tests to fail...
27 warnings.simplefilter('error')
28 # Except for the warnings that shouldn't
29 warnings.filterwarnings('default', category=PendingDeprecationWarning)
30 warnings.filterwarnings('default', category=DeprecationWarning, module='markdown')
31
32 parent_test_dir = os.path.abspath(os.path.dirname(__file__))
33
34
35 class TestBasic(LegacyTestCase):
36 location = os.path.join(parent_test_dir, 'basic')
37
38
39 class TestMisc(LegacyTestCase):
40 location = os.path.join(parent_test_dir, 'misc')
41
42
43 class TestPhp(LegacyTestCase):
44 """
45 Notes on "excluded" tests:
46
47 Quotes in attributes: attributes get output in different order
48
49 Inline HTML (Span): Backtick in raw HTML attribute TODO: fix me
50
51 Backslash escapes: Weird whitespace issue in output
52
53 `Ins` & `del`: Our behavior follows `markdown.pl`. I think PHP is wrong here
54
55 Auto Links: TODO: fix raw HTML so is doesn't match <[email protected]> as a `<hr>`.
56
57 Empty List Item: We match `markdown.pl` here. Maybe someday we'll support this
58
59 Headers: TODO: fix headers to not require blank line before
60
61 Mixed `OL`s and `UL`s: We match `markdown.pl` here. I think PHP is wrong here
62
63 Emphasis: We have various minor differences in combined & incorrect em markup.
64 Maybe fix a few of them - but most aren't too important
65
66 Code block in a list item: We match `markdown.pl` - not sure how PHP gets that output??
67
68 PHP-Specific Bugs: Not sure what to make of the escaping stuff here.
69 Why is PHP not removing a backslash?
70 """
71 location = os.path.join(parent_test_dir, 'php')
72 normalize = True
73 input_ext = '.text'
74 output_ext = '.xhtml'
75 exclude = [
76 'Quotes_in_attributes',
77 'Inline_HTML_(Span)',
78 'Backslash_escapes',
79 'Ins_&_del',
80 'Auto_Links',
81 'Empty_List_Item',
82 'Headers',
83 'Mixed_OLs_and_ULs',
84 'Emphasis',
85 'Code_block_in_a_list_item',
86 'PHP_Specific_Bugs'
87 ]
88
89
90 class TestPl2004(LegacyTestCase):
91 location = os.path.join(parent_test_dir, 'pl/Tests_2004')
92 normalize = True
93 input_ext = '.text'
94 exclude = ['Yuri_Footnotes', 'Yuri_Attributes']
95
96
97 class TestPl2007(LegacyTestCase):
98 """
99 Notes on "excluded" tests:
100
101 Images: the attributes don't get ordered the same so we skip this
102
103 Code Blocks: some weird whitespace issue
104
105 Links, reference style: weird issue with nested brackets TODO: fix me
106
107 Backslash escapes: backticks in raw html attributes TODO: fix me
108
109 Code Spans: more backticks in raw html attributes TODO: fix me
110 """
111 location = os.path.join(parent_test_dir, 'pl/Tests_2007')
112 normalize = True
113 input_ext = '.text'
114 exclude = [
115 'Images',
116 'Code_Blocks',
117 'Links,_reference_style',
118 'Backslash_escapes',
119 'Code_Spans'
120 ]
121
122
123 class TestExtensions(LegacyTestCase):
124 location = os.path.join(parent_test_dir, 'extensions')
125 exclude = ['codehilite']
126
127 attr_list = Kwargs(extensions=['attr_list', 'def_list', 'smarty'])
128
129 codehilite = Kwargs(extensions=['codehilite'])
130
131 toc = Kwargs(extensions=['toc'])
132
133 toc_invalid = Kwargs(extensions=['toc'])
134
135 toc_out_of_order = Kwargs(extensions=['toc'])
136
137 toc_nested = Kwargs(
138 extensions=['toc'],
139 extension_configs={'toc': {'permalink': True}}
140 )
141
142 toc_nested2 = Kwargs(
143 extensions=['toc'],
144 extension_configs={'toc': {'permalink': "[link]"}}
145 )
146
147 toc_nested_list = Kwargs(extensions=['toc'])
148
149 wikilinks = Kwargs(extensions=['wikilinks'])
150
151 github_flavored = Kwargs(extensions=['fenced_code'])
152
153 sane_lists = Kwargs(extensions=['sane_lists'])
154
155 nl2br_w_attr_list = Kwargs(extensions=['nl2br', 'attr_list'])
156
157 admonition = Kwargs(extensions=['admonition'])
158
159
160 class TestExtensionsExtra(LegacyTestCase):
161 location = os.path.join(parent_test_dir, 'extensions/extra')
162 default_kwargs = Kwargs(extensions=['extra'])
163
164 loose_def_list = Kwargs(extensions=['def_list'])
165
166 simple_def_lists = Kwargs(extensions=['def_list'])
167
168 abbr = Kwargs(extensions=['abbr'])
169
170 footnotes = Kwargs(extensions=['footnotes'])
171
172 extra_config = Kwargs(
173 extensions=['extra'],
174 extension_configs={
175 'extra': {
176 'footnotes': {
177 'PLACE_MARKER': '~~~placemarker~~~'
178 }
179 }
180 }
181 )