aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/__init__.py25
-rw-r--r--tests/basic/angle-links-and-img.html2
-rw-r--r--tests/extensions/attr_list.html3
-rw-r--r--tests/extensions/attr_list.txt1
-rw-r--r--tests/extensions/extra/def-in-list.html25
-rw-r--r--tests/extensions/extra/def-in-list.txt15
-rw-r--r--tests/extensions/nl2br_w_attr_list.html1
-rw-r--r--tests/extensions/nl2br_w_attr_list.txt2
-rw-r--r--tests/extensions/test.cfg3
-rw-r--r--tests/misc/attributes-image-ref.html1
-rw-r--r--tests/misc/attributes-image-ref.txt4
-rw-r--r--tests/misc/blank_lines_in_codeblocks.html61
-rw-r--r--tests/misc/blank_lines_in_codeblocks.txt73
-rw-r--r--tests/misc/div.html7
-rw-r--r--tests/misc/div.txt6
-rw-r--r--tests/misc/html.html3
-rw-r--r--tests/misc/two-spaces.html6
-rw-r--r--tests/misc/url_spaces.html4
-rw-r--r--tests/plugins.py4
-rw-r--r--tests/safe_mode/inline-html-simple.html9
-rw-r--r--tests/safe_mode/link-targets.html2
-rw-r--r--tests/safe_mode/link-targets.txt3
-rw-r--r--tests/test_apis.py48
-rw-r--r--tests/test_extensions.py15
-rw-r--r--tests/util.py6
25 files changed, 275 insertions, 54 deletions
diff --git a/tests/__init__.py b/tests/__init__.py
index c790b09..bb56bd4 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -1,4 +1,4 @@
-from __future__ import with_statement
+
import os
import markdown
import codecs
@@ -6,11 +6,11 @@ import difflib
try:
import nose
except ImportError:
- raise ImportError, "The nose testing framework is required to run " \
+ raise ImportError("The nose testing framework is required to run " \
"Python-Markdown tests. Run `easy_install nose` " \
- "to install the latest version."
-import util
-from plugins import HtmlOutput, Markdown
+ "to install the latest version.")
+from . import util
+from .plugins import HtmlOutput, Markdown
try:
import tidy
except ImportError:
@@ -84,21 +84,22 @@ class CheckSyntax(object):
""" Compare expected output to actual output and report result. """
cfg_section = get_section(file, config)
if config.get(cfg_section, 'skip'):
- raise nose.plugins.skip.SkipTest, 'Test skipped per config.'
+ raise nose.plugins.skip.SkipTest('Test skipped per config.')
input_file = file + config.get(cfg_section, 'input_ext')
with codecs.open(input_file, encoding="utf-8") as f:
input = f.read()
output_file = file + config.get(cfg_section, 'output_ext')
with codecs.open(output_file, encoding="utf-8") as f:
- expected_output = f.read()
+ # Normalize line endings (on windows, git may have altered line endings).
+ expected_output = f.read().replace("\r\n", "\n")
output = markdown.markdown(input, **get_args(file, config))
if tidy and config.get(cfg_section, 'normalize'):
- # Normalize whitespace before comparing.
+ # Normalize whitespace with Tidy before comparing.
expected_output = normalize(expected_output)
output = normalize(output)
elif config.get(cfg_section, 'normalize'):
# Tidy is not available. Skip this test.
- raise nose.plugins.skip.SkipTest, 'Test skipped. Tidy not available in system.'
+ raise nose.plugins.skip.SkipTest('Test skipped. Tidy not available in system.')
diff = [l for l in difflib.unified_diff(expected_output.splitlines(True),
output.splitlines(True),
output_file,
@@ -124,17 +125,17 @@ def generate(file, config):
""" Write expected output file for given input. """
cfg_section = get_section(file, config)
if config.get(cfg_section, 'skip'):
- print 'Skipping:', file
+ print('Skipping:', file)
return None
input_file = file + config.get(cfg_section, 'input_ext')
output_file = file + config.get(cfg_section, 'output_ext')
if not os.path.isfile(output_file) or \
os.path.getmtime(output_file) < os.path.getmtime(input_file):
- print 'Generating:', file
+ print('Generating:', file)
markdown.markdownFromFile(input=input_file, output=output_file,
encoding='utf-8', **get_args(file, config))
else:
- print 'Already up-to-date:', file
+ print('Already up-to-date:', file)
def generate_all():
""" Generate expected output for all outdated tests. """
diff --git a/tests/basic/angle-links-and-img.html b/tests/basic/angle-links-and-img.html
index 1ca3b0b..255c299 100644
--- a/tests/basic/angle-links-and-img.html
+++ b/tests/basic/angle-links-and-img.html
@@ -1,4 +1,4 @@
-<p><a href="simple link" title="title">link</a>
+<p><a href="simple%20link" title="title">link</a>
<img alt="image" src="http://example.com/image.jpg" />
<a href="http://example.com/(()((())923)(">link</a>
<img alt="image" src="link(()))(" /></p> \ No newline at end of file
diff --git a/tests/extensions/attr_list.html b/tests/extensions/attr_list.html
index 1e9c182..f50cd6a 100644
--- a/tests/extensions/attr_list.html
+++ b/tests/extensions/attr_list.html
@@ -14,4 +14,5 @@ And a <strong class="nest">nested <a class="linky2" href="http://example.com" ti
{: #someid .someclass }
</code></pre>
<h3 id="hash3">No colon for compatability with Headerid ext</h3>
-<p id="the_end">Also a codespan: <code class="foo">{: .someclass}</code>.</p> \ No newline at end of file
+<p id="the_end">Also a codespan: <code class="foo">{: .someclass}</code>.</p>
+<h3 _:="{:" id="hash5">Bad Syntax</h3> \ No newline at end of file
diff --git a/tests/extensions/attr_list.txt b/tests/extensions/attr_list.txt
index d7ed274..cd7f398 100644
--- a/tests/extensions/attr_list.txt
+++ b/tests/extensions/attr_list.txt
@@ -33,3 +33,4 @@ Now test overrides
Also a codespan: `{: .someclass}`{: .foo}.
{: #the_end}
+### Bad Syntax { {: #hash5 }
diff --git a/tests/extensions/extra/def-in-list.html b/tests/extensions/extra/def-in-list.html
new file mode 100644
index 0000000..21cddaa
--- /dev/null
+++ b/tests/extensions/extra/def-in-list.html
@@ -0,0 +1,25 @@
+<p>: a paragraph that starts with a colon</p>
+<ul>
+<li>A List item</li>
+<li>
+<dl>
+<dt>A def term</dt>
+<dd>A def item</dd>
+<dd>a second</dd>
+</dl>
+</li>
+<li>
+<dl>
+<dt>Another def term</dt>
+<dd>
+<p>a loose item</p>
+</dd>
+<dd>
+<p>a second</p>
+</dd>
+</dl>
+</li>
+<li>
+<p>: a list item that starts with a colon</p>
+</li>
+</ul> \ No newline at end of file
diff --git a/tests/extensions/extra/def-in-list.txt b/tests/extensions/extra/def-in-list.txt
new file mode 100644
index 0000000..7a292ab
--- /dev/null
+++ b/tests/extensions/extra/def-in-list.txt
@@ -0,0 +1,15 @@
+: a paragraph that starts with a colon
+
+* A List item
+*
+ A def term
+ : A def item
+ : a second
+
+* Another def term
+
+ : a loose item
+
+ : a second
+
+* : a list item that starts with a colon
diff --git a/tests/extensions/nl2br_w_attr_list.html b/tests/extensions/nl2br_w_attr_list.html
new file mode 100644
index 0000000..e5e7eb2
--- /dev/null
+++ b/tests/extensions/nl2br_w_attr_list.html
@@ -0,0 +1 @@
+<p id="bar">Foo<br /></p> \ No newline at end of file
diff --git a/tests/extensions/nl2br_w_attr_list.txt b/tests/extensions/nl2br_w_attr_list.txt
new file mode 100644
index 0000000..4b520b5
--- /dev/null
+++ b/tests/extensions/nl2br_w_attr_list.txt
@@ -0,0 +1,2 @@
+Foo
+{: #bar} \ No newline at end of file
diff --git a/tests/extensions/test.cfg b/tests/extensions/test.cfg
index e83aa62..4efd837 100644
--- a/tests/extensions/test.cfg
+++ b/tests/extensions/test.cfg
@@ -30,5 +30,8 @@ extensions=fenced_code
[sane_lists]
extensions=sane_lists
+[nl2br_w_attr_list]
+extensions=nl2br,attr_list
+
[admonition]
extensions=admonition
diff --git a/tests/misc/attributes-image-ref.html b/tests/misc/attributes-image-ref.html
new file mode 100644
index 0000000..6974420
--- /dev/null
+++ b/tests/misc/attributes-image-ref.html
@@ -0,0 +1 @@
+<p><img alt="img" id="foo" src="http://example.com/i.jpg" /></p> \ No newline at end of file
diff --git a/tests/misc/attributes-image-ref.txt b/tests/misc/attributes-image-ref.txt
new file mode 100644
index 0000000..a216971
--- /dev/null
+++ b/tests/misc/attributes-image-ref.txt
@@ -0,0 +1,4 @@
+![img{@id=foo}][img]
+
+ [img]: http://example.com/i.jpg
+
diff --git a/tests/misc/blank_lines_in_codeblocks.html b/tests/misc/blank_lines_in_codeblocks.html
new file mode 100644
index 0000000..57a4c36
--- /dev/null
+++ b/tests/misc/blank_lines_in_codeblocks.html
@@ -0,0 +1,61 @@
+<p>Preserve blank lines in code blocks with tabs:</p>
+<pre><code>a code block
+
+two tabbed lines
+
+
+three tabbed lines
+
+
+
+four tabbed lines
+
+
+
+
+five tabbed lines
+
+
+
+
+
+six tabbed lines
+
+
+
+
+
+
+End of tabbed block
+</code></pre>
+<p>And without tabs:</p>
+<pre><code>a code block
+
+two blank lines
+
+
+three blank lines
+
+
+
+four blank lines
+
+
+
+
+five blank lines
+
+
+
+
+
+six blank lines
+
+
+
+
+
+
+End of block
+</code></pre>
+<p>End of document</p> \ No newline at end of file
diff --git a/tests/misc/blank_lines_in_codeblocks.txt b/tests/misc/blank_lines_in_codeblocks.txt
new file mode 100644
index 0000000..e7ae102
--- /dev/null
+++ b/tests/misc/blank_lines_in_codeblocks.txt
@@ -0,0 +1,73 @@
+Preserve blank lines in code blocks with tabs:
+
+ a code block
+
+ two tabbed lines
+
+
+ three tabbed lines
+
+
+
+ four tabbed lines
+
+
+
+
+ five tabbed lines
+
+
+
+
+
+ six tabbed lines
+
+
+
+
+
+
+ End of tabbed block
+
+
+
+
+
+
+And without tabs:
+
+ a code block
+
+ two blank lines
+
+
+ three blank lines
+
+
+
+ four blank lines
+
+
+
+
+ five blank lines
+
+
+
+
+
+ six blank lines
+
+
+
+
+
+
+ End of block
+
+
+
+
+
+
+End of document \ No newline at end of file
diff --git a/tests/misc/div.html b/tests/misc/div.html
index 7b68854..cb6a759 100644
--- a/tests/misc/div.html
+++ b/tests/misc/div.html
@@ -2,4 +2,9 @@
_foo_
-</div> \ No newline at end of file
+</div>
+
+<p>And now in uppercase:</p>
+<DIV>
+foo
+</DIV> \ No newline at end of file
diff --git a/tests/misc/div.txt b/tests/misc/div.txt
index ca87745..4ff972e 100644
--- a/tests/misc/div.txt
+++ b/tests/misc/div.txt
@@ -3,3 +3,9 @@
_foo_
</div>
+
+And now in uppercase:
+
+<DIV>
+foo
+</DIV>
diff --git a/tests/misc/html.html b/tests/misc/html.html
index c72bb81..1eb6a97 100644
--- a/tests/misc/html.html
+++ b/tests/misc/html.html
@@ -1,7 +1,6 @@
<h1>Block level html</h1>
-<p>Some inline <b>stuff<b>.<br />
-</p>
+<p>Some inline <b>stuff<b>. </p>
<p>Now some <arbitrary>arbitrary tags</arbitrary>.</p>
<div>More block level html.</div>
diff --git a/tests/misc/two-spaces.html b/tests/misc/two-spaces.html
index 102d1db..97b54b4 100644
--- a/tests/misc/two-spaces.html
+++ b/tests/misc/two-spaces.html
@@ -4,14 +4,12 @@ but this line has three <br />
and this is the second from last line
in this test message</p>
<ul>
-<li>This list item has two spaces.<br />
-</li>
+<li>This list item has two spaces. </li>
<li>
<p>This has none.
This line has three. <br />
This line has none.
- And this line two.<br />
-</p>
+ And this line two. </p>
<p>This line has none.</p>
</li>
<li>
diff --git a/tests/misc/url_spaces.html b/tests/misc/url_spaces.html
index ebacb75..f9c91b3 100644
--- a/tests/misc/url_spaces.html
+++ b/tests/misc/url_spaces.html
@@ -1,2 +1,2 @@
-<p><a href="http://wikipedia.org/wiki/Dawn of War">Dawn of War</a></p>
-<p><a href="http://wikipedia.org/wiki/Dawn of War" title="Dawn of War">Dawn of War</a></p> \ No newline at end of file
+<p><a href="http://wikipedia.org/wiki/Dawn%20of%20War">Dawn of War</a></p>
+<p><a href="http://wikipedia.org/wiki/Dawn%20of%20War" title="Dawn of War">Dawn of War</a></p> \ No newline at end of file
diff --git a/tests/plugins.py b/tests/plugins.py
index 6e72024..bbeed60 100644
--- a/tests/plugins.py
+++ b/tests/plugins.py
@@ -1,5 +1,5 @@
import traceback
-from util import MarkdownSyntaxError
+from .util import MarkdownSyntaxError
from nose.plugins import Plugin
from nose.plugins.errorclass import ErrorClass, ErrorClassPlugin
@@ -73,7 +73,7 @@ or ""))
self.html.extend(['<span>FAILED (',
'failures=%d ' % len(result.failures),
'errors=%d' % len(result.errors)])
- for cls in result.errorClasses.keys():
+ for cls in list(result.errorClasses.keys()):
storage, label, isfail = result.errorClasses[cls]
if len(storage):
self.html.append(' %ss=%d' % (label, len(storage)))
diff --git a/tests/safe_mode/inline-html-simple.html b/tests/safe_mode/inline-html-simple.html
index 981c3a2..1e5df17 100644
--- a/tests/safe_mode/inline-html-simple.html
+++ b/tests/safe_mode/inline-html-simple.html
@@ -29,8 +29,7 @@ Blah
<pre><code>&lt;!-- Comment --&gt;
</code></pre>
<p>Just plain comment, with trailing spaces on the line:</p>
-<p>&lt;!-- foo --&gt; <br />
-</p>
+<p>&lt;!-- foo --&gt; </p>
<p>Code:</p>
<pre><code>&lt;hr /&gt;
</code></pre>
@@ -38,10 +37,8 @@ Blah
<p>&lt;hr&gt;</p>
<p>&lt;hr/&gt;</p>
<p>&lt;hr /&gt;</p>
-<p>&lt;hr&gt; <br />
-</p>
-<p>&lt;hr/&gt;<br />
-</p>
+<p>&lt;hr&gt; </p>
+<p>&lt;hr/&gt; </p>
<p>&lt;hr /&gt; </p>
<p>&lt;hr class="foo" id="bar" /&gt;</p>
<p>&lt;hr class="foo" id="bar"/&gt;</p>
diff --git a/tests/safe_mode/link-targets.html b/tests/safe_mode/link-targets.html
new file mode 100644
index 0000000..768ae5b
--- /dev/null
+++ b/tests/safe_mode/link-targets.html
@@ -0,0 +1,2 @@
+<p><a href="">XSS</a>
+See http://security.stackexchange.com/q/30330/1261 for details.</p> \ No newline at end of file
diff --git a/tests/safe_mode/link-targets.txt b/tests/safe_mode/link-targets.txt
new file mode 100644
index 0000000..10eebda
--- /dev/null
+++ b/tests/safe_mode/link-targets.txt
@@ -0,0 +1,3 @@
+[XSS](javascript://%0Aalert%28'XSS'%29;)
+See http://security.stackexchange.com/q/30330/1261 for details.
+
diff --git a/tests/test_apis.py b/tests/test_apis.py
index b39664a..e0f7a03 100644
--- a/tests/test_apis.py
+++ b/tests/test_apis.py
@@ -7,6 +7,7 @@ Tests of the various APIs with the python markdown lib.
"""
+from __future__ import unicode_literals
import unittest
import os
import sys
@@ -14,6 +15,8 @@ import types
import markdown
import warnings
+PY3 = sys.version_info[0] == 3
+
class TestMarkdownBasics(unittest.TestCase):
""" Tests basics of the Markdown class. """
@@ -140,51 +143,51 @@ class TestOrderedDict(unittest.TestCase):
def testValues(self):
""" Test output of OrderedDict.values(). """
- self.assertEqual(self.odict.values(), ['This', 'a', 'self', 'test'])
+ self.assertEqual(list(self.odict.values()), ['This', 'a', 'self', 'test'])
def testKeys(self):
""" Test output of OrderedDict.keys(). """
- self.assertEqual(self.odict.keys(),
+ self.assertEqual(list(self.odict.keys()),
['first', 'third', 'fourth', 'fifth'])
def testItems(self):
""" Test output of OrderedDict.items(). """
- self.assertEqual(self.odict.items(),
+ self.assertEqual(list(self.odict.items()),
[('first', 'This'), ('third', 'a'),
('fourth', 'self'), ('fifth', 'test')])
def testAddBefore(self):
""" Test adding an OrderedDict item before a given key. """
self.odict.add('second', 'is', '<third')
- self.assertEqual(self.odict.items(),
+ self.assertEqual(list(self.odict.items()),
[('first', 'This'), ('second', 'is'), ('third', 'a'),
('fourth', 'self'), ('fifth', 'test')])
def testAddAfter(self):
""" Test adding an OrderDict item after a given key. """
self.odict.add('second', 'is', '>first')
- self.assertEqual(self.odict.items(),
+ self.assertEqual(list(self.odict.items()),
[('first', 'This'), ('second', 'is'), ('third', 'a'),
('fourth', 'self'), ('fifth', 'test')])
def testAddAfterEnd(self):
""" Test adding an OrderedDict item after the last key. """
self.odict.add('sixth', '.', '>fifth')
- self.assertEqual(self.odict.items(),
+ self.assertEqual(list(self.odict.items()),
[('first', 'This'), ('third', 'a'),
('fourth', 'self'), ('fifth', 'test'), ('sixth', '.')])
def testAdd_begin(self):
""" Test adding an OrderedDict item using "_begin". """
self.odict.add('zero', 'CRAZY', '_begin')
- self.assertEqual(self.odict.items(),
+ self.assertEqual(list(self.odict.items()),
[('zero', 'CRAZY'), ('first', 'This'), ('third', 'a'),
('fourth', 'self'), ('fifth', 'test')])
def testAdd_end(self):
""" Test adding an OrderedDict item using "_end". """
self.odict.add('sixth', '.', '_end')
- self.assertEqual(self.odict.items(),
+ self.assertEqual(list(self.odict.items()),
[('first', 'This'), ('third', 'a'),
('fourth', 'self'), ('fifth', 'test'), ('sixth', '.')])
@@ -196,20 +199,20 @@ class TestOrderedDict(unittest.TestCase):
def testDeleteItem(self):
""" Test deletion of an OrderedDict item. """
del self.odict['fourth']
- self.assertEqual(self.odict.items(),
+ self.assertEqual(list(self.odict.items()),
[('first', 'This'), ('third', 'a'), ('fifth', 'test')])
def testChangeValue(self):
""" Test OrderedDict change value. """
self.odict['fourth'] = 'CRAZY'
- self.assertEqual(self.odict.items(),
+ self.assertEqual(list(self.odict.items()),
[('first', 'This'), ('third', 'a'),
('fourth', 'CRAZY'), ('fifth', 'test')])
def testChangeOrder(self):
""" Test OrderedDict change order. """
self.odict.link('fourth', '<third')
- self.assertEqual(self.odict.items(),
+ self.assertEqual(list(self.odict.items()),
[('first', 'This'), ('fourth', 'self'),
('third', 'a'), ('fifth', 'test')])
@@ -217,7 +220,7 @@ class TestOrderedDict(unittest.TestCase):
""" Test OrderedDict change order with bad location. """
self.assertRaises(ValueError, self.odict.link('fourth', '<bad'))
# Check for data integrity ("fourth" wasn't deleted).'
- self.assertEqual(self.odict.items(),
+ self.assertEqual(list(self.odict.items()),
[('first', 'This'), ('third', 'a'),
('fourth', 'self'), ('fifth', 'test')])
@@ -267,6 +270,9 @@ class TestErrors(unittest.TestCase):
def _create_fake_extension(name, has_factory_func=True, is_wrong_type=False):
""" Create a fake extension module for testing. """
mod_name = '_'.join(['mdx', name])
+ if not PY3:
+ # mod_name must be bytes in Python 2.x
+ mod_name = bytes(mod_name)
ext_mod = types.ModuleType(mod_name)
def makeExtension(configs=None):
if is_wrong_type:
@@ -332,7 +338,7 @@ class testAtomicString(unittest.TestCase):
""" Test that a regular string is parsed. """
tree = markdown.util.etree.Element('div')
p = markdown.util.etree.SubElement(tree, 'p')
- p.text = u'some *text*'
+ p.text = 'some *text*'
new = self.inlineprocessor.run(tree)
self.assertEqual(markdown.serializers.to_html_string(new),
'<div><p>some <em>text</em></p></div>')
@@ -341,7 +347,7 @@ class testAtomicString(unittest.TestCase):
""" Test that a simple AtomicString is not parsed. """
tree = markdown.util.etree.Element('div')
p = markdown.util.etree.SubElement(tree, 'p')
- p.text = markdown.util.AtomicString(u'some *text*')
+ p.text = markdown.util.AtomicString('some *text*')
new = self.inlineprocessor.run(tree)
self.assertEqual(markdown.serializers.to_html_string(new),
'<div><p>some *text*</p></div>')
@@ -350,16 +356,16 @@ class testAtomicString(unittest.TestCase):
""" Test that a nested AtomicString is not parsed. """
tree = markdown.util.etree.Element('div')
p = markdown.util.etree.SubElement(tree, 'p')
- p.text = markdown.util.AtomicString(u'*some* ')
+ p.text = markdown.util.AtomicString('*some* ')
span1 = markdown.util.etree.SubElement(p, 'span')
- span1.text = markdown.util.AtomicString(u'*more* ')
+ span1.text = markdown.util.AtomicString('*more* ')
span2 = markdown.util.etree.SubElement(span1, 'span')
- span2.text = markdown.util.AtomicString(u'*text* ')
+ span2.text = markdown.util.AtomicString('*text* ')
span3 = markdown.util.etree.SubElement(span2, 'span')
- span3.text = markdown.util.AtomicString(u'*here*')
- span3.tail = markdown.util.AtomicString(u' *to*')
- span2.tail = markdown.util.AtomicString(u' *test*')
- span1.tail = markdown.util.AtomicString(u' *with*')
+ span3.text = markdown.util.AtomicString('*here*')
+ span3.tail = markdown.util.AtomicString(' *to*')
+ span2.tail = markdown.util.AtomicString(' *test*')
+ span1.tail = markdown.util.AtomicString(' *with*')
new = self.inlineprocessor.run(tree)
self.assertEqual(markdown.serializers.to_html_string(new),
'<div><p>*some* <span>*more* <span>*text* <span>*here*</span> '
diff --git a/tests/test_extensions.py b/tests/test_extensions.py
index 7661347..fd77e5e 100644
--- a/tests/test_extensions.py
+++ b/tests/test_extensions.py
@@ -7,6 +7,7 @@ continue to work as advertised. This used to be accomplished by doctests.
"""
+from __future__ import unicode_literals
import unittest
import markdown
@@ -47,7 +48,7 @@ class TestCodeHilite(unittest.TestCase):
'</pre></div>')
else:
self.assertEqual(self.md.convert(text),
- '<pre><code>Code\n'
+ '<pre class="codehilite"><code># A Code Comment'
'</code></pre>')
@@ -171,6 +172,18 @@ header_forceid: Off
self.assertEqual(markdown.markdown(text, ['headerid', 'meta']),
'<h2>A Header</h2>')
+ def testHeaderIdWithAttr_List(self):
+ """ Test HeaderIDs with Attr_List extension. """
+
+ text = '# Header1 {: #foo }\n# Header2 {: .bar }'
+ self.assertEqual(markdown.markdown(text, ['headerid', 'attr_list']),
+ '<h1 id="foo">Header1</h1>\n'
+ '<h1 class="bar" id="header2">Header2</h1>')
+ # Switch order extensions are loaded - should be no change in behavior.
+ self.assertEqual(markdown.markdown(text, ['attr_list', 'headerid']),
+ '<h1 id="foo">Header1</h1>\n'
+ '<h1 class="bar" id="header2">Header2</h1>')
+
class TestMetaData(unittest.TestCase):
""" Test MetaData extension. """
diff --git a/tests/util.py b/tests/util.py
index 6690eed..bbf7aea 100644
--- a/tests/util.py
+++ b/tests/util.py
@@ -1,4 +1,8 @@
-from ConfigParser import SafeConfigParser
+import sys
+if sys.version_info[0] == 3:
+ from configparser import SafeConfigParser
+else:
+ from ConfigParser import SafeConfigParser
class MarkdownSyntaxError(Exception):
pass