From d4294e1250fac05645ffabb998245c5870a4af8c Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Fri, 29 Oct 2010 21:37:59 -0400 Subject: Fixed Ticket 80. Added support for ElementTree Comments to be included by third party extensions when using cElementTree. --- tests/test_apis.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'tests/test_apis.py') diff --git a/tests/test_apis.py b/tests/test_apis.py index 51f4e73..114b09d 100644 --- a/tests/test_apis.py +++ b/tests/test_apis.py @@ -285,3 +285,39 @@ def _create_fake_extension(name, has_factory_func=True, is_wrong_type=False): # this needs to be specificly overriden or a new python session needs to # be started to get rid of this. This should be ok in a testing context. sys.modules[mod_name] = ext_mod + + +class testETreeComments(unittest.TestCase): + """ + Test that ElementTree Comments work. + + These tests should only be a concern when using cElementTree with third + party serializers (including markdown's html4 serializer). While markdown + doesn't use ElementTree.Comment itself, we should certainly support any + third party extensions which may. Therefore, these tests are included to + ensure such support is maintained. + """ + + def setUp(self): + # Create comment node + self.comment = markdown.util.etree.Comment('foo') + + def testCommentIsComment(self): + """ Test that an ElementTree Comment passes the `is Comment` test. """ + self.assert_(self.comment.tag is markdown.util.etree.Comment) + + def testCommentIsBlockLevel(self): + """ Test that an ElementTree Comment is recognized as BlockLevel. """ + self.assert_(markdown.util.isBlockLevel(self.comment.tag)) + + def testCommentSerialization(self): + """ Test that an ElementTree Comment serializes properly. """ + self.assertEqual(markdown.html4.to_html_string(self.comment), + '') + + def testCommentPrettify(self): + """ Test that an ElementTree Comment is prettified properly. """ + pretty = markdown.treeprocessors.PrettifyTreeprocessor() + pretty.run(self.comment) + self.assertEqual(markdown.html4.to_html_string(self.comment), + '\n') -- cgit v1.2.3