<commit_before>import json

from django.test import TestCase
from django.test.utils import override_settings
from django.core.urlresolvers import reverse

from lazy_tags.templatetags import lazy_tags


class LazyTagsViewTests(TestCase):

    def test_tag_with_no_args_or_kwargs(self):
        url = reverse('lazy_tag')

        response = self.client.get(url, {'tag': 'test_tags.test'})

        self.assertEqual(response.content, '<p>hello world</p>')

    def test_tag_with_just_args(self):
        url = reverse('lazy_tag')
        data = {
            'tag': 'test_tags.test_with_args',
            'args': json.dumps(['hello']),
        }

        response = self.client.get(url, data)

        expected_html = '<p>hello</p>'
        self.assertHTMLEqual(response.content, expected_html)

    def test_tag_with_args_and_kwargs(self):
        url = reverse('lazy_tag')
        data = {
            'tag': 'test_tags.test_with_args',
            'args': json.dumps(['hello']),
            'kwargs': json.dumps({'kwarg': 'world'}),
        }

        response = self.client.get(url, data)

        expected_html = '<p>hello world</p>'
        self.assertHTMLEqual(response.content, expected_html)

    def test_inclusion_tag(self):
        url = reverse('lazy_tag')

        response = self.client.get(url, {'tag': 'test_tags.inclusion'})

        expected_html = '<p>hello world</p>'
        self.assertHTMLEqual(response.content, expected_html)


class LazyTagsTests(TestCase):

    def setUp(self):
        self.context = {
            'lazy_tag_data': {
                'tag': 'test_tags.tag',
                'args': json.dumps([]),
                'kwargs': json.dumps({}),
            },
        }

    def test_default_error_message(self):
        html = lazy_tags.lazy_tags_js(self.context)

        self.assertIn('An error occurred.', html)

    @override_settings(LAZY_TAGS_ERROR_MESSAGE='<p>Custom error message!</p>')
    def test_custom_error_message(self):
        html = lazy_tags.lazy_tags_js(self.context)

        self.assertIn('<p>Custom error message!</p>', html)
<commit_msg>Python 3 text fixes<commit_after>import json

from django.test import TestCase
from django.test.utils import override_settings
from django.core.urlresolvers import reverse

from lazy_tags.templatetags import lazy_tags


class LazyTagsViewTests(TestCase):

    def test_tag_with_no_args_or_kwargs(self):
        url = reverse('lazy_tag')

        response = self.client.get(url, {'tag': 'test_tags.test'})

        self.assertEqual(str(response.content), '<p>hello world</p>')

    def test_tag_with_just_args(self):
        url = reverse('lazy_tag')
        data = {
            'tag': 'test_tags.test_with_args',
            'args': json.dumps(['hello']),
        }

        response = self.client.get(url, data)

        expected_html = '<p>hello</p>'
        self.assertHTMLEqual(str(response.content), expected_html)

    def test_tag_with_args_and_kwargs(self):
        url = reverse('lazy_tag')
        data = {
            'tag': 'test_tags.test_with_args',
            'args': json.dumps(['hello']),
            'kwargs': json.dumps({'kwarg': 'world'}),
        }

        response = self.client.get(url, data)

        expected_html = '<p>hello world</p>'
        self.assertHTMLEqual(str(response.content), expected_html)

    def test_inclusion_tag(self):
        url = reverse('lazy_tag')

        response = self.client.get(url, {'tag': 'test_tags.inclusion'})

        expected_html = '<p>hello world</p>'
        self.assertHTMLEqual(str(response.content), expected_html)


class LazyTagsTests(TestCase):

    def setUp(self):
        self.context = {
            'lazy_tag_data': {
                'tag': 'test_tags.tag',
                'args': json.dumps([]),
                'kwargs': json.dumps({}),
            },
        }

    def test_default_error_message(self):
        html = lazy_tags.lazy_tags_js(self.context)

        self.assertIn('An error occurred.', html)

    @override_settings(LAZY_TAGS_ERROR_MESSAGE='<p>Custom error message!</p>')
    def test_custom_error_message(self):
        html = lazy_tags.lazy_tags_js(self.context)

        self.assertIn('<p>Custom error message!</p>', html)

{'fraction_non_alphanumeric': 0.13399621212121213, 'fraction_numerical': 0.00023674242424242425, 'mean_word_length': 2.706140350877193, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, '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': '3341091', 'n_tokens_mistral': 1369, 'n_tokens_neox': 1329, 'n_words': 225}