From 5724c569b18c7d619fa09293271ee7f0b95d2f1a Mon Sep 17 00:00:00 2001 From: Russel Mahmud Date: Thu, 3 Mar 2016 14:44:56 +0600 Subject: [PATCH] Fix atom content type CDATA --- feedgen/entry.py | 2 +- feedgen/tests/test_entry.py | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/feedgen/entry.py b/feedgen/entry.py index bf50357..d618ebf 100644 --- a/feedgen/entry.py +++ b/feedgen/entry.py @@ -104,7 +104,7 @@ class FeedEntry(object): xmlns="http://www.w3.org/1999/xhtml">%s''' % \ self.__atom_content.get('content'))) elif type == 'CDATA': - content.text = etree.CDATA(self.__atom_content) + content.text = etree.CDATA(self.__atom_content.get('content')) # Emed the text in escaped form elif not type or type.startswith('text') or type == 'html': content.text = self.__atom_content.get('content') diff --git a/feedgen/tests/test_entry.py b/feedgen/tests/test_entry.py index d2fef27..8e4ca0d 100644 --- a/feedgen/tests/test_entry.py +++ b/feedgen/tests/test_entry.py @@ -92,3 +92,15 @@ class TestSequenceFunctions(unittest.TestCase): result = fg.rss_str() assert b'domain="http://www.somedomain.com/category"' in result + + def test_content_cdata_type(self): + fg = FeedGenerator() + fg.title('some title') + fg.id('http://lernfunk.de/media/654322/1') + fe = fg.add_entry() + fe.id('http://lernfunk.de/media/654322/1') + fe.title('some title') + fe.content('content', type='CDATA') + result = fg.atom_str() + assert b'' in result +