<commit_before># -*- coding: utf-8 -*-

from __future__ import unicode_literals, absolute_import

# This code is so you can run the samples without installing the package,
# and should be before any import touching nikola, in any file under tests/
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))


from collections import defaultdict
from io import StringIO
import os
import re
import unittest

import mock

from lxml import etree
from .base import LocaleSupportInTesting

import nikola

fake_conf = defaultdict(str)
fake_conf['TIMEZONE'] = 'UTC'
fake_conf['DEFAULT_LANG'] = 'en'
fake_conf['TRANSLATIONS'] = {'en': ''}
fake_conf['BASE_URL'] = 'http://some.blog/'


class FakeCompiler(object):
    demote_headers = False
    compile_html = None


class RSSFeedTest(unittest.TestCase):
    def setUp(self):
        LocaleSupportInTesting.initialize_locales_for_testing('unilingual')

        self.blog_url = "http://some.blog"

        with mock.patch('nikola.post.get_meta',
                        mock.Mock(return_value=({'title': 'post title',
                                                 'slug': 'awesome_article',
                                                 'date': '2012-10-01 22:41',
                                                 'author': None,
                                                 'tags': 'tags', 'link':
                                                 'link', 'description':
                                                 'description'}))):
            with mock.patch('nikola.nikola.utils.os.path.isdir',
                            mock.Mock(return_value=True)):
                with mock.patch('nikola.nikola.Post.text',
                                mock.Mock(return_value='some long text')):

                    example_post = nikola.nikola.Post('source.file',
                                                      fake_conf,
                                                      'blog_folder',
                                                      True,
                                                      {'en': ''},
                                                      'post.tmpl',
                                                      FakeCompiler())

                    opener_mock = mock.mock_open()

                    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",<commit_msg>Fix tests<commit_after># -*- coding: utf-8 -*-

from __future__ import unicode_literals, absolute_import

# This code is so you can run the samples without installing the package,
# and should be before any import touching nikola, in any file under tests/
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))


from collections import defaultdict
from io import StringIO
import os
import re
import unittest

import mock

from lxml import etree
from .base import LocaleSupportInTesting

import nikola

fake_conf = defaultdict(str)
fake_conf['TIMEZONE'] = 'UTC'
fake_conf['DEFAULT_LANG'] = 'en'
fake_conf['TRANSLATIONS'] = {'en': ''}
fake_conf['BASE_URL'] = 'http://some.blog/'


class FakeCompiler(object):
    demote_headers = False
    compile_html = None


class RSSFeedTest(unittest.TestCase):
    def setUp(self):
        LocaleSupportInTesting.initialize_locales_for_testing('unilingual')

        self.blog_url = "http://some.blog"

        with mock.patch('nikola.post.get_meta',
                        mock.Mock(return_value=({'title': 'post title',
                                                 'slug': 'awesome_article',
                                                 'date': '2012-10-01 22:41',
                                                 'author': None,
                                                 'tags': 'tags', 'link':
                                                 'link', 'description':
                                                 'description'}))):
            with mock.patch('nikola.nikola.utils.os.path.isdir',
                            mock.Mock(return_value=True)):
                with mock.patch('nikola.nikola.Post.text',
                                mock.Mock(return_value='some long text')):

                    example_post = nikola.nikola.Post('source.file',
                                                      fake_conf,
                                                      'blog_folder',
                                                      True,
                                                      {'en': ''},
                                                      'post.tmpl',
                                                      FakeCompiler())

                    opener_mock = mock.mock_open()

                    with mock.patch('nikola.nikola.codecs.open', opener_mock, create=True):
                        nikola.nikola.utils.generic_rss_renderer('en',
                                                                 "blog_title",
                                                                 self.blog_url,
                                                                 "blog_description",
{'fraction_non_alphanumeric': 0.09343899741983044, 'fraction_numerical': 0.005160339107998526, 'mean_word_length': 1.1391407173827355, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 60, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4788664', 'n_tokens_mistral': 1226, 'n_tokens_neox': 1167, 'n_words': 266}