<commit_before>import unittest

from django.template import (
    Context,
    Template
)
from django.conf import settings
settings.configure()
from django.test.utils import override_settings
try:
    # django < 1.7
    from django.template import loader
    add_to_builtins = loader.add_to_builtins
except AttributeError:
    try:
        # django >= 1.7
        from django.template.base import add_to_builtins
    except ImportError:
        # django >= 1.9
        def add_to_builtins(module):
            from django.template.engine import Engine
            template_engine = Engine.get_default()
            template_engine.builtins.append(module)
            template_engine.template_builtins = \
                template_engine.get_template_builtins(template_engine.builtins)

from django_nvd3.templatetags.nvd3_tags import load_chart, include_container


class NVD3TemplateTagsTestCase(unittest.TestCase):

    def render_template(self, string, context=None):
        context = context or {}
        context = Context(context)
        return Template(string).render(context)

    def testPiechart(self):
        xdata = ["Apple", "Apricot", "Avocado", "Banana", "Boysenberries", "Blueberries",
                 "Dates", "Grapefruit", "Kiwi", "Lemon"]
        ydata = [52, 48, 160, 94, 75, 71, 490, 82, 46, 17]
        chartdata = {'x': xdata, 'y': ydata}
        charttype = "pieChart"
        extra = {'y_is_date': False}<commit_msg>Fix the exceptions in tests with Django 1.9<commit_after>import unittest


import django
from django.template import (
    Context,
    Template
)
from django.conf import settings
settings.configure()
django.setup()
from django.test.utils import override_settings
try:
    from django.template.base import add_to_builtins
except ImportError:
    # django >= 1.9
    def add_to_builtins(module):
        from django.template.engine import Engine
        template_engine = Engine.get_default()
        template_engine.builtins.append(module)
        template_engine.template_builtins = \
            template_engine.get_template_builtins(template_engine.builtins)

from django_nvd3.templatetags.nvd3_tags import load_chart, include_container


class NVD3TemplateTagsTestCase(unittest.TestCase):

    def render_template(self, string, context=None):
        context = context or {}
        context = Context(context)
        return Template(string).render(context)

    def testPiechart(self):
        xdata = ["Apple", "Apricot", "Avocado", "Banana", "Boysenberries", "Blueberries",
                 "Dates", "Grapefruit", "Kiwi", "Lemon"]
        ydata = [52, 48, 160, 94, 75, 71, 490, 82, 46, 17]
        chartdata = {'x': xdata, 'y': ydata}
        charttype = "pieChart"
        extra = {'y_is_date': False}
{'fraction_non_alphanumeric': 0.10098074827460951, 'fraction_numerical': 0.02179440610243371, 'mean_word_length': 3.172727272727273, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 6, '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': '1048273', 'n_tokens_mistral': 875, 'n_tokens_neox': 807, 'n_words': 198}