<commit_before>import os
import tempfile

from django.conf import settings
from django.test import TestCase
from django.contrib.auth.models import User

from django_webtest import WebTest


class MockTemplateMixin(object):

    def setUp(self):
        tempdir = tempfile.gettempdir()
        self.default_template_dirs = settings.TEMPLATE_DIRS
        settings.TEMPLATE_DIRS = list(settings.TEMPLATE_DIRS) + [tempdir]
        self.template_name = 'test_article_page.html'
        self.template_file = os.path.join(tempdir, self.template_name)

    def tearDown(self):
        # make sure that other tests don't rely on these settings
        settings.TEMPLATE_DIRS = self.default_template_dirs

    def prepare_template_file(self, content):
        with open(self.template_file, 'w') as tmpl_file:
            tmpl_file.write(content)<commit_msg>Add cleanup of templates in tests<commit_after>import os
import tempfile

from django.conf import settings
from django.test import TestCase
from django.contrib.auth.models import User

from django_webtest import WebTest


class MockTemplateMixin(object):

    def setUp(self):
        tempdir = tempfile.gettempdir()
        self.default_template_dirs = settings.TEMPLATE_DIRS
        settings.TEMPLATE_DIRS = list(settings.TEMPLATE_DIRS) + [tempdir]
        self.template_name = 'test_article_page.html'
        self.template_file = os.path.join(tempdir, self.template_name)

    def tearDown(self):
        os.remvoe(self.template_file)
        # make sure that other tests don't rely on these settings
        settings.TEMPLATE_DIRS = self.default_template_dirs

    def prepare_template_file(self, content):
        with open(self.template_file, 'w') as tmpl_file:
            tmpl_file.write(content)
{'fraction_non_alphanumeric': 0.07534246575342465, 'fraction_numerical': 0.0, 'mean_word_length': 3.62532981530343, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5495783', 'n_tokens_mistral': 534, 'n_tokens_neox': 522, 'n_words': 123}