aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWaylan Limberg <waylan@gmail.com>2008-10-14 21:52:15 -0400
committerWaylan Limberg <waylan@gmail.com>2008-10-14 21:52:15 -0400
commit497932647e2bb489ce29c9cefd549e10f752757d (patch)
treee0126a32e1e361648e2fa90bf7474201ea0d1ae2
parent8e1d6f83826b2ef85534b9158b7a28914bc65b68 (diff)
downloadmarkdown-497932647e2bb489ce29c9cefd549e10f752757d.tar.gz
markdown-497932647e2bb489ce29c9cefd549e10f752757d.tar.bz2
markdown-497932647e2bb489ce29c9cefd549e10f752757d.zip
Added extension doctests to the regression tests and fixed a few broken doctests in CodeHilite and WikiLinks extentions.
-rw-r--r--markdown_extensions/codehilite.py4
-rw-r--r--markdown_extensions/wikilinks.py8
-rwxr-xr-xregression-tests.py21
3 files changed, 24 insertions, 9 deletions
diff --git a/markdown_extensions/codehilite.py b/markdown_extensions/codehilite.py
index 89de58b..9371e79 100644
--- a/markdown_extensions/codehilite.py
+++ b/markdown_extensions/codehilite.py
@@ -36,7 +36,7 @@ class CodeHilite:
Determine language of source code, and pass it into the pygments hilighter.
Basic Usage:
- >>> code = CodeHilite(src = text)
+ >>> code = CodeHilite(src = 'some text')
>>> html = code.hilite()
* src: Source string or any object with a .readline attribute.
@@ -47,7 +47,7 @@ class CodeHilite:
Low Level Usage:
>>> code = CodeHilite()
- >>> code.src = text # String or anything with a .readline attribute
+ >>> code.src = 'some text' # String or anything with a .readline attr.
>>> code.linenos = True # True or False; Turns line numbering on or of.
>>> html = code.hilite()
diff --git a/markdown_extensions/wikilinks.py b/markdown_extensions/wikilinks.py
index 0d06100..0caeb48 100644
--- a/markdown_extensions/wikilinks.py
+++ b/markdown_extensions/wikilinks.py
@@ -12,7 +12,7 @@ Basic usage:
>>> text = "Some text with a [[WikiLink]]."
>>> html = markdown.markdown(text, ['wikilinks'])
>>> html
- u'<p>Some text with a <a href="/WikiLink/" class="wikilink">WikiLink</a>.</p>'
+ u'<p>Some text with a <a class="wikilink" href="/WikiLink/">WikiLink</a>.</p>'
Whitespace behavior:
@@ -26,7 +26,7 @@ To define custom settings the simple way:
>>> markdown.markdown(text,
... ['wikilinks(base_url=/wiki/,end_url=.html,html_class=foo)']
... )
- u'<p>Some text with a <a href="/wiki/WikiLink.html" class="foo">WikiLink</a>.</p>'
+ u'<p>Some text with a <a class="foo" href="/wiki/WikiLink.html">WikiLink</a>.</p>'
Custom settings the complex way:
@@ -46,7 +46,7 @@ Use MetaData with mdx_meta.py (Note the blank html_class in MetaData):
... wiki_end_url: .html
... wiki_html_class:
...
- ... Some text with a WikiLink."""
+ ... Some text with a [[WikiLink]]."""
>>> md = markdown.Markdown(extensions=['meta', 'wikilinks'])
>>> md.convert(text)
u'<p>Some text with a <a href="http://example.com/WikiLink.html">WikiLink</a>.</p>'
@@ -54,7 +54,7 @@ Use MetaData with mdx_meta.py (Note the blank html_class in MetaData):
MetaData should not carry over to next document:
>>> md.convert("No [[MetaData]] here.")
- u'<p>No <a href="/MetaData/" class="wikilink">MetaData</a> here.</p>'
+ u'<p>No <a class="wikilink" href="/MetaData/">MetaData</a> here.</p>'
From the command line:
diff --git a/regression-tests.py b/regression-tests.py
index 71b090a..a53c639 100755
--- a/regression-tests.py
+++ b/regression-tests.py
@@ -8,6 +8,8 @@ Tests of the various APIs with the python markdown lib.
"""
import unittest
+from doctest import DocTestSuite
+import os
import markdown
class TestMarkdownParser(unittest.TestCase):
@@ -73,7 +75,7 @@ class TestHtmlStash(unittest.TestCase):
self.assertEqual(self.stash.html_counter, 0)
self.assertEqual(self.stash.rawHtmlBlocks, [])
-class testTreap(unittest.TestCase):
+class TestTreap(unittest.TestCase):
""" Test Treap storage class. """
def setUp(self):
@@ -135,6 +137,19 @@ class testTreap(unittest.TestCase):
[('first', 'This'), ('second', 'is'), ('third', 'a'),
('fourth', 'self'), ('seventh','.'), ('fifth', 'test')])
-if __name__ == '__main__':
- unittest.main()
+suite = unittest.TestSuite()
+suite.addTest(unittest.makeSuite(TestMarkdownParser))
+suite.addTest(unittest.makeSuite(TestHtmlStash))
+suite.addTest(unittest.makeSuite(TestTreap))
+
+for filename in os.listdir('markdown_extensions'):
+ if filename.endswith('.py'):
+ module = 'markdown_extensions.%s' % filename[:-3]
+ try:
+ suite.addTest(DocTestSuite(module))
+ except: ValueError
+ # No tests
+if __name__ == '__main__':
+ #unittest.main()
+ unittest.TextTestRunner().run(suite)