hash stringlengths 64 64 | content stringlengths 0 1.51M |
|---|---|
d5fac8d7c6acb3753ad8f42879b4bcca79f53f991a9f39cc97a51290d0b61201 | import datetime
from django import forms
from django.core.exceptions import ValidationError
from django.forms.models import ModelChoiceIterator, ModelChoiceIteratorValue
from django.forms.widgets import CheckboxSelectMultiple
from django.template import Context, Template
from django.test import TestCase
from .models ... |
3a0e5c208ec254e8ebe005087e7913f25ca48f3ed30ca05feaa3916d664f2d6b | import datetime
import os
from decimal import Decimal
from unittest import mock, skipUnless
from django import forms
from django.core.exceptions import (
NON_FIELD_ERRORS, FieldError, ImproperlyConfigured, ValidationError,
)
from django.core.files.uploadedfile import SimpleUploadedFile
from django.db import connec... |
a3cfb912d319642163a7bea338aa3424561545305a1dba24642147760695fcdc | import datetime
import os
import tempfile
import uuid
from django.core import validators
from django.core.exceptions import ValidationError
from django.core.files.storage import FileSystemStorage
from django.db import models
temp_storage_dir = tempfile.mkdtemp()
temp_storage = FileSystemStorage(temp_storage_dir)
cl... |
4522465411121e296cf33510e1db7ec41ca071acbbae5d37c260d212a1235464 | from django.db import connection
from django.db.models import CharField, F, Max
from django.db.models.functions import Lower
from django.test import TestCase, skipUnlessDBFeature
from django.test.utils import register_lookup
from .models import Celebrity, Fan, Staff, StaffTag, Tag
@skipUnlessDBFeature('can_distinct_... |
125371066062b4b9a7787f13ed1c68ac9d1c1b67b28d5b0d65e6c52e6cd8ef3c | try:
from django.contrib.gis import admin
except ImportError:
from django.contrib import admin
admin.GISModelAdmin = admin.ModelAdmin
# RemovedInDjango50Warning.
admin.OSMGeoAdmin = admin.ModelAdmin
|
bda24d57522d11290c0cd53015e889e4f532a532153d99538b428c78bc46856c | """
This module has the mock object definitions used to hold reference geometry
for the GEOS and GDAL tests.
"""
import json
import os
from django.utils.functional import cached_property
# Path where reference test data is located.
TEST_DATA = os.path.join(os.path.dirname(__file__), 'data')
def tuplize(seq):
"T... |
36c2d2b721596f75c3c94a7274853be38835c06bdae64ed73819b8d48793ff39 | import re
from django.contrib.gis import forms
from django.contrib.gis.forms import BaseGeometryWidget, OpenLayersWidget
from django.contrib.gis.geos import GEOSGeometry
from django.core.exceptions import ValidationError
from django.test import SimpleTestCase, override_settings
from django.utils.html import escape
c... |
3b0b8f11750c8fa84d2a096e34242cfcf18a2f41db01b2dcce50f9f8f7a7f71b | import datetime
import unittest
try:
import pytz
except ImportError:
pytz = None
from django.test import TestCase, ignore_warnings, override_settings
from django.utils import timezone
from django.utils.deprecation import RemovedInDjango50Warning
from .models import Article, Category, Comment
class DateTime... |
db2a262388f7b7df0596110f5acb1c2e88dffde1f2eb49cdfed57fd09e523831 | from math import ceil
from django.db import connection, models
from django.db.models import ProtectedError, RestrictedError
from django.db.models.deletion import Collector
from django.db.models.sql.constants import GET_ITERATOR_CHUNK_SIZE
from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature
from .mo... |
c82b72925dcad5fd1836c0de066a308a9e13cf4cf7d2bb94a01c8d09236cfebc | from unittest import mock
from django.core.checks import Error, Warning as DjangoWarning
from django.db import connection, models
from django.test.testcases import SimpleTestCase
from django.test.utils import isolate_apps, modify_settings, override_settings
@isolate_apps('invalid_models_tests')
class RelativeFieldTe... |
917b9e182776125cde69e1fdc25d04f8865c6b670e0e81243dc59a0a458f36b3 | import mimetypes
import os
import shutil
import socket
import sys
import tempfile
from email import charset, message_from_binary_file, message_from_bytes
from email.header import Header
from email.mime.text import MIMEText
from email.utils import parseaddr
from io import StringIO
from pathlib import Path
from smtplib i... |
faecd8e59227db602311fe34399acf7bd71cef8d30a3f71d30625d276bcc1972 | import pickle
from django import forms
from django.core.exceptions import ValidationError
from django.db import models
from django.test import SimpleTestCase, TestCase
from django.utils.functional import lazy
from .models import (
Bar, Choiceful, Foo, RenamedField, VerboseNameField, Whiz, WhizDelayed,
WhizIte... |
a781555ec4046afc61934fcbfdbe74dcff2c60fdaa9ad58d0af4c625ab48a151 | import math
from decimal import Decimal
from django.core import validators
from django.core.exceptions import ValidationError
from django.db import models
from django.test import TestCase
from .models import BigD, Foo
class DecimalFieldTests(TestCase):
def test_to_python(self):
f = models.DecimalField(... |
838c880420752ba400e57c8bbe7c495b19d843e9631d8b0ffb1d0306645f64dc | import datetime
import pickle
import unittest
import uuid
from collections import namedtuple
from copy import deepcopy
from decimal import Decimal
from unittest import mock
from django.core.exceptions import FieldError
from django.db import DatabaseError, NotSupportedError, connection
from django.db.models import (
... |
d3d5b45ddbfb7b20e9d15065311842e3c9999e90876ceaba37eef240763169b2 | import copy
import datetime
import pickle
from operator import attrgetter
from django.core.exceptions import FieldError
from django.db import models
from django.test import SimpleTestCase, TestCase, skipUnlessDBFeature
from django.test.utils import isolate_apps
from django.utils import translation
from .models import... |
fe6935d4cd9ad75adddd3061e074d323fc3849938c0628d0ab13fac9a159fdcb | import datetime
import re
import sys
from contextlib import contextmanager
from unittest import SkipTest, skipIf
from xml.dom.minidom import parseString
try:
import zoneinfo
except ImportError:
from backports import zoneinfo
try:
import pytz
except ImportError:
pytz = None
from django.contrib.auth.mo... |
a8fbfb58c8a212c44fd6af90a2024fc4641d5aa1d8b0c4d370cb8f253348b936 | from unittest import mock
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ObjectDoesNotExist
from django.db import connection
from django.db.models import Prefetch, QuerySet, prefetch_related_objects
from django.db.models.query import get_prefetcher
from django.db.models.s... |
563dcfa28e5bf3f9217bbcabefea2be0f855e8e14ce04ac7f817c4f5a98e39cf | from django.db import DatabaseError, connection
from django.db.models import Index
from django.test import TransactionTestCase, skipUnlessDBFeature
from .models import (
Article, ArticleReporter, CheckConstraintModel, City, Comment, Country,
District, Reporter, UniqueConstraintConditionModel,
)
class Introsp... |
191aeb35feaf727c4525ac5de684771f13a3180e5ac71cf1d7250450b15eb08a | import os
import re
import shutil
import tempfile
import time
import warnings
from io import StringIO
from pathlib import Path
from unittest import mock, skipIf, skipUnless
from admin_scripts.tests import AdminScriptTestCase
from django.core import management
from django.core.management import execute_from_command_li... |
af53ae5ac4e85c72b31e24b612559d28ce52bc94651b337e82bce30521eeb8e2 | import datetime
import decimal
import gettext as gettext_module
import os
import pickle
import re
import tempfile
from contextlib import contextmanager
from importlib import import_module
from pathlib import Path
from unittest import mock
from asgiref.local import Local
from django import forms
from django.apps impor... |
7cec017a775ee949b635bff1ff8795a5d432f136b30cd372ebd238024bf80318 | from operator import attrgetter
from django.contrib.contenttypes.models import ContentType
from django.contrib.sessions.backends.db import SessionStore
from django.db import models
from django.db.models import Count
from django.test import TestCase, ignore_warnings, override_settings
from django.utils.deprecation impo... |
e13f2c4be8ef10c22e478771a08876c229bf0da89c733706cef3b9c703405bd8 | import collections.abc
from datetime import datetime
from math import ceil
from operator import attrgetter
from unittest import skipUnless
from django.core.exceptions import FieldError
from django.db import connection, models
from django.db.models import (
BooleanField, Case, Exists, ExpressionWrapper, F, Max, Out... |
f839234f7dc04fa7a22c16015188fa5855d0fd8758c60e5232a264c471aabdbd | from django.contrib.contenttypes.fields import (
GenericForeignKey, GenericRelation,
)
from django.contrib.contenttypes.models import ContentType
from django.core.checks import Error
from django.core.exceptions import FieldDoesNotExist, FieldError
from django.db import models
from django.test import SimpleTestCase
... |
940afb5833f1a854da4d8645787f376de1f2b17836cb9593c51805f8ae85759c | from unittest import mock
from django.apps.registry import Apps
from django.db import models
from django.db.models import signals
from django.dispatch import receiver
from django.test import SimpleTestCase, TestCase
from django.test.utils import isolate_apps
from .models import Author, Book, Car, Page, Person
class... |
38b2857fa79e881debe32adfd0e39272959efcab396f773b71335d627d2713b2 | """
Testing signals before/after saving and deleting.
"""
from django.db import models
class Person(models.Model):
first_name = models.CharField(max_length=20)
last_name = models.CharField(max_length=20)
def __str__(self):
return "%s %s" % (self.first_name, self.last_name)
class Car(models.Mode... |
9588b09b3b760e30cbfe33c88b6821c8d810650399d3c26f7486ac48c8e22a52 | import datetime
from django.contrib import admin
from django.contrib.admin.models import LogEntry
from django.contrib.admin.options import IncorrectLookupParameters
from django.contrib.admin.templatetags.admin_list import pagination
from django.contrib.admin.tests import AdminSeleniumTestCase
from django.contrib.admin... |
8a89808279bc3a8058368d619758afaaed4ba0085e13b76656b6953746af98f7 | from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User
from django.core.paginator import Paginator
from .models import Band, Child, Event, Parent, Swallow
site = admin.AdminSite(name="admin")
site.register(User, UserAdmin)
class CustomPaginator(... |
7efcea31437ac33e14c1455d9339b0f2252b1a7dce06f310dfffadd9603c0a3d | import gettext
import os
import re
from datetime import datetime, timedelta
from importlib import import_module
try:
import zoneinfo
except ImportError:
from backports import zoneinfo
from django import forms
from django.conf import settings
from django.contrib import admin
from django.contrib.admin import wi... |
f5c63b13f5b05aace4291b0f28c40d7587901e12c5d395c2f27964f20f1077d1 | from django import forms
from django.contrib import admin
from django.contrib.admin.widgets import AutocompleteSelect
from django.forms import ModelChoiceField
from django.test import TestCase, override_settings
from django.utils import translation
from .models import Album, Band, ReleaseEvent, VideoStream
class Alb... |
11b8c0370a2575999ce88aaff8705ccd6b361c7a719ffdfe0943341925995030 | from django.core.exceptions import FieldError
from django.test import TestCase
from .models import (
Entry, Line, Post, RegressionModelSplit, SelfRefer, SelfReferChild,
SelfReferChildSibling, Tag, TagCollection, Worksheet,
)
class M2MRegressionTests(TestCase):
def test_multiple_m2m(self):
# Multi... |
c2235f0d044729615887965f1b02d6ffbf29aa1d50bde5db644223b3ef8b092f | from django.db import migrations
def forwards(apps, schema_editor):
pass
class Migration(migrations.Migration):
dependencies = [
('migrations', '0001_initial'),
]
operations = [
migrations.RunPython(forwards, migrations.RunPython.noop),
]
|
ae97fbec4c3e1bd811096751d6804f3c3a5042c87717114eb38adff360ffd700 | from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
operations = [
migrations.CreateModel(
'SomeModel',
[
('id', models.AutoField(primary_key=True)),
('name', models.CharField(max_length=255)),
... |
509ffe90fdb9e7cce2c76cb1c87db853367167805004ff586d3554406b452259 | from django.db import migrations, models
class Migration(migrations.Migration):
operations = [
migrations.CreateModel(
"Author",
[
("id", models.AutoField(primary_key=True)),
("name", models.CharField(max_length=255)),
],
),
... |
bfabc1a92cd92377385f35c4bf9ad829e5a1de1db5ce81730465c06b73e7bec3 | from unittest import TestCase, expectedFailure
class FailureTestCase(TestCase):
def test_sample(self):
self.assertEqual(0, 1)
class ErrorTestCase(TestCase):
def test_sample(self):
raise Exception('test')
class ExpectedFailureTestCase(TestCase):
@expectedFailure
def test_sample(self... |
a7e21af062191b45daadab8e229739f2a0f0725602737b6892f598b22221b1a8 | from django.core.management.base import BaseCommand
class Command(BaseCommand):
def add_arguments(self, parser):
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument('--for', dest='until', action='store')
group.add_argument('--until', action='store')
def handl... |
9795a8655603969fdd58f956e8abb348dc03d1e5474ded88a10f46dd25aa413f | from django.db import migrations, models
from ..fields import (
ArrayField, BigIntegerRangeField, CICharField, CIEmailField, CITextField,
DateRangeField, DateTimeRangeField, DecimalRangeField, EnumField,
HStoreField, IntegerRangeField, SearchVectorField,
)
from ..models import TagField
class Migration(mi... |
c2cdf836d2d4aa0e28be5184d218a7266b0d29c881fee6538039a34ac6f3b30f | from datetime import datetime
from django.forms import DateTimeInput
from django.test import ignore_warnings
from django.utils import translation
from django.utils.deprecation import RemovedInDjango50Warning
from .base import WidgetTest
class DateTimeInputTest(WidgetTest):
widget = DateTimeInput()
def test... |
83e951700fa130d5ce5db95e95a438d9e97d8d36958a2522c716d1506d2399f0 | from django.forms.widgets import NumberInput
from django.test import override_settings
from .base import WidgetTest
class NumberInputTests(WidgetTest):
@override_settings(USE_THOUSAND_SEPARATOR=True)
def test_attrs_not_localized(self):
widget = NumberInput(attrs={'max': 12345, 'min': 1234, 'step': 9... |
8d180311f84e024520180e68bc49b59e2fa170fc8cf16c53d57075b23738f1bd | import datetime
from django import forms
from django.forms import CheckboxSelectMultiple
from django.test import override_settings
from .base import WidgetTest
class CheckboxSelectMultipleTest(WidgetTest):
widget = CheckboxSelectMultiple
def test_render_value(self):
self.check_html(self.widget(choi... |
7cc72301662217ffd3192cef333054833235360928ccf4de73efe2b4df1c6297 | from datetime import date
from django.forms import DateInput
from django.utils import translation
from .base import WidgetTest
class DateInputTest(WidgetTest):
widget = DateInput()
def test_render_none(self):
self.check_html(self.widget, 'date', None, html='<input type="text" name="date">')
de... |
967f9e4cde294e9455c82f452de9f406c3489a9820ed635a0afaf0522f1d1a1c | from datetime import date
from django.forms import DateField, Form, SelectDateWidget
from django.test import ignore_warnings, override_settings
from django.utils import translation
from django.utils.dates import MONTHS_AP
from django.utils.deprecation import RemovedInDjango50Warning
from .base import WidgetTest
cla... |
87d92b301ca4a14730a7f408d2c13afdfb9eebe6d4b3bb3314b526ee2f018e68 | from datetime import datetime
from django.forms import SplitHiddenDateTimeWidget
from django.utils import translation
from .base import WidgetTest
class SplitHiddenDateTimeWidgetTest(WidgetTest):
widget = SplitHiddenDateTimeWidget()
def test_render_empty(self):
self.check_html(self.widget, 'date', ... |
0c56922e30b1f688c375513cc48d9963270f448c8c9ed3168f25b5e1646548f9 | import copy
import datetime
from django.forms import Select
from django.test import override_settings
from django.utils.safestring import mark_safe
from .base import WidgetTest
class SelectTest(WidgetTest):
widget = Select
nested_widget = Select(choices=(
('outer1', 'Outer 1'),
('Group "1"',... |
a8a41f2f4eac14f9f55dbf365425de1d2ef5d2bbbbc8acb30b65d90d1b7a0fbd | from django.forms import NullBooleanSelect
from django.utils import translation
from .base import WidgetTest
class NullBooleanSelectTest(WidgetTest):
widget = NullBooleanSelect()
def test_render_true(self):
self.check_html(self.widget, 'is_cool', True, html=(
"""<select name="is_cool">
... |
0623b5c1dd014f5f49de6fe4e0d6a4da4bf2f83e362dd81feeebc9adb185ab02 | from datetime import time
from django.forms import TimeInput
from django.utils import translation
from .base import WidgetTest
class TimeInputTest(WidgetTest):
widget = TimeInput()
def test_render_none(self):
self.check_html(self.widget, 'time', None, html='<input type="text" name="time">')
de... |
7ad88cdc9874ae89c9b7c4c009f633b3bc3004788dac732ea24846930cd51dcb | import datetime
from django.forms import MultiWidget, RadioSelect
from django.test import override_settings
from .base import WidgetTest
class RadioSelectTest(WidgetTest):
widget = RadioSelect
def test_render(self):
choices = (('', '------'),) + self.beatles
self.check_html(self.widget(choi... |
4a44eeb08712f1f2c694bac18b06df1d68e5d7d8b4539666febefb01402b05cd | from datetime import date, datetime
from django.core.exceptions import ValidationError
from django.forms import DateField, Form, HiddenInput, SelectDateWidget
from django.test import SimpleTestCase
from django.utils import translation
class GetDate(Form):
mydate = DateField(widget=SelectDateWidget)
class DateF... |
00b8278bfefac6083b3a86e70a90bc24cb92a7081a1109b497ff07c69d13109e | import datetime
from django.core.exceptions import ValidationError
from django.forms import DurationField
from django.test import SimpleTestCase
from django.utils import translation
from django.utils.duration import duration_string
from . import FormFieldAssertionsMixin
class DurationFieldTest(FormFieldAssertionsMi... |
c3206e5ab8c6f308cf1216a10507e63f40590c9317d595a421cc972e349990b6 | import datetime
from django.core.exceptions import ValidationError
from django.forms import Form, SplitDateTimeField
from django.forms.widgets import SplitDateTimeWidget
from django.test import SimpleTestCase
class SplitDateTimeFieldTest(SimpleTestCase):
def test_splitdatetimefield_1(self):
f = SplitDat... |
88ff5bdcde6e292413d60ba2d462a6bc944b51c777c6ba46f7d80ab20ff94056 | from datetime import datetime
from django.core.exceptions import ValidationError
from django.forms import (
CharField, Form, MultipleChoiceField, MultiValueField, MultiWidget,
SelectMultiple, SplitDateTimeField, SplitDateTimeWidget, TextInput,
)
from django.test import SimpleTestCase
beatles = (('J', 'John'),... |
54a15197ccb21f4d1857ce513c137d242e5b348dadfb098465358cf37adf52e4 | from django.core.exceptions import ValidationError
from django.forms import URLField
from django.test import SimpleTestCase
from . import FormFieldAssertionsMixin
class URLFieldTest(FormFieldAssertionsMixin, SimpleTestCase):
def test_urlfield_widget(self):
f = URLField()
self.assertWidgetRenders... |
5c16d101d62971d32820866507c760ea9fee0cbb029941899a544866cb25568b | import decimal
from django.core.exceptions import ValidationError
from django.forms import DecimalField, NumberInput, Widget
from django.test import SimpleTestCase, ignore_warnings, override_settings
from django.utils import formats, translation
from django.utils.deprecation import RemovedInDjango50Warning
from . imp... |
b3038c743e31a2d6d0db38eaafe4bba4e69bcf7b017b55d7103a37c547cf9161 | from django.core.exceptions import ValidationError
from django.forms import FloatField, NumberInput
from django.test import SimpleTestCase
from django.test.utils import ignore_warnings, override_settings
from django.utils import formats, translation
from django.utils.deprecation import RemovedInDjango50Warning
from . ... |
7c465c54b8a331b430fd186fe9a29a639cfdc948ed4a2654d61df889b68ad414 | import datetime
from collections import Counter
from unittest import mock
from django.core.exceptions import ValidationError
from django.forms import (
BaseForm, CharField, DateField, FileField, Form, IntegerField,
SplitDateTimeField, formsets,
)
from django.forms.formsets import (
INITIAL_FORM_COUNT, MAX_... |
93dc7012e96b57e3f9256f94671f636ea4e67b08c5ff19255e5e7611c407e807 | import copy
import json
from django.core.exceptions import ValidationError
from django.forms.utils import ErrorDict, ErrorList, flatatt
from django.test import SimpleTestCase
from django.utils.safestring import mark_safe
from django.utils.translation import gettext_lazy
class FormsUtilsTestCase(SimpleTestCase):
... |
ac18a01e40e5b85105f38b45cb9ffb56259b99d5bde8fef2f6cc1233279be4b6 | import datetime
from django.core.files.uploadedfile import SimpleUploadedFile
from django.db import models
from django.forms import CharField, FileField, Form, ModelForm
from django.forms.models import ModelFormMetaclass
from django.test import SimpleTestCase, TestCase
from ..models import (
BoundaryModel, Choice... |
6fdb929a09fc08f3f801321bfe3ea6c4e9f79d372a09c01b8099738020e26c25 | from unittest import skipIf
from django.test.utils import override_settings
try:
import jinja2
except ImportError:
jinja2 = None
def jinja2_tests(test_func):
test_func = skipIf(jinja2 is None, 'this test requires jinja2')(test_func)
return override_settings(
FORM_RENDERER='django.forms.rende... |
cab844e1bd04f214a027607c472d5425b163a79c2dd36d0b6321cd9ddf6af810 | # RemovedInDjango50
from django.forms import CharField, EmailField, Form, HiddenInput
from django.forms.utils import ErrorList
from django.test import SimpleTestCase, ignore_warnings
from django.utils.deprecation import RemovedInDjango50Warning
from .test_forms import Person
class DivErrorList(ErrorList):
def __... |
d2239f0be2058be107932e9229952fcca0dd4259f8e10595dc2692583a258aaf | from datetime import date, datetime, time
from django import forms
from django.core.exceptions import ValidationError
from django.test import SimpleTestCase, override_settings
from django.utils import translation
from django.utils.translation import activate, deactivate
class LocalizedTimeTests(SimpleTestCase):
... |
ee91ba6d5b53e8800ae60d719f7fbabe7d119e6b64f216344f877c519073e0ca | from django.forms import (
CharField, ChoiceField, Form, IntegerField, RadioSelect, Select, TextInput,
)
from django.test import SimpleTestCase
from django.utils import translation
from django.utils.translation import gettext_lazy
from . import jinja2_tests
class FormsI18nTests(SimpleTestCase):
def test_lazy... |
768cd82fecdddd83b5293a5bc50891dbed905179b1e6e0ab056c39f894001641 | from django.contrib.admin.tests import AdminSeleniumTestCase
from django.test import override_settings
from django.urls import reverse
from ..models import Article
@override_settings(ROOT_URLCONF='forms_tests.urls')
class LiveWidgetTests(AdminSeleniumTestCase):
available_apps = ['forms_tests'] + AdminSeleniumTe... |
3136025dfc3372bb9cb11d406bc50f8c0afc3983712466a9a65eaee8b6cff513 | from django.forms import CharField, Form, Media, MultiWidget, TextInput
from django.template import Context, Template
from django.test import SimpleTestCase, override_settings
@override_settings(
STATIC_URL='http://media.example.com/static/',
)
class FormsMediaTestCase(SimpleTestCase):
"""Tests for the media ... |
ae5528494b717f44ca9e2e647df77eaf6f0636b8f50c24c038e37deefc90a300 | import copy
import datetime
import json
import uuid
from django.core.exceptions import NON_FIELD_ERRORS
from django.core.files.uploadedfile import SimpleUploadedFile
from django.core.validators import MaxValueValidator, RegexValidator
from django.forms import (
BooleanField, CharField, CheckboxSelectMultiple, Choi... |
2bc19c59e1165d8fc435d43c6bb3b4196e971fb8e0778bd63a3f8faaac13a610 | from django.template import Library, Node
register = Library()
class CountRenderNode(Node):
count = 0
def render(self, context):
self.count += 1
for v in context.flatten().values():
try:
v.render()
except AttributeError:
pass
re... |
d9fcd8252c3af6cabaf223d1c9a4ead41919fe6ad31d3cb278009cffd5cbc89b | import gettext
import json
from os import path
from django.conf import settings
from django.test import (
RequestFactory, SimpleTestCase, TestCase, modify_settings,
override_settings,
)
from django.test.selenium import SeleniumTestCase
from django.urls import reverse
from django.utils.translation import get_la... |
2fa99be6d7c06ed9ae11f5fb3bae674834abd2a414ef22a9721a720ee7ae9d80 | import importlib
import inspect
import os
import re
import sys
import tempfile
import threading
from io import StringIO
from pathlib import Path
from unittest import mock
from django.core import mail
from django.core.files.uploadedfile import SimpleUploadedFile
from django.db import DatabaseError, connection
from djan... |
833d6ef567c3c9ace2d6c76c2a8651d88344edb84a5e3648adbe2378a0f623fc | 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'},
{... |
f498417380698b5a431044eb3636a5ccade144adc7095d53f54fe5cbcfd24ed1 | from django.template.defaultfilters import filesizeformat
from django.test import SimpleTestCase
from django.utils import translation
class FunctionTests(SimpleTestCase):
def test_formats(self):
tests = [
(0, '0\xa0bytes'),
(1, '1\xa0byte'),
(1023, '1023\xa0bytes'),
... |
a48ac00afaa15d0e368eec752398b36e8cf50e6cd5289acc1c6290cab81a61a2 | from datetime import datetime, time
from django.template.defaultfilters import date
from django.test import SimpleTestCase
from django.utils import timezone, translation
from ..utils import setup
from .timezone_utils import TimezoneTestCase
class DateTests(TimezoneTestCase):
@setup({'date01': '{{ d|date:"m" }}... |
e85d1309e96a9c32cc1712c3c5cd97bda3c3a978035128a7c5ad3acfc13f84a8 | from decimal import Decimal, localcontext
from django.template.defaultfilters import floatformat
from django.test import SimpleTestCase
from django.utils import translation
from django.utils.safestring import mark_safe
from ..utils import setup
class FloatformatTests(SimpleTestCase):
@setup({'floatformat01': '... |
92fd3081d6f21fd19c566f4a970f4a292f0885226d7112ba66f98dec1c2f30af | from django.test import SimpleTestCase
from ..utils import setup
class JsonScriptTests(SimpleTestCase):
@setup({'json-tag01': '{{ value|json_script:"test_id" }}'})
def test_basic(self):
output = self.engine.render_to_string(
'json-tag01',
{'value': {'a': 'testing\r\njson \'st... |
747ad85b8ec3fe156670cae6d9971e97cb684f5f38228cf55a94266aefa86bb1 | from datetime import time
from django.template.defaultfilters import time as time_filter
from django.test import SimpleTestCase
from django.utils import timezone, translation
from ..utils import setup
from .timezone_utils import TimezoneTestCase
class TimeTests(TimezoneTestCase):
"""
#20693: Timezone suppor... |
fd25ea4630eeb7f4488a91ec7a1d51a81d07dd409545d68be7c92fd384edf2d7 | from django.template.defaultfilters import _property_resolver, dictsort
from django.test import SimpleTestCase
class User:
password = 'abc'
_private = 'private'
@property
def test_property(self):
return 'cde'
def test_method(self):
"""This is just a test method."""
class Funct... |
1243d24d7864195daee926bc40675f9c117b22395fac4324c072b3e78b0613c2 | import operator
from django import template
from django.template.defaultfilters import stringfilter
from django.utils.html import escape, format_html
from django.utils.safestring import mark_safe
register = template.Library()
@register.filter
@stringfilter
def trim(value, num):
return value[:num]
@register.fi... |
68d1929c8a1321c4fa5363d36e641e9a71c9845ec82e8701174eec51778f5cc1 | import operator
from django.template import Engine, Library
engine = Engine(app_dirs=True)
register = Library()
@register.inclusion_tag('inclusion.html')
def inclusion_no_params():
"""Expected inclusion_no_params __doc__"""
return {"result": "inclusion_no_params - Expected result"}
inclusion_no_params.any... |
07048693859686844b0ce567c9347e6c172b90d8543cdb34c2b8d9a8923f7658 | from django.contrib.sitemaps import views
from django.urls import path
urlpatterns = [
path(
'sitemap-without-entries/sitemap.xml', views.sitemap,
{'sitemaps': {}}, name='django.contrib.sitemaps.views.sitemap',
),
]
|
083c278da232751e6ad004f18a2c16df528a3b7b7ef0bb0962397c751a344e15 | from datetime import date, datetime
from django.conf.urls.i18n import i18n_patterns
from django.contrib.sitemaps import GenericSitemap, Sitemap, views
from django.http import HttpResponse
from django.urls import path
from django.utils import timezone
from django.views.decorators.cache import cache_page
from ..models ... |
904e0b3dd815452db99c3008980c226ddda9dd79cd1d891874695f4728c2fc67 | import unittest
from django.db import DatabaseError, connection
from django.db.models import BooleanField
from django.test import TransactionTestCase
from ..models import (
Square, VeryLongModelNameZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ,
)
@unittest.skipUnless(connection.vendor == 'oracle', 'Oracle tests')
... |
1d2f2ed0e9ddf7d22c2fa5b6a1eb6efb0c943cc665bb9fb292fbcd9765f77c58 | from django.db.backends.sqlite3._functions import (
_sqlite_date_trunc, _sqlite_datetime_trunc, _sqlite_time_trunc,
)
from django.test import SimpleTestCase
class FunctionTests(SimpleTestCase):
def test_sqlite_date_trunc(self):
msg = "Unsupported lookup type: 'unknown-lookup'"
with self.assert... |
326c7999c431e1459c278e4bed9727deb01aa03e8aed34e4393f87da056cf9b0 | import unittest
import sqlparse
from django.db import connection
from django.test import TestCase
@unittest.skipUnless(connection.vendor == 'sqlite', 'SQLite tests')
class IntrospectionTests(TestCase):
def test_get_primary_key_column(self):
"""
Get the primary key column regardless of whether or... |
56033b0c24d0ae220e58e25b9bcaf07f44983f8cbc4cdae7cef4b76b84d6a870 | import decimal
from django.core.management.color import no_style
from django.db import NotSupportedError, connection, transaction
from django.db.backends.base.operations import BaseDatabaseOperations
from django.db.models import DurationField, Value
from django.test import (
SimpleTestCase, TestCase, TransactionTe... |
f8152a120f5f42a855e3420eccf5a307b3a85434f43e382f3c0f6a921d390fc3 | from unittest.mock import MagicMock, patch
from django.db import DEFAULT_DB_ALIAS, connection, connections
from django.db.backends.base.base import BaseDatabaseWrapper
from django.test import SimpleTestCase, TestCase, skipUnlessDBFeature
from ..models import Square
class DatabaseWrapperTests(SimpleTestCase):
d... |
657b8e107dfab524344f56ddebdf9c8e86461ff2f055ed1330466390faeb15c4 | from django.db import connection
from django.db.backends.base.introspection import BaseDatabaseIntrospection
from django.test import SimpleTestCase
class SimpleDatabaseIntrospectionTests(SimpleTestCase):
may_require_msg = (
'subclasses of BaseDatabaseIntrospection may require a %s() method'
)
def... |
75e8d61b323a21ccccf3db4c460ad630af1aa9f13294843e9f400d688ce17ce5 | import copy
import datetime
import os
from unittest import mock
from django.db import DEFAULT_DB_ALIAS, connection, connections
from django.db.backends.base.creation import (
TEST_DATABASE_PREFIX, BaseDatabaseCreation,
)
from django.test import SimpleTestCase, TransactionTestCase
from django.test.utils import over... |
746aba59ff68d06214699f5063ade3350831f9a47697e7598cf147fc5dded30d | from unittest import skipUnless
from django.db import connection, connections
from django.test import TestCase
@skipUnless(connection.vendor == 'mysql', 'MySQL tests')
class ParsingTests(TestCase):
def test_parse_constraint_columns(self):
_parse_constraint_columns = connection.introspection._parse_constr... |
e3ce042ff52c1f872117abc97826f5a2edd221e48e3380e6c247a6775c81ffd0 | import copy
import unittest
from io import StringIO
from unittest import mock
from django.core.exceptions import ImproperlyConfigured
from django.db import DEFAULT_DB_ALIAS, DatabaseError, connection, connections
from django.db.backends.base.base import BaseDatabaseWrapper
from django.test import TestCase, override_se... |
32217406d122f172b2135c8040b98eb51a13e8afdd6389d25fc0e5ce7ca30a14 | from django.apps import AppConfig
class SameTagsApp1AppConfig(AppConfig):
name = 'check_framework.template_test_apps.same_tags_app_1'
|
6bce5c1115019fbafdcd5d42c73494dccc1299c4adceb97dcbead6b21b7225ec | from django.apps import AppConfig
class SameTagsApp2AppConfig(AppConfig):
name = 'check_framework.template_test_apps.same_tags_app_2'
|
3ae30fb2dd7d403aec229e5c41a00d20866b51a5f6d61e278d64c563b2f8e602 | from django.apps import AppConfig
class DifferentTagsAppAppConfig(AppConfig):
name = 'check_framework.template_test_apps.different_tags_app'
|
aeac4d6cf18a5c72b5a7d7f221248995f78d05c02a5bcf11e07e9bdb3c99ece8 | # The {{ project_name }} should be rendered.
|
385f11de3df745174512c33d219178c4c0b456154365e86332f9e957c5636800 | from django.core.management import BaseCommand
class Command(BaseCommand):
help = 'Test suppress base options command.'
requires_system_checks = []
suppressed_base_arguments = {
'-v',
'--traceback',
'--settings',
'--pythonpath',
'--no-color',
'--force-color... |
d17fb6ab1fdd1685bd8793f7e1bea3898e74c52ee3e15a8667e1a6cf2f1bed8a | import os
import re
from io import StringIO
from django.contrib.gis.gdal import GDAL_VERSION, Driver, GDALException
from django.contrib.gis.utils.ogrinspect import ogrinspect
from django.core.management import call_command
from django.db import connection, connections
from django.test import SimpleTestCase, TestCase, ... |
cc0a6e9b5abaa7c23b73082880a4a33247c63209d30a2ca218a0dada8f091e39 | from django.contrib.gis import admin
from django.contrib.gis.geos import Point
from django.test import SimpleTestCase, ignore_warnings, override_settings
from django.utils.deprecation import RemovedInDjango50Warning
from .admin import UnmodifiableAdmin
from .models import City, site
@ignore_warnings(category=Removed... |
4cf05a0bdc43614c3fed2b3ca57c19ea5738574872ddee1f1651824d16b363be | from django.contrib.gis.db import models
from django.test import ignore_warnings
from django.utils.deprecation import RemovedInDjango50Warning
from ..admin import admin
class City(models.Model):
name = models.CharField(max_length=30)
point = models.PointField()
class Meta:
app_label = 'geoadmini... |
f6044f6131af3061bd524568d7e0412a731150c2c2bc2865bd9ee3684eb4577c | from unittest import skipUnless
from django.contrib.gis.db.models import fields
from django.contrib.gis.geos import MultiPolygon, Polygon
from django.core.exceptions import ImproperlyConfigured
from django.db import connection, migrations, models
from django.db.migrations.migration import Migration
from django.db.migr... |
8d6adfb5c5ecfee78d9522abb401106a2c053b83e077ac525cc910d6481fb8e7 | import binascii
from django.contrib.gis.geos import (
GEOSGeometry, Point, Polygon, WKBReader, WKBWriter, WKTReader, WKTWriter,
)
from django.contrib.gis.geos.libgeos import geos_version_tuple
from django.test import SimpleTestCase
class GEOSIOTest(SimpleTestCase):
def test01_wktreader(self):
# Crea... |
3eb0102df7391132e42825a8c9e315e0657dceeee1fb8b123e59bb90113d3b7f | import ctypes
import itertools
import json
import pickle
import random
from binascii import a2b_hex
from io import BytesIO
from unittest import mock, skipIf
from django.contrib.gis import gdal
from django.contrib.gis.geos import (
GeometryCollection, GEOSException, GEOSGeometry, LinearRing, LineString,
MultiLi... |
792afaba6dfa35e951fbe7bec30735923914bcaddcfa74dfad2a22c59abe9d57 | import os
import re
from datetime import datetime
from pathlib import Path
from django.contrib.gis.gdal import (
DataSource, Envelope, GDALException, OGRGeometry,
)
from django.contrib.gis.gdal.field import (
OFTDateTime, OFTInteger, OFTReal, OFTString,
)
from django.contrib.gis.geos import GEOSGeometry
from d... |
a6df9af5802375930c6eb430a8f9bfb117a570efb091309e0238899f8669dda2 | from unittest import skipIf
from django.contrib.gis.gdal import (
GDAL_VERSION, AxisOrder, CoordTransform, GDALException, SpatialReference,
SRSException,
)
from django.contrib.gis.geos import GEOSGeometry
from django.test import SimpleTestCase
class TestSRS:
def __init__(self, wkt, **kwargs):
sel... |
54a29166bfce357b315183a2fb415614f664d9c97fa45654ff7173659e26ea48 | from django.contrib.gis.geos import Point
from django.test import SimpleTestCase, override_settings
from .models import City, site, site_gis, site_gis_custom
@override_settings(ROOT_URLCONF='django.contrib.gis.tests.geoadmin.urls')
class GeoAdminTest(SimpleTestCase):
admin_site = site # ModelAdmin
def test... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.