<commit_before>from django.http import QueryDict
from django.shortcuts import render
from django.test import TestCase


class TemplateTagsTest(TestCase):

    def test_useful_tags(self):
        body = render(
            None,
            'template_for_tags.html',
            context=dict(
                querydict=QueryDict('a=12&b=13'),
                map1={
                    'key1': 'KEY',
                },
                int1=300,
                int2=3000,
                int3=30000,
                int4=300000,
                int1m=-300,
                int2m=-3000,
                int3m=-30000,
                int4m=-300000,
                string1='test',
                string2='TEST',
                begin='te',
                path='/etc/passwd/shadow',
            )
        )
        body_lines = body.content.decode('UTF-8').strip().split('\n')

        expected_lines = (
            ('a=newvalue&amp;b=13', 'b=13&amp;a=newvalue'),  # result should be one of these
            'KEY',
            'KEY',
            '300',
            '3 000',
            '30 000',
            '300 000',
            '-300',
            '-3 000',
            '-30 000',
            '-300 000',
            'True',
            'False',
            'shadow',
        )

        for bl, el in zip(body_lines, expected_lines):
            if isinstance(el, tuple):
                self.assertIn(bl, el)
            else:
                self.assertEqual(bl, el)

        self.assertEqual(len(body_lines), len(expected_lines))
<commit_msg>used proper renderer in test<commit_after>from django.http import QueryDict
from django.template.loader import render_to_string
from django.test import TestCase


class TemplateTagsTest(TestCase):

    def test_useful_tags(self):
        body_lines = render_to_string(
            'template_for_tags.html',
            context=dict(
                querydict=QueryDict('a=12&b=13'),
                map1={
                    'key1': 'KEY',
                },
                int1=300,
                int2=3000,
                int3=30000,
                int4=300000,
                int1m=-300,
                int2m=-3000,
                int3m=-30000,
                int4m=-300000,
                string1='test',
                string2='TEST',
                begin='te',
                path='/etc/passwd/shadow',
            )
        ).strip().split('\n')

        expected_lines = (
            ('a=newvalue&amp;b=13', 'b=13&amp;a=newvalue'),  # result should be one of these
            'KEY',
            'KEY',
            '300',
            '3 000',
            '30 000',
            '300 000',
            '-300',
            '-3 000',
            '-30 000',
            '-300 000',
            'True',
            'False',
            'shadow',
        )

        for bl, el in zip(body_lines, expected_lines):
            if isinstance(el, tuple):
                self.assertIn(bl, el)
            else:
                self.assertEqual(bl, el)

        self.assertEqual(len(body_lines), len(expected_lines))

{'fraction_non_alphanumeric': 0.1189470263243419, 'fraction_numerical': 0.060123496912577186, 'mean_word_length': 1.184528034066714, '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': '4009252', 'n_tokens_mistral': 998, 'n_tokens_neox': 844, 'n_words': 168}