aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWaylan Limberg <waylan@gmail.com>2009-03-21 08:52:21 -0400
committerWaylan Limberg <waylan@gmail.com>2009-03-21 08:52:21 -0400
commit38ff334360057383b8d21a3155d1109ff4c59759 (patch)
tree0a8b09dd2d91e16aa77053f0e8f2fd8e6db10084
parentd633e83d818c6198ba26f2265243475c0db1dd58 (diff)
downloadmarkdown-38ff334360057383b8d21a3155d1109ff4c59759.tar.gz
markdown-38ff334360057383b8d21a3155d1109ff4c59759.tar.bz2
markdown-38ff334360057383b8d21a3155d1109ff4c59759.zip
Fixed a bug where Markdown choked on input of only whitespace. Added some tests.
-rw-r--r--markdown/__init__.py2
-rwxr-xr-xregression-tests.py20
2 files changed, 21 insertions, 1 deletions
diff --git a/markdown/__init__.py b/markdown/__init__.py
index ae301b5..af5a2c1 100644
--- a/markdown/__init__.py
+++ b/markdown/__init__.py
@@ -367,7 +367,7 @@ class Markdown:
"""
# Fixup the source text
- if not source:
+ if not source.strip():
return u"" # a blank unicode string
try:
source = unicode(source)
diff --git a/regression-tests.py b/regression-tests.py
index 1b99ff9..7601061 100755
--- a/regression-tests.py
+++ b/regression-tests.py
@@ -12,6 +12,25 @@ from doctest import DocTestSuite
import os
import markdown
+class TestMarkdown(unittest.TestCase):
+ """ Tests basics of the Markdown class. """
+
+ def setUp(self):
+ """ Create instance of Markdown. """
+ self.md = markdown.Markdown()
+
+ def testBlankInput(self):
+ """ Test blank input. """
+ self.assertEqual(self.md.convert(''), '')
+
+ def testWhitespaceOnly(self):
+ """ Test input of only whitespace. """
+ self.assertEqual(self.md.convert(' '), '')
+
+ def testSimpleInput(self):
+ """ Test simple input. """
+ self.assertEqual(self.md.convert('foo'), '<p>foo</p>')
+
class TestBlockParser(unittest.TestCase):
""" Tests of the BlockParser class. """
@@ -196,6 +215,7 @@ class TestOrderedDict(unittest.TestCase):
def suite():
""" Build a test suite of the above tests and extension doctests. """
suite = unittest.TestSuite()
+ suite.addTest(unittest.makeSuite(TestMarkdown))
suite.addTest(unittest.makeSuite(TestBlockParser))
suite.addTest(unittest.makeSuite(TestBlockParserState))
suite.addTest(unittest.makeSuite(TestHtmlStash))