aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_rss_feeds.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_rss_feeds.py')
-rw-r--r--tests/test_rss_feeds.py30
1 files changed, 23 insertions, 7 deletions
diff --git a/tests/test_rss_feeds.py b/tests/test_rss_feeds.py
index 2b48f36..ae1cd41 100644
--- a/tests/test_rss_feeds.py
+++ b/tests/test_rss_feeds.py
@@ -1,9 +1,10 @@
# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
import unittest
import os
import re
-from StringIO import StringIO
+from io import StringIO
import mock
@@ -32,21 +33,36 @@ class RSSFeedTest(unittest.TestCase):
{'en': ''},
'en',
self.blog_url,
- 'unused message.')
+ 'unused message.',
+ 'post.tmpl')
opener_mock = mock.mock_open()
- with mock.patch('nikola.nikola.utils.open', opener_mock, create=True):
+ with mock.patch('nikola.nikola.utils.codecs.open', opener_mock, create=True):
nikola.nikola.utils.generic_rss_renderer('en',
"blog_title",
self.blog_url,
"blog_description",
[example_post,
],
- 'testfeed.rss')
-
- self.file_content = ''.join(
- [call[1][0] for call in opener_mock.mock_calls[2:-1]])
+ 'testfeed.rss',
+ True)
+
+ opener_mock.assert_called_once_with(
+ 'testfeed.rss', 'wb+', 'utf-8')
+
+ # Python 3 / unicode strings workaround
+ # lxml will complain if the encoding is specified in the
+ # xml when running with unicode strings.
+ # We do not include this in our content.
+ open_handle = opener_mock()
+ file_content = [call[1][0]
+ for call in open_handle.mock_calls[1:-1]][0]
+ splitted_content = file_content.split('\n')
+ self.encoding_declaration = splitted_content[0]
+ content_without_encoding_declaration = splitted_content[1:]
+ self.file_content = '\n'.join(
+ content_without_encoding_declaration)
def tearDown(self):
pass