aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_apis.py
diff options
context:
space:
mode:
authorWaylan Limberg <waylan@gmail.com>2010-11-04 20:51:24 -0400
committerWaylan Limberg <waylan@gmail.com>2010-11-04 20:51:24 -0400
commitb32cba5558d964f3445f20bdd44af8ed1cc2df83 (patch)
tree832a7616aad64dfa275a99f330cdca15597c9285 /tests/test_apis.py
parent0fd4a148d942b9056734a6f72201a95da5ca0c05 (diff)
downloadmarkdown-b32cba5558d964f3445f20bdd44af8ed1cc2df83.tar.gz
markdown-b32cba5558d964f3445f20bdd44af8ed1cc2df83.tar.bz2
markdown-b32cba5558d964f3445f20bdd44af8ed1cc2df83.zip
Fixed Ticket 74. AtomicStrings should now be ackowledged (and preserved) in all instances. This was a real pain to debug, but an easy fix once I found it. Thanks to obs for the report.
Diffstat (limited to 'tests/test_apis.py')
-rw-r--r--tests/test_apis.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/test_apis.py b/tests/test_apis.py
index 0de4727..ebbc24f 100644
--- a/tests/test_apis.py
+++ b/tests/test_apis.py
@@ -325,3 +325,48 @@ class testETreeComments(unittest.TestCase):
pretty.run(self.comment)
self.assertEqual(markdown.html4.to_html_string(self.comment),
'<!--foo-->\n')
+
+
+class testAtomicString(unittest.TestCase):
+ """ Test that AtomicStrings are honored (not parsed). """
+
+ def setUp(self):
+ md = markdown.Markdown()
+ self.inlineprocessor = md.treeprocessors['inline']
+
+ def testString(self):
+ """ 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*'
+ new = self.inlineprocessor.run(tree)
+ self.assertEqual(markdown.html4.to_html_string(new),
+ '<div><p>some <em>text</em></p></div>')
+
+ def testSimpleAtomicString(self):
+ """ 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*')
+ new = self.inlineprocessor.run(tree)
+ self.assertEqual(markdown.html4.to_html_string(new),
+ '<div><p>some *text*</p></div>')
+
+ def testNestedAtomicString(self):
+ """ 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* ')
+ span1 = markdown.util.etree.SubElement(p, 'span')
+ span1.text = markdown.util.AtomicString(u'*more* ')
+ span2 = markdown.util.etree.SubElement(span1, 'span')
+ span2.text = markdown.util.AtomicString(u'*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*')
+ new = self.inlineprocessor.run(tree)
+ self.assertEqual(markdown.html4.to_html_string(new),
+ '<div><p>*some* <span>*more* <span>*text* <span>*here*</span> *to*</span> *test*</span> *with*</p></div>')
+