<commit_before>import os

from django import forms
from django.conf import settings
from django.test import TestCase
# timezone support is new in Django 1.4
try:
    from django.utils import timezone as datetime
except ImportError:
    from datetime import datetime


from django_filters.filterset import FilterSet
from django_filters.filters import (AllValuesFilter, CharFilter, ChoiceFilter,
    DateRangeFilter, DateTimeFilter, MultipleChoiceFilter, NumberFilter,
    RangeFilter)
from django_filters.widgets import LinkWidget

from django_filters.tests.models import User, Comment, Book, Restaurant, Article, STATUS_CHOICES

import django
if django.VERSION[:2] >= (1,4):
    test_fixture_name = 'test_data'
else:
    # Same as test_data except that datetime values don't have timezones.
    test_fixture_name = 'test_data_django_13'

class GenericViewTests(TestCase):
    urls = 'django_filters.tests.test_urls'

    fixtures = [test_fixture_name]
    template_dirs = [
        os.path.join(os.path.dirname(__file__), 'templates'),
    ]

    def setUp(self):
        self.old_template_dir = settings.TEMPLATE_DIRS
        settings.TEMPLATE_DIRS = self.template_dirs

    def tearDown(self):
        settings.TEMPLATE_DIRS = self.old_template_dir

    def test_generic_view(self):
        response = self.client.get('/books/')
        for b in ['Ender&#39;s Game', 'Rainbox Six', 'Snowcrash']:
            self.assertContains(response, b)

<commit_msg>Add a compat TestCase for Django < 1.4.<commit_after>import os

from django import forms
from django.conf import settings
from django.test import TestCase
# timezone support is new in Django 1.4
try:
    from django.utils import timezone as datetime
except ImportError:
    from datetime import datetime


from django_filters.filterset import FilterSet
from django_filters.filters import (AllValuesFilter, CharFilter, ChoiceFilter,
    DateRangeFilter, DateTimeFilter, MultipleChoiceFilter, NumberFilter,
    RangeFilter)
from django_filters.widgets import LinkWidget

from django_filters.tests.models import User, Comment, Book, Restaurant, Article, STATUS_CHOICES

import django
if django.VERSION[:2] >= (1,4):
    test_fixture_name = 'test_data'
else:
    # Same as test_data except that datetime values don't have timezones.
    test_fixture_name = 'test_data_django_13'


    class TestCase(TestCase):
        """
        Redefined TestCase to add assertQuerysetEqual() with an 'ordered' parameter.
        The 'ordered' parameter was added in Django 1.4.
        """

        def assertQuerysetEqual(self, qs, values, transform=repr, ordered=True):
            items = map(transform, qs)
            if not ordered:
                return self.assertEqual(set(items), set(values))
            return self.assertEqual(list(items), values)


class GenericViewTests(TestCase):
    urls = 'django_filters.tests.test_urls'

    fixtures = [test_fixture_name]
    template_dirs = [
        os.path.join(os.path.dirname(__file__), 'templates'),
    ]

    def setUp(self):
        self.old_template_dir = settings.TEMPLATE_DIRS
        settings.TEMPLATE_DIRS = self.template_dirs

    def tearDown(self):
        settings.TEMPLATE_DIRS = self.old_template_dir

    def test_generic_view(self):
        response = self.client.get('/books/')
        for b in ['Ender&#39;s Game', 'Rainbox Six', 'Snowcrash']:
            self.assertContains(response, b)


{'fraction_non_alphanumeric': 0.08480046948356808, 'fraction_numerical': 0.006455399061032864, 'mean_word_length': 3.715076071922545, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 5, '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': '2462967', 'n_tokens_mistral': 1026, 'n_tokens_neox': 988, 'n_words': 273}