hash
stringlengths
64
64
content
stringlengths
0
1.51M
bab69f164decdcffd394c7b09243b950b067cdd27542fc6ed7475babeacc1fcf
import datetime import sys import unittest from django.contrib.admin import ( AllValuesFieldListFilter, BooleanFieldListFilter, EmptyFieldListFilter, FieldListFilter, ModelAdmin, RelatedOnlyFieldListFilter, SimpleListFilter, site, ) from django.contrib.admin.options import IncorrectLookupParameters from dj...
81174282115b8a8906e4445874b57fb77b358dce48c3fbc05ce5e85afda19df5
import logging from contextlib import contextmanager from io import StringIO from admin_scripts.tests import AdminScriptTestCase from django.conf import settings from django.core import mail from django.core.exceptions import ( DisallowedHost, PermissionDenied, SuspiciousOperation, ) from django.core.files.temp i...
f9b19d9e5bc643a535ba9711b5aaab4d97a11035bd0783ebb0d12ab2082cd79e
import os from io import StringIO from unittest import mock from admin_scripts.tests import AdminScriptTestCase from django.apps import apps from django.core import management from django.core.checks import Tags from django.core.management import BaseCommand, CommandError, find_commands from django.core.management.ut...
5cee12f91bcefd5941c88e6c5842b7270070f044104bf827a2f27643d0611909
import os from django.apps import AppConfig, apps from django.apps.registry import Apps from django.contrib.admin.models import LogEntry from django.core.exceptions import AppRegistryNotReady, ImproperlyConfigured from django.db import models from django.test import SimpleTestCase, override_settings from django.test.u...
707dfd9fc16aab43286d8bdd766758b46dd1b88bf920020296dc8a5a6a1a61db
import sys import unittest from django.conf import settings from django.contrib import admin from django.contrib.admindocs import utils, views from django.contrib.admindocs.views import get_return_data_type, simplify_regex from django.contrib.sites.models import Site from django.db import models from django.db.models ...
05ba9ea76d435d60d7448c46ae0f2369169e65bfb345455455ef4db67903c72a
import errno import gzip import os import struct import tempfile import unittest from io import BytesIO, StringIO, TextIOWrapper from pathlib import Path from unittest import mock from django.core.files import File, locks from django.core.files.base import ContentFile from django.core.files.move import file_move_safe ...
24a7024305b3bb63eb1515b4a77f876b05ad92a8861819362d535597709dec29
import decimal import enum import json import unittest import uuid from django import forms from django.core import checks, exceptions, serializers, validators from django.core.exceptions import FieldError from django.core.management import call_command from django.db import IntegrityError, connection, models from dja...
b07b40f62a2c36d9d3c624929c0311824ac23e17180a6e73b937a24590fcd94d
from django.test import modify_settings from . import PostgreSQLTestCase from .models import CharFieldModel, TextFieldModel try: from django.contrib.postgres.search import ( TrigramDistance, TrigramSimilarity, TrigramWordDistance, TrigramWordSimilarity, ) except ImportError: pass @modify...
690319f267dabf52d7b734e771ec9f3fc3b47182b56b71149db8513d20447f4f
from django.db import connection from django.db.models import ( CharField, F, Func, IntegerField, OuterRef, Q, Subquery, Value, ) from django.db.models.fields.json import KeyTextTransform, KeyTransform from django.db.models.functions import Cast, Concat, Substr from django.test import skipUnlessDBFeature from djang...
86b7815c32ea2e13551701975c6f49029e75e98e06e443b11fd6601c6b60799e
import datetime import json from decimal import Decimal from django import forms from django.core import exceptions, serializers from django.db.models import DateField, DateTimeField, F, Func, Value from django.http import QueryDict from django.test import override_settings from django.test.utils import isolate_apps f...
cad30ad7f3c4d6ce81d292fbcf188b0fdccee75f909e333d0f564b3a817cf22c
from django.db import models from .fields import ( ArrayField, BigIntegerRangeField, CICharField, CIEmailField, CITextField, DateRangeField, DateTimeRangeField, DecimalRangeField, EnumField, HStoreField, IntegerRangeField, SearchVectorField, ) class Tag: def __init__(self, tag_id): self.tag_i...
57a3673aadd9465f74076c349e03ed5afc9186ccd132418350cf6c161180a480
""" Indirection layer for PostgreSQL-specific fields, so the tests don't fail when run with a backend other than PostgreSQL. """ import enum from django.db import models try: from django.contrib.postgres.fields import ( ArrayField, BigIntegerRangeField, CICharField, CIEmailField, CITextField, Date...
08333041a9f9a27b66d207322dbeb867635ab51e04ba4e89e5b8be1ebd8db490
from unittest import mock from django.contrib.postgres.indexes import ( BloomIndex, BrinIndex, BTreeIndex, GinIndex, GistIndex, HashIndex, OpClass, SpGistIndex, ) from django.db import NotSupportedError, connection from django.db.models import CharField, F, Index, Q from django.db.models.functions import Cast,...
d0b3a32140594a496436c4375dcef9f43227b4d918f75a4eb9e5b20a49bf6276
from decimal import Decimal from django.db.backends.signals import connection_created from django.db.migrations.writer import MigrationWriter from django.test.utils import modify_settings from . import PostgreSQLTestCase try: from psycopg2.extras import ( DateRange, DateTimeRange, DateTimeTZRange, Numeri...
78bcd1e55ba914958049623dc041b5fa0350d037bcd5b91c5c489285b59a6744
import json from django.core import checks, exceptions, serializers from django.db import connection from django.db.models import F, OuterRef, Subquery from django.db.models.expressions import RawSQL from django.forms import Form from django.test.utils import CaptureQueriesContext, isolate_apps from . import PostgreS...
caf54ce0436e472e8cddea0aa57d065ea41fa8244f5c4751b25947ada911b1b3
import datetime from unittest import mock from django.contrib.postgres.indexes import OpClass from django.db import ( IntegrityError, NotSupportedError, connection, transaction, ) from django.db.models import ( CheckConstraint, Deferrable, F, Func, IntegerField, Q, UniqueConstraint, ) from django.db.models.fie...
163e9d38faa12be72fd2546f7b12a0285a5a069a6625c34d02ca65bb78c4fd87
import datetime from decimal import Decimal from django.core.exceptions import FieldDoesNotExist, FieldError from django.db.models import ( BooleanField, Case, CharField, Count, DateTimeField, DecimalField, Exists, ExpressionWrapper, F, FloatField, Func, IntegerField, Max, OuterRef, Q, Subquery, Sum, Value...
f528c4d44c8d3b05e227072e02ef43d11ccc8affeccab4c20c2de8e41f173b90
import re import types from datetime import datetime, timedelta from decimal import Decimal from unittest import TestCase, mock from django.core.exceptions import ValidationError from django.core.files.base import ContentFile from django.core.validators import ( BaseValidator, DecimalValidator, EmailValidator, Fil...
f606113b3855c364cde37038507d17ded5a6354898eae400858f58c713076f87
import os import re from io import StringIO from unittest import mock, skipUnless from django.core.management import call_command from django.db import connection from django.db.backends.base.introspection import TableInfo from django.test import TestCase, TransactionTestCase, skipUnlessDBFeature from .models import ...
2308ba6f1263364dc3f7872973c609525d9432d079c34f17e1fb04f45a6aed56
from django.db import connection, models class People(models.Model): name = models.CharField(max_length=255) parent = models.ForeignKey('self', models.CASCADE) class Message(models.Model): from_field = models.ForeignKey(People, models.CASCADE, db_column='from_id') class PeopleData(models.Model): p...
8d15106c83dbb589907323d4045161bbd1979d9059fe567ee1b305411185c971
import time from django.core.exceptions import ImproperlyConfigured from django.http import HttpResponse from django.test import RequestFactory, SimpleTestCase, override_settings from django.test.utils import require_jinja2 from django.urls import resolve from django.views.generic import RedirectView, TemplateView, Vi...
0b780cea9df09344bcb329aa88f27e1ee0562168d8412fa43eece6c408dd3d83
from django import forms from django.core.exceptions import ImproperlyConfigured from django.test import SimpleTestCase, TestCase, override_settings from django.test.client import RequestFactory from django.urls import reverse from django.views.generic.base import View from django.views.generic.edit import ( Create...
1f254de1dcb21e8a76d4bb318f00f0aae56ba3252b77b3cc4c53ce298e2dde33
import json import random from django.conf import settings from django.contrib.messages import constants from django.contrib.messages.storage.base import Message from django.contrib.messages.storage.cookie import ( CookieStorage, MessageDecoder, MessageEncoder, ) from django.test import SimpleTestCase, override_se...
ea31500671f5823441392ced0398a8363cbe101758580a4b4b98eff97ae16dd3
from unittest import mock from django.contrib.messages import constants from django.contrib.messages.storage import base from django.contrib.messages.storage.base import Message from django.test import SimpleTestCase, override_settings class MessageTests(SimpleTestCase): def test_eq(self): msg_1 = Messag...
7d72d23176ac6e319e85c7fc99f7f9c619e53f16967542ff6ec304a39ef81ae1
from django.contrib.messages import constants, get_level, set_level from django.contrib.messages.api import MessageFailure from django.contrib.messages.constants import DEFAULT_LEVELS from django.contrib.messages.storage import default_storage from django.contrib.messages.storage.base import Message from django.http im...
f5bdd39e3823d4f35887ac4e9f8d8268a57f9015b6504b63899b852ec44bed32
""" Unit tests for reverse URL lookups. """ import pickle import sys import threading from admin_scripts.tests import AdminScriptTestCase from django.conf import settings from django.contrib.auth.models import User from django.core.exceptions import ImproperlyConfigured, ViewDoesNotExist from django.http import ( ...
dabd8bd1d31d007b0a05e1727c01605b6701ec7da15c4e485ef7618742ab1347
import datetime import os import shutil import tempfile import unittest from io import StringIO from pathlib import Path from unittest import mock from admin_scripts.tests import AdminScriptTestCase from django.conf import settings from django.contrib.staticfiles import storage from django.contrib.staticfiles.managem...
1d3c7e3cd2306fff3fd7ce8cadf4f34fb366c5e23be1790afe5940c0ac9e6745
""" A subset of the tests in tests/servers/tests exercising django.contrib.staticfiles.testing.StaticLiveServerTestCase instead of django.test.LiveServerTestCase. """ import os from urllib.request import urlopen from django.contrib.staticfiles.testing import StaticLiveServerTestCase from django.core.exceptions import...
17967b033004752c34dd5b024387cbd2738af994e8ce7a3ecaa031836d2ded3a
from urllib.parse import urljoin from django.contrib.staticfiles import storage from django.forms import Media from django.templatetags.static import static from django.test import SimpleTestCase, override_settings class StaticTestStorage(storage.StaticFilesStorage): def url(self, name): return urljoin('...
3677fb8ae70172031a8115ac68539c4f6c512ca3256b69258c8b6731052ea01d
import json import os import shutil import sys import tempfile import unittest from io import StringIO from pathlib import Path from unittest import mock from django.conf import settings from django.contrib.staticfiles import finders, storage from django.contrib.staticfiles.management.commands.collectstatic import ( ...
904abc70bf8ff2f378633334bc1b13b718e8190f8e3d751b2ef0476a58f519b1
import unittest from datetime import date, datetime, time, timedelta from decimal import Decimal from operator import attrgetter, itemgetter from uuid import UUID from django.core.exceptions import FieldError from django.db import connection from django.db.models import ( BinaryField, BooleanField, Case, Count, De...
4961e71a2c6bdd92e24fb0f9420f55518c7dd651dae8f022b7241df14482edfc
import io import itertools import os import sys import tempfile from unittest import skipIf from django.core.files.base import ContentFile from django.http import FileResponse from django.test import SimpleTestCase class UnseekableBytesIO(io.BytesIO): def seekable(self): return False class FileResponse...
d05c64a77a46159d50ac0aa662873cf778ca84d4a3fc0d42e245411e8c3edbe2
import json from django.contrib.contenttypes.fields import GenericForeignKey from django.db import models from django.test import TestCase from django.test.utils import isolate_apps from .models import Answer, Post, Question @isolate_apps('contenttypes_tests') class GenericForeignKeyTests(TestCase): def test_s...
136b9c69d957ca6a24d340c715540af681939a3f55da83d3fe70c6e782a91b72
""" Regression tests for the Test Client, especially the customized assertions. """ import itertools import os from django.contrib.auth.models import User from django.contrib.auth.signals import user_logged_in, user_logged_out from django.http import HttpResponse from django.template import ( Context, RequestConte...
5c2397278cab9c0e34147e9c511a7c14ef694c38fcac7546ea38de2d59a93262
from django.apps import apps from django.db import models from django.test import SimpleTestCase, override_settings from django.test.utils import isolate_lru_cache class FieldDeconstructionTests(SimpleTestCase): """ Tests the deconstruct() method on all core fields. """ def test_name(self): "...
fd2fe49316f6b5615e33c2117e24d4196fc3d4bb35924f511eaddb0c60904d31
from django.db.models.base import ModelState, ModelStateCacheDescriptor from django.test import SimpleTestCase class ModelStateTests(SimpleTestCase): def test_fields_cache_descriptor(self): self.assertIsInstance(ModelState.fields_cache, ModelStateCacheDescriptor) def test_related_managers_descriptor...
c2f5cab0e58b8b2302625ccb1d13c82f3646a0ad3793284b3ac96cd4055df314
import os from functools import partial from django.conf.urls.i18n import i18n_patterns from django.urls import include, path, re_path from django.utils.translation import gettext_lazy as _ from django.views import defaults, i18n, static from . import views base_dir = os.path.dirname(os.path.abspath(__file__)) media...
1390e6d53e63eae909fa089c58e9d2398c30da6569b4e9641c062a51648b6ab3
import datetime import decimal import logging import sys from pathlib import Path from django.core.exceptions import ( BadRequest, PermissionDenied, SuspiciousOperation, ) from django.http import Http404, HttpResponse, JsonResponse from django.shortcuts import render from django.template import TemplateDoesNotExis...
f04ec192726947cb4e10e5ebaa4b77bdc25ab4ecaa8bb2b534dbc9acc2fd447c
import sys import threading import time from unittest import skipIf, skipUnless from django.db import ( DatabaseError, Error, IntegrityError, OperationalError, connection, transaction, ) from django.test import ( TestCase, TransactionTestCase, skipIfDBFeature, skipUnlessDBFeature, ) from .models import Re...
3eb90f5da55ed830cbe1b885db326db3e4b3bddd35e3d0fe74bbfb16868ac674
# Unit tests for cache framework # Uses whatever cache backend is set in the test settings file. import copy import io import os import pickle import re import shutil import sys import tempfile import threading import time import unittest from pathlib import Path from unittest import mock, skipIf from django.conf impo...
dfb994f0b3f6e6c0402fd5de17911ccf91241cbce3edc54e80770b95ebaeb1c6
import asyncio from django.core.cache import CacheKeyWarning, cache from django.test import SimpleTestCase, override_settings from .tests import KEY_ERRORS_WITH_MEMCACHED_MSG @override_settings(CACHES={ 'default': { 'BACKEND': 'django.core.cache.backends.dummy.DummyCache', } }) class AsyncDummyCache...
383974a145be34a69387e60c254649e80ab5d8e27bde3a85fbe80d7e8e471add
import os import sys import unittest from importlib import import_module from zipimport import zipimporter from django.test import SimpleTestCase, modify_settings from django.test.utils import extend_sys_path from django.utils.module_loading import ( autodiscover_modules, import_string, module_has_submodule, ) fro...
431b9f654341949988cd625c493a7588439d1e38d7ed6213aefa72cea5994269
import datetime import unittest from unittest import mock try: import pytz except ImportError: pytz = None try: import zoneinfo except ImportError: from backports import zoneinfo from django.test import SimpleTestCase, ignore_warnings, override_settings from django.utils import timezone from django.u...
c907313fb74d554ae1ef7a53c95877403b61bd0d40ca90c3e3f0607a48896586
from django.test import SimpleTestCase from django.utils.deconstruct import deconstructible from django.utils.version import get_docs_version @deconstructible() class DeconstructibleClass: pass class DeconstructibleChildClass(DeconstructibleClass): pass @deconstructible( path='utils_tests.deconstructi...
90afe860dbca56d3e7c4730859ad773deabdc560257a7c952f34f665cad99812
import unittest from datetime import date, datetime, time, timedelta from django.utils.dateparse import ( parse_date, parse_datetime, parse_duration, parse_time, ) from django.utils.timezone import get_fixed_timezone class DateParseTests(unittest.TestCase): def test_parse_date(self): # Valid inputs ...
c2db1e1d1cb1d691e2cc4bbb430babe2c3af90fddb09256ff819528042250d20
import os from datetime import datetime from django.test import SimpleTestCase from django.utils.functional import lazystr from django.utils.html import ( conditional_escape, escape, escapejs, format_html, html_safe, json_script, linebreaks, smart_urlquote, strip_spaces_between_tags, strip_tags, urlize, ) from...
1fbd08bf2e6f83897143f05cfecc383dd940cfbe1e028df3560dc83f1637a24d
from decimal import Decimal from sys import float_info from django.test import SimpleTestCase from django.utils.numberformat import format as nformat class TestNumberFormat(SimpleTestCase): def test_format_number(self): self.assertEqual(nformat(1234, '.'), '1234') self.assertEqual(nformat(1234.2...
c22372271cd546f389a4b48f53ce9928cd591b7b76444e8b93af6bb2a4c45f53
from .test_deconstruct import DeconstructibleWithPathClass # NOQA
f55bc3d753314bf12005fad76c468345afe91c9691fc6fe21bd08dc847a151b1
from unittest import mock from django.test import SimpleTestCase from django.test.utils import ignore_warnings from django.utils.deprecation import RemovedInDjango50Warning from django.utils.functional import cached_property, classproperty, lazy class FunctionalTests(SimpleTestCase): def test_lazy(self): ...
fa40e465c4beea034b1c6b954362c4f01e7ab48a2f0f043249f051cb402be901
import hashlib import unittest from django.test import SimpleTestCase from django.utils.crypto import ( InvalidAlgorithm, constant_time_compare, pbkdf2, salted_hmac, ) class TestUtilsCryptoMisc(SimpleTestCase): def test_constant_time_compare(self): # It's hard to test for constant time, just test th...
13a99b57aab5970d3e51d9498a3cfc915f4422201be824dbd99e45175e985084
import contextlib import os import py_compile import shutil import sys import tempfile import threading import time import types import weakref import zipfile from importlib import import_module from pathlib import Path from subprocess import CompletedProcess from unittest import mock, skip, skipIf try: import zon...
e8fe5c82ed063e91a690ac612635219f5c1451f80bb3f1385b5b20bf160354d7
import platform import unittest from datetime import datetime, timezone from unittest import mock from django.test import SimpleTestCase from django.utils.datastructures import MultiValueDict from django.utils.http import ( base36_to_int, escape_leading_slashes, http_date, int_to_base36, is_same_domain, parse_...
efbf6c90d85119dcf488ce7ac2788f53914019c1926ca5d3aa68859da7dfb7a9
import json import sys from django.core.exceptions import SuspiciousFileOperation from django.test import SimpleTestCase from django.utils import text from django.utils.functional import lazystr from django.utils.text import format_lazy from django.utils.translation import gettext_lazy, override IS_WIDE_BUILD = (len(...
37589f507940c94e9ea1829578a6f6e1eb05b3b2d8147b29493590b15fe2d78d
import threading from datetime import datetime, timedelta from unittest import mock from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist from django.db import DEFAULT_DB_ALIAS, DatabaseError, connections, models from django.db.models.manager import BaseManager from django.db.models.query impo...
9748dfd6abf8e0be3764df6fa3154091384b62b404ffcff81b4a793bd6d283c8
import pickle from datetime import datetime from functools import partialmethod from io import StringIO from unittest import mock, skipIf from django.core import serializers from django.core.serializers import SerializerDoesNotExist from django.core.serializers.base import PickleSerializer, ProgressBar from django.db ...
9885c10d6e728a90cc9b9ae977ffcf34ec37270e48f7f2dcf9eefc750d52f5bb
from datetime import date from django import forms from django.contrib.admin.models import ADDITION, CHANGE, DELETION, LogEntry from django.contrib.admin.options import ( HORIZONTAL, VERTICAL, ModelAdmin, TabularInline, get_content_type_for_model, ) from django.contrib.admin.sites import AdminSite from django....
44cd7a93ce38ac0967b74dfa8e4a9238e0c860d397afe591b771fa27b8ede2b8
from django import forms from django.contrib import admin from django.contrib.admin import BooleanFieldListFilter, SimpleListFilter from django.contrib.admin.options import VERTICAL, ModelAdmin, TabularInline from django.contrib.admin.sites import AdminSite from django.core.checks import Error from django.db.models imp...
18abefe2ba016df2f252af2df1240d8c77645c195786dc2d5ea6c3741ca37310
""" Tests for django test runner """ import collections.abc import multiprocessing import os import sys import unittest from unittest import mock from admin_scripts.tests import AdminScriptTestCase from django import db from django.conf import settings from django.core.exceptions import ImproperlyConfigured from djan...
9f33cc62dd2ddac406a4608bd570c8623a26159869437e0d28c3fcef0c86f135
import logging import multiprocessing import os import unittest.loader from argparse import ArgumentParser from contextlib import contextmanager from importlib import import_module from unittest import TestSuite, TextTestRunner, defaultTestLoader, mock from django.db import connections from django.test import SimpleTe...
274a2df02ef43be0d3868007d9313dee5ac86ecb1ee17577950f4d880bd8f0ff
from datetime import datetime from decimal import Decimal from django import forms from django.conf import settings from django.contrib import admin from django.contrib.admin import helpers from django.contrib.admin.utils import ( NestedObjects, display_for_field, display_for_value, flatten, flatten_fieldsets,...
57a26959ec40551b9a51afb89d783761296788ec387c24b1c4c48a717e2f23a9
import json from datetime import datetime from django.contrib.admin.models import ADDITION, CHANGE, DELETION, LogEntry from django.contrib.admin.utils import quote from django.contrib.auth.models import User from django.contrib.contenttypes.models import ContentType from django.test import TestCase, override_settings ...
4d560cc14b199a0719e91d380dfd6f29570f07ca32061fd4e477d9aea023b520
import datetime import pickle import sys import unittest from operator import attrgetter from threading import Lock from django.core.exceptions import EmptyResultSet, FieldError from django.db import DEFAULT_DB_ALIAS, connection from django.db.models import Count, Exists, F, Max, OuterRef, Q from django.db.models.expr...
76a333cd7339cccb3ad5f4670474ab64f1d521b70ed1fc5c93d2e73771871924
""" Various complex queries that have been problematic in the past. """ from django.db import models from django.db.models.functions import Now class DumbCategory(models.Model): pass class ProxyCategory(DumbCategory): class Meta: proxy = True class NamedCategory(DumbCategory): name = models.Ch...
61dcadcb54d013299c1a8e148d24d696569b27342b5e1269bb292b988e2c4626
import operator from django.db import DatabaseError, NotSupportedError, connection from django.db.models import Exists, F, IntegerField, OuterRef, Subquery, Value from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature from django.test.utils import CaptureQueriesContext from .models import Author, Cele...
76dea8702f84597fc2af2108891418a4cd84c28c525119d9ec6dee5dfe9167c2
from django.db import DEFAULT_DB_ALIAS, connection from django.db.models.sql import Query from django.test import SimpleTestCase from .models import Item class SQLCompilerTest(SimpleTestCase): def test_repr(self): query = Query(Item) compiler = query.get_compiler(DEFAULT_DB_ALIAS, connection) ...
02a30e38041df7803ab2202a2c627ff8750fbe45f6fa4ac0d8723fc48f2a39e8
from datetime import datetime from django.core.exceptions import FieldError from django.db.models import BooleanField, CharField, F, Q from django.db.models.expressions import Col, Func from django.db.models.fields.related_lookups import RelatedIsNull from django.db.models.functions import Lower from django.db.models....
fd2a137bc2e57a5197f437de0a1508a2e068a0e7c02b98777f2fb08be4565358
import datetime from django.core.exceptions import FieldDoesNotExist from django.db.models import F from django.db.models.functions import Lower from django.test import TestCase, skipUnlessDBFeature from .models import ( Article, CustomDbColumn, CustomPk, Detail, Individual, JSONFieldNullable, Member, Note, N...
335bbbc2630f705db3dfbdebcbd6dc783fa58f94ee1d9ccf5fecbd2e0022a906
import sys from django.contrib.auth.models import Group from django.template import ( Context, Engine, TemplateDoesNotExist, TemplateSyntaxError, ) from django.template.base import UNKNOWN_SOURCE from django.test import SimpleTestCase, override_settings from django.urls import NoReverseMatch from django.utils impo...
e7fc892e7401f1e19daa248faa269ca47c9b8900dcccf8149168766000fb5b74
from django.template import Context, Template, Variable, VariableDoesNotExist from django.template.base import DebugLexer, Lexer, TokenType from django.test import SimpleTestCase from django.utils.translation import gettext_lazy class LexerTestMixin: template_string = ( 'text\n' '{% if test %}{{ v...
6502d67c0ce2e2ecf46606e71166c83775cb4df5c60d5c81e99fe4010543c13b
import os from django.template import Context, Engine, TemplateSyntaxError from django.template.base import Node from django.template.library import InvalidTemplateLibrary from django.test import SimpleTestCase from django.test.utils import extend_sys_path from .templatetags import custom, inclusion from .utils impor...
df51f9a1951f950b0652c926ffa9528e642e766d8cb56900653123d99b56767b
import datetime import re from datetime import date from decimal import Decimal from django import forms from django.core.exceptions import ImproperlyConfigured from django.db import models from django.forms.models import ( BaseModelFormSet, _get_foreign_key, inlineformset_factory, modelformset_factory, ) from...
6a7174514e1f2475b97a0935ce522bc8826d754e99fbf93f98b2e3a384807021
import base64 import os import shutil import string import tempfile import unittest from datetime import timedelta from http import cookies from pathlib import Path from unittest import mock from django.conf import settings from django.contrib.sessions.backends.base import UpdateError from django.contrib.sessions.back...
0343bccc2f5751c5fd431362c67e4c2d4f181ef728d8303645cc16e987e5ebcb
from datetime import datetime from django.contrib.sitemaps import GenericSitemap from django.test import ignore_warnings, override_settings from django.utils.deprecation import RemovedInDjango50Warning from .base import SitemapTestsBase from .models import TestModel @override_settings(ABSOLUTE_URL_OVERRIDES={}) cla...
753f4d9a9505b64bc300991845f1dd5709df5e254399316beabe3710269a1c4c
from unittest import mock from urllib.parse import urlencode from django.contrib.sitemaps import ( SitemapNotFound, _get_sitemap_full_url, ping_google, ) from django.core.exceptions import ImproperlyConfigured from django.test import modify_settings, override_settings from .base import SitemapTestsBase class Pi...
7a159e12f557b6de67bce49b04052e3b208c441679424ac249147a6873c2ec04
from datetime import date from django.test import override_settings from .base import SitemapTestsBase @override_settings(ROOT_URLCONF='sitemaps_tests.urls.https') class HTTPSSitemapTests(SitemapTestsBase): protocol = 'https' def test_secure_sitemap_index(self): "A secure sitemap index can be rende...
49fbb9ebc3d4e1d0bc78496b01ba285dbdc323e448abd4d1e26be9cf8bd1e0b3
import os from datetime import date from django.contrib.sitemaps import Sitemap from django.contrib.sites.models import Site from django.core.exceptions import ImproperlyConfigured from django.test import ignore_warnings, modify_settings, override_settings from django.utils import translation from django.utils.depreca...
0b4360ded7b40e4d6d80ca8455c6a628d8d4750ceb8dfda090efee2c035d29dd
from django.db.models import Q from django.http import Http404 from django.shortcuts import get_list_or_404, get_object_or_404 from django.test import TestCase from .models import Article, Author class GetObjectOr404Tests(TestCase): def test_get_object_or_404(self): a1 = Author.objects.create(name="Brave...
fa61c320a3312f60a949033d6f1472299f29ec87784cb1189a59c7ec58c4278d
""" Testing using the Test Client The test client is a class that can act like a simple browser for testing purposes. It allows the user to compose GET and POST requests, and obtain the response that the server gave to those requests. The server Response objects are annotated with the details of the contexts and temp...
3168604874c3185d2df0eda7e5c190ce7f8cd6558dc06600321e79f7e0c47d6c
from django.contrib.auth import views as auth_views from django.urls import path from django.views.generic import RedirectView from . import views urlpatterns = [ path('upload_view/', views.upload_view, name='upload_view'), path('get_view/', views.get_view, name='get_view'), path('post_view/', views.post_...
50f60e9fb3f9ffda81a0d97557731a49730f27d3327cbcf39a6a52b19ec5a1df
import json from urllib.parse import urlencode from xml.dom.minidom import parseString from django.contrib.auth.decorators import login_required, permission_required from django.core import mail from django.core.exceptions import ValidationError from django.forms import fields from django.forms.forms import Form from ...
295396a9913d5ba6c939dc082513bb745e257c34e9c08867493ef769e140f35e
from django.db import connection from django.db.backends.ddl_references import ( Columns, Expressions, ForeignKeyName, IndexName, Statement, Table, ) from django.db.models import ExpressionList, F from django.db.models.functions import Upper from django.db.models.indexes import IndexExpression from django.db.models...
c470d6350c84b23276601f439d3fe058365f6b5758e1314ca31254253220bb98
"""Tests for django.db.backends.utils""" from decimal import Decimal, Rounded from django.db import NotSupportedError, connection from django.db.backends.utils import ( format_number, split_identifier, split_tzname_delta, truncate_name, ) from django.test import ( SimpleTestCase, TransactionTestCase, skipIfDBF...
3718bf44ea949576bdb29656af45a5eaacc5ae70f3531f353cddb7961b79c687
import datetime import itertools import unittest from copy import copy from unittest import mock from django.core.exceptions import FieldError from django.core.management.color import no_style from django.db import ( DatabaseError, DataError, IntegrityError, OperationalError, connection, ) from django.db.models im...
c78a31c4c4e25d9bf7514f35532bff35efd4a60cbbf43fd7eb618eec4dabbd0e
from django.contrib.admin import ModelAdmin, TabularInline from django.contrib.admin.helpers import InlineAdminForm from django.contrib.admin.tests import AdminSeleniumTestCase from django.contrib.auth.models import Permission, User from django.contrib.contenttypes.models import ContentType from django.test import Requ...
3747d616aa02e5d9eb9c1846b1b2bab80a56c5d0af315eeb69e616a6c092bd4c
""" Testing of admin inline formsets. """ import random from django.contrib.contenttypes.fields import GenericForeignKey from django.contrib.contenttypes.models import ContentType from django.db import models class Parent(models.Model): name = models.CharField(max_length=50) def __str__(self): retur...
f09dab5693bf67b953809b47f1223f196e098c87eac787dd9a325c9301f5adfa
from django import forms from django.contrib import admin from django.core.exceptions import ValidationError from django.db import models from .models import ( Author, BinaryTree, CapoFamiglia, Chapter, Child, ChildModel1, ChildModel2, Class, Consigliere, Course, CourseProxy, CourseProxy1, CourseProxy2, Ed...
72dbda5027cc1db4fe4d7073ce7f9dcf0212a8fc224844c07e81e6f54e73a127
from django.urls import path from . import admin urlpatterns = [ path('admin/', admin.site.urls), path('admin2/', admin.site2.urls), path('admin3/', admin.site3.urls), path('admin4/', admin.site4.urls), ]
3eeb707c386d47895aac7dbcd2360d71aec3eb5de4b3669996b676c51f1dc369
from copy import copy, deepcopy from django.core.checks import Error from django.core.checks.templates import ( E001, E002, E003, check_for_template_tags_with_the_same_name, check_setting_app_dirs_loaders, check_string_if_invalid_is_string, ) from django.test import SimpleTestCase from django.test.utils import...
7cb23e7b03b0279a35f84af8ea3a496f61b8fe1031bf6ebbaf84ba2413e2bd33
import datetime from decimal import Decimal from django.contrib.humanize.templatetags import humanize from django.template import Context, Template, defaultfilters from django.test import SimpleTestCase, modify_settings, override_settings from django.utils import translation from django.utils.html import escape from d...
c51e1c1dd073ab6388375c61b557ed0fc9216cad466239db1815d5585f3b5f43
from functools import update_wrapper, wraps from unittest import TestCase, mock from django.contrib.admin.views.decorators import staff_member_required from django.contrib.auth.decorators import ( login_required, permission_required, user_passes_test, ) from django.http import HttpRequest, HttpResponse, HttpRespon...
9697a1629977eb658781fe85fb212a6f28d506d3a154f2084b567f95b57e9607
from django.db import models from django.test import TestCase from .models import ( Book, Car, ConfusedBook, CustomManager, CustomQuerySet, DeconstructibleCustomManager, FastCarAsBase, FastCarAsDefault, FunPerson, OneToOneRestrictedModel, Person, PersonFromAbstract, PersonManager, PublishedBookManager,...
cf4e27b352484e40d979b07ea753bcea021d917232f0120b45018af056d89ee0
""" Giving models a custom manager You can use a custom ``Manager`` in a particular model by extending the base ``Manager`` class and instantiating your custom ``Manager`` in your model. There are two reasons you might want to customize a ``Manager``: to add extra ``Manager`` methods, and/or to modify the initial ``Q...
0b8c923eff6bfc2e70c9932cf142ed6f264bb3d45e6fc685bd4afc30b72c8fce
""" A series of tests to establish that the command-line management tools work as advertised - especially with regards to the handling of the DJANGO_SETTINGS_MODULE and default settings.py files. """ import os import re import shutil import socket import stat import subprocess import sys import tempfile import unittest...
216e08725e2afa3dc1ad286d4d404b710122ed0e9b8ada05031c8df6097558f1
from math import ceil from operator import attrgetter from django.core.exceptions import FieldDoesNotExist from django.db import ( IntegrityError, NotSupportedError, OperationalError, ProgrammingError, connection, ) from django.db.models import FileField, Value from django.db.models.functions import Lower from...
8a24a22f97ae41ec48cf59fba58b7b46a5331bb35bcb4dbb292eed97b30fcf24
import datetime import uuid from decimal import Decimal from django.db import models from django.utils import timezone try: from PIL import Image except ImportError: Image = None class Country(models.Model): name = models.CharField(max_length=255) iso_two_letter = models.CharField(max_length=2) ...
1a9b26b89a8318a5017b7155300d6bb76c6b10f4c1082d32fadce900b92a893a
""" Regression tests for Model inheritance behavior. """ import datetime from operator import attrgetter from unittest import expectedFailure from django import forms from django.test import TestCase from .models import ( ArticleWithAuthor, BachelorParty, BirthdayParty, BusStation, Child, Congressman, Derived...
ab2db4acc3d908893b8fc6b9947169b76c12ba2884119b54f7ef8c7e55c1a495
import datetime from decimal import Decimal from unittest import mock from django.core.exceptions import FieldError from django.db import NotSupportedError, connection from django.db.models import ( Avg, BooleanField, Case, F, Func, IntegerField, Max, Min, OuterRef, Q, RowRange, Subquery, Sum, Value, ValueRang...
02e49db1ba7608355ee275fe2d4206acfc5b7ab02c6559b63b0ed9c1ba4b8f70
import sys from types import ModuleType from django.conf import USE_L10N_DEPRECATED_MSG, Settings, settings from django.test import TestCase, ignore_warnings from django.utils.deprecation import RemovedInDjango50Warning class DeprecationTests(TestCase): msg = USE_L10N_DEPRECATED_MSG def test_override_settin...
220887ee14e83a71be04949c651a1fb6ba1f5aef8ba25929ffeb3bbe3a829244
import sys from types import ModuleType from django.conf import CSRF_COOKIE_MASKED_DEPRECATED_MSG, Settings, settings from django.test import SimpleTestCase from django.utils.deprecation import RemovedInDjango50Warning class CsrfCookieMaskedDeprecationTests(SimpleTestCase): msg = CSRF_COOKIE_MASKED_DEPRECATED_MS...
fd2c4f75c14a9e15a1c57dd0ad07a9fd5884be02d133b7baf34a1c57972d0832
import base64 import hashlib import os import shutil import sys import tempfile as sys_tempfile import unittest from io import BytesIO, StringIO from unittest import mock from urllib.parse import quote from django.core.exceptions import SuspiciousFileOperation from django.core.files import temp as tempfile from django...