<commit_before>
from __future__ import with_statement
import os
from shutil import rmtree
from uuid import uuid4

from django.conf import settings
from django.template import Context
from django.template.loader import get_template
from django.test import TestCase


TEST_TEMPLATE = """

%(extends_string)s
{%% block main %%}
%(super_string)s
%(test_string)s
{%% endblock %%}

"""


class Tests(TestCase):
    """
    Test that ``overextends`` triggers across multiple project and
    app templates with the same relative path. To achieve this, we
    need same template name to exist in multiple apps, as well as
    at the project level, so we create some fake apps and a project
    template. These all used a unique ID to ensure they don't
    collide with anything in the project. When we're done, we clean
    up our mess.
    """

    def setUp(self):
        """
        Put the test template into a couple of test apps and the project.
        """

        self.root = os.path.dirname(__import__(settings.ROOT_URLCONF).__file__)

        # Add the test apps to INSTALLED_APPS.
        self.unique_id = str(uuid4()).replace("-", "")
        self.test_apps = ["app%s%s" % (i, self.unique_id) for i in range(2)]
        settings.INSTALLED_APPS = list(settings.INSTALLED_APPS)
        settings.INSTALLED_APPS.extend(self.test_apps)

        # Create the app directories with the test template.
        for test_app in self.test_apps:
            app_dir = os.path.join(self.root, test_app)
            os.mkdir(app_dir)
            app_templates = os.path.join(app_dir, "templates")
            os.mkdir(app_templates)
            with open(os.path.join(app_dir, "__init__.py"), "w") as f:
                f.write("")<commit_msg>Add project root to path to try and get travis to run.<commit_after>
from __future__ import with_statement
import os
from shutil import rmtree
import sys
from uuid import uuid4

from django.conf import settings
from django.template import Context
from django.template.loader import get_template
from django.test import TestCase


TEST_TEMPLATE = """

%(extends_string)s
{%% block main %%}
%(super_string)s
%(test_string)s
{%% endblock %%}

"""


class Tests(TestCase):
    """
    Test that ``overextends`` triggers across multiple project and
    app templates with the same relative path. To achieve this, we
    need same template name to exist in multiple apps, as well as
    at the project level, so we create some fake apps and a project
    template. These all used a unique ID to ensure they don't
    collide with anything in the project. When we're done, we clean
    up our mess.
    """

    def setUp(self):
        """
        Put the test template into a couple of test apps and the project.
        """

        self.root = os.path.dirname(__import__(settings.ROOT_URLCONF).__file__)
        sys.path.append(self.root)

        # Add the test apps to INSTALLED_APPS.
        self.unique_id = str(uuid4()).replace("-", "")
        self.test_apps = ["app%s%s" % (i, self.unique_id) for i in range(2)]
        settings.INSTALLED_APPS = list(settings.INSTALLED_APPS)
        settings.INSTALLED_APPS.extend(self.test_apps)

        # Create the app directories with the test template.
        for test_app in self.test_apps:
            app_dir = os.path.join(self.root, test_app)
            os.mkdir(app_dir)
            app_templates = os.path.join(app_dir, "templates")
            os.mkdir(app_templates)
            with open(os.path.join(app_dir, "__init__.py"), "w") as f:
                f.write("")
{'fraction_non_alphanumeric': 0.09456797072896145, 'fraction_numerical': 0.0016887137630171687, 'mean_word_length': 2.867247007616975, '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': '7420571', 'n_tokens_mistral': 1074, 'n_tokens_neox': 1041, 'n_words': 357}