hash stringlengths 64 64 | content stringlengths 0 1.51M |
|---|---|
9c285beb1f0b1f043bbf3354b39ea4429b6371d7788ab6a5c171d461bc186a29 | import json
from django.test import SimpleTestCase, override_settings
@override_settings(ROOT_URLCONF='view_tests.generic_urls')
class JsonResponseTests(SimpleTestCase):
def test_json_response(self):
response = self.client.get('/json/response/')
self.assertEqual(response.status_code, 200)
... |
c8a7cc9eedb310921a27a1d967a62b4f7255f2d4765f8fe420dc4cbb8f826c2d | from django import template
register = template.Library()
@register.simple_tag
def go_boom():
raise Exception('boom')
|
38267fe0e2a7915c72a923e4cd76800349eb838959506a572d22d22b07bc11c1 | import a_package_name_that_does_not_exist # NOQA
content = 'Bad Module'
|
b54bc0abdf6e6c1eeb1390fcec8f4f0b8ea3752d1565d0c104f538abbfaf3e19 | class SiteMock:
_registry = {}
site = SiteMock()
|
d53f9d14997ab53b665790f306a8928c40199c4d31bc95bcf915f653793eecf8 | content = 'Good Module'
|
ab4560e014c00131dbf5ce26877bcb7e9e444bbfe0ac346ff3254ea7b6927631 | from . import site
content = 'Another Good Module'
site._registry.update({
'lorem': 'ipsum',
})
|
5a7db7ac9db32807197cb08b3b820a17eeda7227a030f18efaf875999df99e52 | from . import site
content = 'Another Bad Module'
site._registry.update({
'foo': 'bar',
})
raise Exception('Some random exception.')
|
b058b96bfea5a65feefa000415bcc7fb9d47ff045ecd4fb897804d63100358cf | content = 'Grandchild Module'
|
16272be1eabd69f953811234cff3778886bc5f3edd0fd443b0395e276de36305 | from django.db import models
class ParentManager(models.Manager):
def get_by_natural_key(self, parent_data):
return self.get(parent_data=parent_data)
class Parent(models.Model):
parent_data = models.CharField(max_length=30, unique=True)
objects = ParentManager()
def natural_key(self):
... |
e12ac590ef7dfbd603f49848fd42d55744a6c8a75bca0bff788823ef83f912a3 | from .base import * # NOQA
from .data import * # NOQA
from .multi_table import * # NOQA
from .natural import * # NOQA
|
7607290fda8744d062df77452abc1ff166668854d7f1397de40fdf5dc292af01 | """Models for test_natural.py"""
from django.db import models
class NaturalKeyAnchorManager(models.Manager):
def get_by_natural_key(self, data):
return self.get(data=data)
class NaturalKeyAnchor(models.Model):
objects = NaturalKeyAnchorManager()
data = models.CharField(max_length=100, unique=Tr... |
4e09ca76c152edeb35c2d07512bfd85b84ff427847393ad682026da41f0632af | """
Serialization
``django.core.serializers`` provides interfaces to converting Django
``QuerySet`` objects to and from "flat" data (i.e. strings).
"""
from decimal import Decimal
from django.db import models
class CategoryMetaDataManager(models.Manager):
def get_by_natural_key(self, kind, name):
retur... |
9993c9330856407c5ed3dcf9c04a8755a2a2c4899a788b67686c8f2f45aabbdb | """
******** Models for test_data.py ***********
The following classes are for testing basic data marshalling, including
NULL values, where allowed.
The basic idea is to have a model for each Django data type.
"""
from django.contrib.contenttypes.fields import (
GenericForeignKey, GenericRelation,
)
from django.con... |
f7536734002844a5d8538dd86e344f88595f1bbd6964aeaaf6432720dff3d17f | from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [("migrations2", "0001_initial")]
operations = [
migrations.CreateModel(
"Bookstore",
[
("id", models.AutoField(primary_key=True)),
("name", models.... |
efa8d13cf2a85535adc7d862675aad28c0774fad364c7928ef8f265b3e54511a | from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("migrations", "__first__"),
]
operations = [
migrations.CreateModel(
"OtherAuthor",
[
("id", models.AutoField(primary_key=True)),
("n... |
33d24f95434c6b255621462380939732a0e753d8682048aa54c2cb869a17c28c | from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = []
operations = [
migrations.CreateModel(
"OtherAuthor",
[
("id", models.AutoField(primary_key=True)),
("name", models.CharField(max_length=255)),
... |
ec25831671a80f7796b54c3acb016481864140b80a23e7f461d989a8caba1fe3 | from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [("migrations", "0002_second")]
operations = [
migrations.CreateModel(
"OtherAuthor",
[
("id", models.AutoField(primary_key=True)),
("name", models.... |
796be1a19d4360e4c981027928a2485f7979b65c96de0d120e7a8ac4299f0e75 | from django.template import TemplateSyntaxError
from django.test import SimpleTestCase
from ..utils import setup
class FilterTagTests(SimpleTestCase):
@setup({'filter01': '{% filter upper %}{% endfilter %}'})
def test_filter01(self):
output = self.engine.render_to_string('filter01')
self.ass... |
2583594024df0f61a3bc5a83be7a1e92f0d111cf780f49a2126b3f354b164a1d | from django.template import TemplateSyntaxError
from django.template.defaulttags import IfNode
from django.test import SimpleTestCase
from ..utils import TestObj, setup
class IfTagTests(SimpleTestCase):
@setup({'if-tag01': '{% if foo %}yes{% else %}no{% endif %}'})
def test_if_tag01(self):
output = ... |
111afa018ec76c133df4a8e4129858d6e4adcfb5776a4f85e1cc1434f2613261 | from django.template import (
Context, Engine, TemplateDoesNotExist, TemplateSyntaxError, loader,
)
from django.test import SimpleTestCase
from ..utils import setup
from .test_basic import basic_templates
include_fail_templates = {
'include-fail1': '{% load bad_tag %}{% badtag %}',
'include-fail2': '{% lo... |
44db0d7fff07169055a19ca706a4ff67dd7fc25702082e31c623cebced137ec3 | from django.template import TemplateSyntaxError
from django.test import SimpleTestCase
from ..utils import setup
class NamedEndblockTests(SimpleTestCase):
@setup({'namedendblocks01': '1{% block first %}_{% block second %}'
'2{% endblock second %}_{% endblock first %}3'})
def ... |
e3ab66c0fc198493dbde2b6085812338d2630b7db98f8ee3b580b2ceae1b5cc7 | from django.template import TemplateSyntaxError
from django.test import SimpleTestCase
from ..utils import setup
class FirstOfTagTests(SimpleTestCase):
@setup({'firstof01': '{% firstof a b c %}'})
def test_firstof01(self):
output = self.engine.render_to_string('firstof01', {'a': 0, 'c': 0, 'b': 0})
... |
fdbcb4df18571ceb17d067c58bcced331b9b78bbeb33249cd09c840e22ebb667 | from urllib.parse import urljoin
from django.conf import settings
from django.template import TemplateSyntaxError
from django.test import SimpleTestCase, override_settings
from ..utils import setup
@override_settings(INSTALLED_APPS=[], MEDIA_URL='/media/', STATIC_URL='/static/')
class StaticTagTests(SimpleTestCase)... |
f4e976c23de6f9e9b14c4706db271122dd19fac933c1bcd80afb3cf755cf2757 | from django.template import TemplateSyntaxError
from django.test import SimpleTestCase
from ..utils import SomeClass, SomeOtherException, UTF8Class, setup
class FilterSyntaxTests(SimpleTestCase):
@setup({'filter-syntax01': '{{ var|upper }}'})
def test_filter_syntax01(self):
"""
Basic filter ... |
beabba120b54bb90a0c479cdf2fc19d9b36cb4bf2dd1a9057df14906930e8161 | from django.template.base import Context, TemplateSyntaxError
from django.test import SimpleTestCase
from ..utils import SilentAttrClass, SilentGetItemClass, SomeClass, setup
basic_templates = {
'basic-syntax01': 'something cool',
'basic-syntax02': '{{ headline }}',
'basic-syntax03': '{{ first }} --- {{ s... |
10860c2a02fe18f8bbefe24f949e06de76f80bf92d3dd14fda4eb963f11e9695 | from django.test import SimpleTestCase
from ..utils import setup
class CommentSyntaxTests(SimpleTestCase):
@setup({'comment-syntax01': '{# this is hidden #}hello'})
def test_comment_syntax01(self):
output = self.engine.render_to_string('comment-syntax01')
self.assertEqual(output, 'hello')
... |
6dd16d5d681fdc00d763af93a0ac2093f582d5ef1162d818f603fe71f275fa75 | from django.template import TemplateSyntaxError
from django.template.defaulttags import IfEqualNode
from django.test import SimpleTestCase
from ..utils import setup
class IfEqualTagTests(SimpleTestCase):
@setup({'ifequal01': '{% ifequal a b %}yes{% endifequal %}'})
def test_ifequal01(self):
output =... |
18233c332ff239b5848a17389aad81f01e8a12165f8a3eb26ad5c225d6deb1ff | from django.template import TemplateSyntaxError
from django.test import SimpleTestCase
from django.utils.safestring import mark_safe
from ..utils import SafeClass, UnsafeClass, setup
class AutoescapeTagTests(SimpleTestCase):
@setup({'autoescape-tag01': '{% autoescape off %}hello{% endautoescape %}'})
def te... |
7f97fb09483ae49bc56b9f7d1efec29717dea4faf7db740bf6aae3123dd5eedf | from django.template import TemplateSyntaxError
from django.template.defaulttags import ForNode
from django.test import SimpleTestCase
from ..utils import setup
class ForTagTests(SimpleTestCase):
libraries = {'custom': 'template_tests.templatetags.custom'}
@setup({'for-tag01': '{% for val in values %}{{ val... |
e198549f46c91ca48e7924ab35682d5d8ba0c82da15f6f3fbcd0864fe9a21f15 | from django.template import TemplateSyntaxError
from django.test import SimpleTestCase
from ..utils import setup
class TemplateTagTests(SimpleTestCase):
@setup({'templatetag01': '{% templatetag openblock %}'})
def test_templatetag01(self):
output = self.engine.render_to_string('templatetag01')
... |
bb8edf14bc52b25ea5bbd59379553e19a326869b2988f1eadcc6472a4f17b5b3 | from django.core.cache import cache
from django.template import Context, Engine, TemplateSyntaxError
from django.test import SimpleTestCase, override_settings
from ..utils import setup
class CacheTagTests(SimpleTestCase):
libraries = {
'cache': 'django.templatetags.cache',
'custom': 'template_tes... |
60eb225bf388d53fda09e01588386b62d5ec972510b03bedbaa9841fb8c87ba3 | from django.template import TemplateSyntaxError
from django.test import SimpleTestCase
from ..utils import setup
class VerbatimTagTests(SimpleTestCase):
@setup({'verbatim-tag01': '{% verbatim %}{{bare }}{% endverbatim %}'})
def test_verbatim_tag01(self):
output = self.engine.render_to_string('verb... |
a7a7a6194b69a1718acdaa35b09260dd174b7ed436d2e89e01b73a0862d6e52a | from django.template import TemplateSyntaxError
from django.test import SimpleTestCase
from ..utils import setup
class CycleTagTests(SimpleTestCase):
@setup({'cycle01': '{% cycle a %}'})
def test_cycle01(self):
msg = "No named cycles in template. 'a' is not defined"
with self.assertRaisesMes... |
e9b1ba6244f644d3fec6649edcac2783c6f2ae0526b5aaaf5a03f0f9da7f786c | from django.test import SimpleTestCase
from ..utils import setup
class ListIndexTests(SimpleTestCase):
@setup({'list-index01': '{{ var.1 }}'})
def test_list_index01(self):
"""
List-index syntax allows a template to access a certain item of a
subscriptable object.
"""
... |
8d4aad1045ecdbb4d0b0e4901c4dd7e16a95a992fe719afa74095c1f5fc620d6 | from django.template import TemplateSyntaxError
from django.template.defaulttags import WithNode
from django.test import SimpleTestCase
from ..utils import setup
class WithTagTests(SimpleTestCase):
at_least_with_one_msg = "'with' expected at least one variable assignment"
@setup({'with01': '{% with key=dict... |
ae69b743d10a364b19263d7de1b00c3ce1e127c958fa53a211edde4e307585e7 | from django.template import Context, Engine
from django.test import SimpleTestCase
from ..utils import setup
class IfChangedTagTests(SimpleTestCase):
libraries = {'custom': 'template_tests.templatetags.custom'}
@setup({'ifchanged01': '{% for n in num %}{% ifchanged %}{{ n }}{% endifchanged %}{% endfor %}'})... |
79b22dd12210723fe05dc62a901e0ab83b408853019c7d800a6e20f186a1df2c | from datetime import datetime
from django.template import TemplateSyntaxError
from django.test import SimpleTestCase
from django.utils.formats import date_format
from ..utils import setup
class NowTagTests(SimpleTestCase):
@setup({'now01': '{% now "j n Y" %}'})
def test_now01(self):
"""
Sim... |
3e849d39ff1326730d10df9bda3e5ac09c5deb0c340bca0e825927d7ea02b706 | from django.test import SimpleTestCase
from ..utils import setup
class InvalidStringTests(SimpleTestCase):
libraries = {'i18n': 'django.templatetags.i18n'}
@setup({'invalidstr01': '{{ var|default:"Foo" }}'})
def test_invalidstr01(self):
output = self.engine.render_to_string('invalidstr01')
... |
95fc6a3d8e0a3fd5185c27415320ae0c4675608f5e4333e7c12652fc13e8fa0f | from django.test import SimpleTestCase
from ..utils import setup
class BuiltinsTests(SimpleTestCase):
@setup({'builtins01': '{{ True }}'})
def test_builtins01(self):
output = self.engine.render_to_string('builtins01')
self.assertEqual(output, 'True')
@setup({'builtins02': '{{ False }}'}... |
64c6ad6a642527a9cbc4053e218e1d2607ee6de1a286d65f4a4b5ece31fe4a14 | from django.template import TemplateDoesNotExist, TemplateSyntaxError
from django.test import SimpleTestCase
from ..utils import setup
from .test_extends import inheritance_templates
class ExceptionsTests(SimpleTestCase):
@setup({'exception01': "{% extends 'nonexistent' %}"})
def test_exception01(self):
... |
41c4c9ea4be5a6c313147bba4501a9350fb29516b5a34234ae811534032ab2ee | from django.test import SimpleTestCase
from ..utils import setup
multiline_string = """
Hello,
boys.
How
are
you
gentlemen.
"""
class MultilineTests(SimpleTestCase):
@setup({'multiline01': multiline_string})
def test_multiline01(self):
output = self.engine.render_to_string('multiline01')
se... |
48f0f29c9ad17741ad7a5b46ea73e4fd4e0e9ec08d42e261e59fb4322c1325a5 | from datetime import date
from django.template import TemplateSyntaxError
from django.test import SimpleTestCase
from ..utils import setup
class RegroupTagTests(SimpleTestCase):
@setup({'regroup01': ''
'{% regroup data by bar as grouped %}'
'{% for group in gro... |
0eafa5cffb11a1c976a3be819d338f7baedab8eaa67a9d460836a4ddb2895561 | from django.template import RequestContext, TemplateSyntaxError
from django.test import RequestFactory, SimpleTestCase, override_settings
from django.urls import NoReverseMatch, resolve
from ..utils import setup
@override_settings(ROOT_URLCONF='template_tests.urls')
class UrlTagTests(SimpleTestCase):
# Successe... |
cfc2bd05689a5e6f41a24a32c138410bf00584da4ee9b53bbca3d03481ac02ea | from django.template import TemplateSyntaxError
from django.test import SimpleTestCase
from ..utils import setup
class ResetCycleTagTests(SimpleTestCase):
@setup({'resetcycle01': "{% resetcycle %}"})
def test_resetcycle01(self):
with self.assertRaisesMessage(TemplateSyntaxError, "No cycles in templa... |
e55fe4cf2eb93a08a74e55b2d363ec0453f4ab3dc35823c1829f69420f8f84f9 | from django.template import TemplateSyntaxError
from django.test import SimpleTestCase
from ..utils import setup
class LoadTagTests(SimpleTestCase):
libraries = {
'subpackage.echo': 'template_tests.templatetags.subpackage.echo',
'testtags': 'template_tests.templatetags.testtags',
}
@setu... |
df474066b2ae8d7863a7eebe8cf2bc32be9ffd1399010964eccd3c2cad55ad68 | from django.template import TemplateSyntaxError
from django.test import SimpleTestCase
from ..utils import setup
class SimpleTagTests(SimpleTestCase):
libraries = {'custom': 'template_tests.templatetags.custom'}
@setup({'simpletag-renamed01': '{% load custom %}{% minusone 7 %}'})
def test_simpletag_rena... |
06e330890575bbb4abe88c811ad782ba8024e9fadf65658f118592338edbbd6d | from django.test import SimpleTestCase
from ..utils import setup
class SpacelessTagTests(SimpleTestCase):
@setup({'spaceless01': "{% spaceless %} <b> <i> text </i> </b> {% endspaceless %}"})
def test_spaceless01(self):
output = self.engine.render_to_string('spaceless01')
self.assertEqu... |
3cbdc3bf8faa34cd2aaf5b2956dcfaa9e1fca5351cbde3d3326e408b8b64264f | from unittest import skipIf
from django.test import SimpleTestCase
from ..utils import setup
try:
import numpy
except ImportError:
numpy = False
@skipIf(numpy is False, "Numpy must be installed to run these tests.")
class NumpyTests(SimpleTestCase):
@setup({'numpy-array-index01': '{{ var.1 }}'})
d... |
150a825a62893990c8cd2d534a3309fd20dcffdb6587f0f0a32fa944754edf6f | from django.test import SimpleTestCase
from ..utils import setup
class SetupTests(SimpleTestCase):
def test_setup(self):
"""
Let's just make sure setup runs cases in the right order.
"""
cases = []
@setup({})
def method(self):
cases.append([
... |
421f55b75926b9be57283cf7d7da62aeffc9a01718b65a574f16ff59185059fd | from django.test import SimpleTestCase
from django.utils.lorem_ipsum import WORDS
from ..utils import setup
class LoremTagTests(SimpleTestCase):
@setup({'lorem1': '{% lorem 3 w %}'})
def test_lorem1(self):
output = self.engine.render_to_string('lorem1')
self.assertEqual(output, 'lorem ipsum ... |
b18f9a83a0d6c0c859c9e4fb70cddf32880bfc15f2f77dab294781532631a17f | from django.template import NodeList, TemplateSyntaxError
from django.template.base import Node
from django.template.loader_tags import ExtendsNode
from django.test import SimpleTestCase
from ..utils import setup
inheritance_templates = {
'inheritance01': "1{% block first %}&{% endblock %}3{% block second %}_{% e... |
28c4a877d943cfbf16e71d53edfd4043d196af696cc9cbffb9f094a4124bfaa4 | from django.template import TemplateSyntaxError
from django.test import SimpleTestCase
from ..utils import setup
class WidthRatioTagTests(SimpleTestCase):
libraries = {'custom': 'template_tests.templatetags.custom'}
@setup({'widthratio01': '{% widthratio a b 0 %}'})
def test_widthratio01(self):
... |
3bebc93a06953fcaa3b431e5c258dc2aa9c6e0799c7fefb2fd2676b7e312bec7 | from django.template.defaultfilters import ljust
from django.test import SimpleTestCase
from django.utils.safestring import mark_safe
from ..utils import setup
class LjustTests(SimpleTestCase):
@setup({'ljust01': '{% autoescape off %}.{{ a|ljust:"5" }}. .{{ b|ljust:"5" }}.{% endautoescape %}'})
def test_lju... |
77ea6a49b0420aa35359d76fb81b716de4d8d39ae1cc001f3e08f5892245326f | from django.template.defaultfilters import striptags
from django.test import SimpleTestCase
from django.utils.functional import lazystr
from django.utils.safestring import mark_safe
from ..utils import setup
class StriptagsTests(SimpleTestCase):
@setup({'striptags01': '{{ a|striptags }} {{ b|striptags }}'})
... |
98ddcd318c67f1428d127d1aab875dc1f554312e79e53ca22b46610662532615 | from django.template.defaultfilters import stringformat
from django.test import SimpleTestCase
from django.utils.safestring import mark_safe
from ..utils import setup
class StringformatTests(SimpleTestCase):
"""
Notice that escaping is applied *after* any filters, so the string
formatting here only needs... |
506aecd5321e2a8ab4b08876a4200a67cd8bd013189bfd9ee211a9985f64ec2a | from django.template.defaultfilters import escape
from django.test import SimpleTestCase
from django.utils.functional import Promise, lazy
from django.utils.safestring import mark_safe
from ..utils import setup
class EscapeTests(SimpleTestCase):
"""
The "escape" filter works the same whether autoescape is on... |
ef6c87b91fc1c11d031cd4ba5512f032ff760f3dc811c8d25b8dc81d124ae54a | from django.template.defaultfilters import slugify
from django.test import SimpleTestCase
from django.utils.functional import lazy
from django.utils.safestring import mark_safe
from ..utils import setup
class SlugifyTests(SimpleTestCase):
"""
Running slugify on a pre-escaped string leads to odd behavior,
... |
5a9043c2ed873fd9226afce327e09c9847076de05b0986929eba903d0e6fd2c8 | from django.template.defaultfilters import first
from django.test import SimpleTestCase
from django.utils.safestring import mark_safe
from ..utils import setup
class FirstTests(SimpleTestCase):
@setup({'first01': '{{ a|first }} {{ b|first }}'})
def test_first01(self):
output = self.engine.render_to_... |
cb7f800b150481ad14ec4e9036fbe4768f1be5b49c4748c6fbd0f4414ac49bd1 | from django.template.defaultfilters import capfirst
from django.test import SimpleTestCase
from django.utils.safestring import mark_safe
from ..utils import setup
class CapfirstTests(SimpleTestCase):
@setup({'capfirst01': '{% autoescape off %}{{ a|capfirst }} {{ b|capfirst }}{% endautoescape %}'})
def test_... |
f19b10b5e33ae60d6f5a09c0087ee1fcb8edecf76b7b72e6d127343d7e61ec4c | from datetime import date, datetime
from django.test import SimpleTestCase
from django.utils import timezone
class TimezoneTestCase(SimpleTestCase):
def setUp(self):
self.now = datetime.now()
self.now_tz = timezone.make_aware(
self.now, timezone.get_default_timezone(),
)
... |
6378aa244a8b6494c727d204649d8707f8b114d67634a8d63cd85d107532bacd | from django.template.defaultfilters import unordered_list
from django.test import SimpleTestCase
from django.utils.safestring import mark_safe
from django.utils.translation import gettext_lazy
from ..utils import setup
class UnorderedListTests(SimpleTestCase):
@setup({'unordered_list01': '{{ a|unordered_list }}... |
4dbe78dad57f99721390a724f0794bddd99106b929710c55b3904bd5420cc7c6 | from django.template.defaultfilters import force_escape
from django.test import SimpleTestCase
from django.utils.safestring import SafeData
from ..utils import setup
class ForceEscapeTests(SimpleTestCase):
"""
Force_escape is applied immediately. It can be used to provide
double-escaping, for example.
... |
f3d20b4a1d71f07e6f5cf0b627100d005d660a92a9808b9c86a229ba7ae18353 | from django.template.defaultfilters import urlizetrunc
from django.test import SimpleTestCase
from django.utils.safestring import mark_safe
from ..utils import setup
class UrlizetruncTests(SimpleTestCase):
@setup({
'urlizetrunc01': '{% autoescape off %}{{ a|urlizetrunc:"8" }} {{ b|urlizetrunc:"8" }}{% e... |
ae7faee03be4098910ff8938b082bbe571585bfb6580920579429de98544eacf | from django.test import SimpleTestCase
from ..utils import setup
class SafeTests(SimpleTestCase):
@setup({'safe01': '{{ a }} -- {{ a|safe }}'})
def test_safe01(self):
output = self.engine.render_to_string('safe01', {'a': '<b>hello</b>'})
self.assertEqual(output, '<b>hello</b> -- ... |
5957aa5c6a4be6ae457dbfdef98e4b9b3f7a12ee52be76e61551f2a980a238de | from django.template.defaultfilters import addslashes
from django.test import SimpleTestCase
from django.utils.safestring import mark_safe
from ..utils import setup
class AddslashesTests(SimpleTestCase):
@setup({'addslashes01': '{% autoescape off %}{{ a|addslashes }} {{ b|addslashes }}{% endautoescape %}'})
... |
4e7d703da3a749023f7d13fb02e67d737c3b562c20675d50e3b13ef7589b7e6e | from django.template.defaultfilters import wordwrap
from django.test import SimpleTestCase
from django.utils.functional import lazystr
from django.utils.safestring import mark_safe
from ..utils import setup
class WordwrapTests(SimpleTestCase):
@setup({
'wordwrap01': '{% autoescape off %}{{ a|wordwrap:"3... |
722167b2de9a47318dd8e98625a9bf3f7deb764494ec043091ba32dc863663c0 | from django.template.defaultfilters import truncatewords
from django.test import SimpleTestCase
from django.utils.safestring import mark_safe
from ..utils import setup
class TruncatewordsTests(SimpleTestCase):
@setup({
'truncatewords01': '{% autoescape off %}{{ a|truncatewords:"2" }} {{ b|truncatewords:... |
1620294498b483c9651fbf6bf9028e960d4974d489194bac1ad07969876f5967 | from datetime import datetime, timedelta
from django.template.defaultfilters import timesince_filter
from django.test import SimpleTestCase
from django.test.utils import requires_tz_support
from ..utils import setup
from .timezone_utils import TimezoneTestCase
class TimesinceTests(TimezoneTestCase):
"""
#20... |
97ca143d278beb28850dc34cf40884365e1624ce5b8d868cfdaf2224b4183db1 | from django.template.defaultfilters import cut
from django.test import SimpleTestCase
from django.utils.safestring import mark_safe
from ..utils import setup
class CutTests(SimpleTestCase):
@setup({'cut01': '{% autoescape off %}{{ a|cut:"x" }} {{ b|cut:"x" }}{% endautoescape %}'})
def test_cut01(self):
... |
a3349b81a082f79a4b939d3ae9029fb7b9bca1644d3bdad9aa813bb8ecf4f7df | from django.template.defaultfilters import make_list
from django.test import SimpleTestCase
from django.utils.safestring import mark_safe
from ..utils import setup
class MakeListTests(SimpleTestCase):
"""
The make_list filter can destroy existing escaping, so the results are
escaped.
"""
@setup(... |
346c95994ccb4b8f7d81f9df93df1be16500ad7bf5476727cf60a86e982c7048 | from django.template.defaultfilters import join
from django.test import SimpleTestCase
from django.utils.safestring import mark_safe
from ..utils import setup
class JoinTests(SimpleTestCase):
@setup({'join01': '{{ a|join:", " }}'})
def test_join01(self):
output = self.engine.render_to_string('join01... |
fe1f24d094434aa12d7efe23efc2a0bc28f442abf1f69cd6be0affb7e9774796 | from django.template.defaultfilters import linenumbers
from django.test import SimpleTestCase
from django.utils.safestring import mark_safe
from ..utils import setup
class LinenumbersTests(SimpleTestCase):
"""
The contents of "linenumbers" is escaped according to the current
autoescape setting.
"""
... |
9c8a40571878e790791795275314bfe0179870a27b5aff24c576bf67bf1065af | from django.template.defaultfilters import urlize
from django.test import SimpleTestCase
from django.utils.functional import lazy
from django.utils.safestring import mark_safe
from ..utils import setup
class UrlizeTests(SimpleTestCase):
@setup({'urlize01': '{% autoescape off %}{{ a|urlize }} {{ b|urlize }}{% en... |
1194edac3128e9bbb3ae1346426a2dacbfb668bec6a26307f00cd46cfc5b5133 | from django.template.defaultfilters import dictsortreversed
from django.test import SimpleTestCase
class FunctionTests(SimpleTestCase):
def test_sort(self):
sorted_dicts = dictsortreversed(
[{'age': 23, 'name': 'Barbara-Ann'},
{'age': 63, 'name': 'Ra Ra Rasputin'},
{... |
65d7418978991d4b7c0b535ac77364c52b1006e4f2da3b40db72f59cb6514925 | from django.template.defaultfilters import title
from django.test import SimpleTestCase
from ..utils import setup
class TitleTests(SimpleTestCase):
@setup({'title1': '{{ a|title }}'})
def test_title1(self):
output = self.engine.render_to_string('title1', {'a': 'JOE\'S CRAB SHACK'})
self.asse... |
b9cf2a4f8e977a4ee38c9e5f9820e98b241b7b8d6eba2188daf7fdce2613b596 | from django.test import SimpleTestCase
from ..utils import SafeClass, UnsafeClass, setup
class AutoescapeStringfilterTests(SimpleTestCase):
"""
Filters decorated with stringfilter still respect is_safe.
"""
@setup({'autoescape-stringfilter01': '{{ unsafe|capfirst }}'})
def test_autoescape_string... |
986774a1342bfce7d8ba3c65119b171d219fac8e8ec517c26637ea563548a835 | from django.template.defaultfilters import filesizeformat
from django.test import SimpleTestCase
from django.utils import translation
class FunctionTests(SimpleTestCase):
def test_formats(self):
self.assertEqual(filesizeformat(1023), '1023\xa0bytes')
self.assertEqual(filesizeformat(1024), '1.0\xa... |
b80a910dc8f9ae637b097e97915dba4ca41ca29db81c0e333ca6881705868480 | from django.template.defaultfilters import lower
from django.test import SimpleTestCase
from django.utils.safestring import mark_safe
from ..utils import setup
class LowerTests(SimpleTestCase):
@setup({'lower01': '{% autoescape off %}{{ a|lower }} {{ b|lower }}{% endautoescape %}'})
def test_lower01(self):
... |
e8412419059ac167301a95f6c5b34ae2d6b21fa5bb1f2fe708346fddff5fdf63 | from django.template.defaultfilters import urlencode
from django.test import SimpleTestCase
from ..utils import setup
class UrlencodeTests(SimpleTestCase):
@setup({'urlencode01': '{{ url|urlencode }}'})
def test_urlencode01(self):
output = self.engine.render_to_string('urlencode01', {'url': '/test&"... |
a065b97cffb15f4fa3ad315156b7cac3c890bf351ee9c90002041ed732510a4e | from django.template.defaultfilters import truncatechars_html
from django.test import SimpleTestCase
class FunctionTests(SimpleTestCase):
def test_truncate_zero(self):
self.assertEqual(truncatechars_html('<p>one <a href="#">two - three <br>four</a> five</p>', 0), '...')
def test_truncate(self):
... |
dd9a13b059cf0994d74e2de0ef9aebfeb9c05e1196da84f1a1363369d82fe59c | from django.template.defaultfilters import linebreaks_filter
from django.test import SimpleTestCase
from django.utils.functional import lazy
from django.utils.safestring import mark_safe
from ..utils import setup
class LinebreaksTests(SimpleTestCase):
"""
The contents in "linebreaks" are escaped according to... |
2670d02a3dde8423a2cb3c2e6601b2fa9abefe04dfaf2458db91c7ff81c49585 | from django.test import SimpleTestCase
from ..utils import setup
class SafeseqTests(SimpleTestCase):
@setup({'safeseq01': '{{ a|join:", " }} -- {{ a|safeseq|join:", " }}'})
def test_safeseq01(self):
output = self.engine.render_to_string('safeseq01', {'a': ['&', '<']})
self.assertEqual(output... |
6ad29d855092bd6e3eb684e910c3c93dbefeffb9d13c5397cd0bcca7a0b8f6a8 | from django.test import SimpleTestCase
from django.utils.safestring import mark_safe
from ..utils import setup
class ChainingTests(SimpleTestCase):
"""
Chaining safeness-preserving filters should not alter the safe status.
"""
@setup({'chaining01': '{{ a|capfirst|center:"7" }}.{{ b|capfirst|center:"... |
ba6d93f7ddbef3e92d1d7390561493e5ab1f4383e523889077ede820a07b03f0 | from django.template.defaultfilters import linebreaksbr
from django.test import SimpleTestCase
from django.utils.safestring import mark_safe
from ..utils import setup
class LinebreaksbrTests(SimpleTestCase):
"""
The contents in "linebreaksbr" are escaped according to the current
autoescape setting.
"... |
b4b3ad98b3ef093023315f46fe5d34407dadcc041bafe4b16982c55738833749 | from django.test import SimpleTestCase
from django.utils.safestring import mark_safe
from ..utils import setup
class RandomTests(SimpleTestCase):
@setup({'random01': '{{ a|random }} {{ b|random }}'})
def test_random01(self):
output = self.engine.render_to_string(
'random01', {'a': ['a&b'... |
58891babb8562deb1c25aacdba803ea31d00711862e0dcbd69317de90f4bd75f | from django.template.defaultfilters import slice_filter
from django.test import SimpleTestCase
from django.utils.safestring import mark_safe
from ..utils import setup
class SliceTests(SimpleTestCase):
@setup({'slice01': '{{ a|slice:"1:3" }} {{ b|slice:"1:3" }}'})
def test_slice01(self):
output = sel... |
96b541533f9976b38c6c94bddd31319aa912f1d9750beb186ed52f773d5f900f | from django.test import SimpleTestCase
from django.utils.safestring import mark_safe
from ..utils import setup
class LastTests(SimpleTestCase):
@setup({'last01': '{{ a|last }} {{ b|last }}'})
def test_last01(self):
output = self.engine.render_to_string('last01', {"a": ["x", "a&b"], "b": ["x", mark_s... |
5a83ebe8330bef5805d09bc8832809cd7f8317099d0b1707f59db9f18f2c5b99 | from django.template.defaultfilters import default
from django.test import SimpleTestCase
from django.utils.safestring import mark_safe
from ..utils import setup
class DefaultTests(SimpleTestCase):
"""
Literal string arguments to the default filter are always treated as
safe strings, regardless of the au... |
a1bc687153e1187f880938d1c56c4dbb7009a054d95447ca3d1681f560ed1c2d | from django.template.defaultfilters import rjust
from django.test import SimpleTestCase
from django.utils.safestring import mark_safe
from ..utils import setup
class RjustTests(SimpleTestCase):
@setup({'rjust01': '{% autoescape off %}.{{ a|rjust:"5" }}. .{{ b|rjust:"5" }}.{% endautoescape %}'})
def test_rju... |
9da16789dc1334b2ae202cb4b97c050471eccc2744a321ec5be3e5e0600efc5d | from datetime import datetime, time
from django.template.defaultfilters import date
from django.test import SimpleTestCase, override_settings
from django.utils import timezone, translation
from ..utils import setup
from .timezone_utils import TimezoneTestCase
class DateTests(TimezoneTestCase):
@setup({'date01'... |
5104b90e2632481e446bed11a29aad9434539cf77a7b0d64d6be439f8ac1d66f | from django.template.defaultfilters import wordcount
from django.test import SimpleTestCase
from django.utils.safestring import mark_safe
from ..utils import setup
class WordcountTests(SimpleTestCase):
@setup({'wordcount01': '{% autoescape off %}{{ a|wordcount }} {{ b|wordcount }}{% endautoescape %}'})
def ... |
eb3a0971bfcc9333741e567866eaa343f0c9b2b32f8cb2dec45845c509c8a83a | from django.template.defaultfilters import length_is
from django.test import SimpleTestCase
from ..utils import setup
class LengthIsTests(SimpleTestCase):
@setup({'length_is01': '{% if some_list|length_is:"4" %}Four{% endif %}'})
def test_length_is01(self):
output = self.engine.render_to_string('len... |
46eb56daac4a21e1eb28202152018abd4adf36b9a76d2311615155dc43a85488 | from django.template.defaultfilters import truncatewords_html
from django.test import SimpleTestCase
class FunctionTests(SimpleTestCase):
def test_truncate_zero(self):
self.assertEqual(truncatewords_html('<p>one <a href="#">two - three <br>four</a> five</p>', 0), '')
def test_truncate(self):
... |
b6cee4a8b4b1562b2490bccae6401a93cb03a880c6e0096a6990bf6d10fc8b59 | from django.template.defaultfilters import center
from django.test import SimpleTestCase
from django.utils.safestring import mark_safe
from ..utils import setup
class CenterTests(SimpleTestCase):
@setup({'center01': '{% autoescape off %}.{{ a|center:"5" }}. .{{ b|center:"5" }}.{% endautoescape %}'})
def tes... |
f2434640ad204195bb1968254e4c5d1aec2516c561b33650659c01324bcfcea2 | from django.template.defaultfilters import get_digit
from django.test import SimpleTestCase
class FunctionTests(SimpleTestCase):
def test_values(self):
self.assertEqual(get_digit(123, 1), 3)
self.assertEqual(get_digit(123, 2), 2)
self.assertEqual(get_digit(123, 3), 1)
self.assertE... |
ab346b163a63dedb6d134d60195dce3b2aaca704d35cb2dc4fcbd6fea1a0f20b | from django.template.defaultfilters import divisibleby
from django.test import SimpleTestCase
class FunctionTests(SimpleTestCase):
def test_true(self):
self.assertIs(divisibleby(4, 2), True)
def test_false(self):
self.assertIs(divisibleby(4, 3), False)
|
4613429ca08dfa7ce3ce2eec08542661546401b99dc094a57a3d0e38de3f0f70 | from django.template.defaultfilters import default_if_none
from django.test import SimpleTestCase
class FunctionTests(SimpleTestCase):
def test_value(self):
self.assertEqual(default_if_none("val", 'default'), 'val')
def test_none(self):
self.assertEqual(default_if_none(None, 'default'), 'def... |
e0a8fd2bca0ae705d9bafcaea3fe86b9fdd332279e327e3f9d3aff79e5cb7c54 | from django.template.defaultfilters import length
from django.test import SimpleTestCase
from django.utils.safestring import mark_safe
from ..utils import setup
class LengthTests(SimpleTestCase):
@setup({'length01': '{{ list|length }}'})
def test_length01(self):
output = self.engine.render_to_string... |
45926f812597e02c30b6f36abe9129159562257e00f12a5acd19883d7c899e10 | from decimal import Decimal
from django.template.defaultfilters import pluralize
from django.test import SimpleTestCase
from ..utils import setup
class PluralizeTests(SimpleTestCase):
def check_values(self, *tests):
for value, expected in tests:
with self.subTest(value=value):
... |
481891803b85357d6d53d3d856ec5be9c6ac7d5125b401c0bf62601a8fde26fe | from django.template.defaultfilters import escapejs_filter
from django.test import SimpleTestCase
from django.utils.functional import lazy
from ..utils import setup
class EscapejsTests(SimpleTestCase):
@setup({'escapejs01': '{{ a|escapejs }}'})
def test_escapejs01(self):
output = self.engine.render_... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.