aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorWaylan Limberg <waylan.limberg@icloud.com>2014-08-27 14:59:40 -0400
committerWaylan Limberg <waylan.limberg@icloud.com>2014-08-27 14:59:40 -0400
commite98ac74737c1f28ec730fa5c645062e0e0d5702b (patch)
treeec4400643c52c1441c61d9fe994b574b48170006 /tests
parent44e718ed82ed4c8e8e0f0fe1dbdb73d441747b19 (diff)
downloadmarkdown-e98ac74737c1f28ec730fa5c645062e0e0d5702b.tar.gz
markdown-e98ac74737c1f28ec730fa5c645062e0e0d5702b.tar.bz2
markdown-e98ac74737c1f28ec730fa5c645062e0e0d5702b.zip
Allow named extensions to specify the Class Name
If you were to import the class like this: from path.to.module import SomeExtensionClass Then the named extension would be the string: "path.to.module:SomeExtensionClass" This should simplify loading extensions from the command line or template filters -- expecially when multiple extensions are defined in a single python module. The docs still need updating. I'm waiting to update the docs after implementing #335 and #336 as that will require a major refactor of that section of the docs anyway.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_apis.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/tests/test_apis.py b/tests/test_apis.py
index f0c7f3d..e347cf9 100644
--- a/tests/test_apis.py
+++ b/tests/test_apis.py
@@ -40,6 +40,19 @@ class TestMarkdownBasics(unittest.TestCase):
""" Test simple input. """
self.assertEqual(self.md.convert('foo'), '<p>foo</p>')
+ def testInstanceExtension(self):
+ """ Test Extension loading with a class instance. """
+ from markdown.extensions.footnotes import FootnoteExtension
+ markdown.Markdown(extensions=[FootnoteExtension()])
+
+ def testNamedExtension(self):
+ """ Test Extension loading with Name (`path.to.module`). """
+ markdown.Markdown(extensions=['markdown.extensions.footnotes'])
+
+ def TestNamedExtensionWithClass(self):
+ """ Test Extension loading with class name (`path.to.module:Class`). """
+ markdown.Markdown(extensions=['markdown.extensions.footnotes:FootnoteExtension'])
+
class TestBlockParser(unittest.TestCase):
""" Tests of the BlockParser class. """
@@ -572,7 +585,7 @@ class TestCliOptionParsing(unittest.TestCase):
'end_url': '.html',
'html_class': 'test',
},
- 'footnotes': {
+ 'footnotes:FootnotesExtension': {
'PLACE_MARKER': '~~~footnotes~~~'
}
}
@@ -588,7 +601,7 @@ class TestCliOptionParsing(unittest.TestCase):
'end_url': '.html',
'html_class': 'test',
},
- 'footnotes': {
+ 'footnotes:FootnotesExtension': {
'PLACE_MARKER': '~~~footnotes~~~'
}
}