hash
stringlengths
64
64
content
stringlengths
0
1.51M
8c4adf539bdc0bd1b98343012363728135353481e88ecb786b3291a7865c55f0
import glob import os import re import sys from functools import total_ordering from itertools import dropwhile import django from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.core.files.temp import NamedTemporaryFile from django.core.management.base import BaseComman...
c148ba04f9f3e425c6e8f608722659f3b2e5482e568281ddbe67994e091a023c
import sys from django.apps import apps from django.core.management.base import BaseCommand from django.db import DEFAULT_DB_ALIAS, connections from django.db.migrations.loader import MigrationLoader class Command(BaseCommand): help = "Shows all available migrations for the current project" def add_argument...
df88bb3e5c63ed21be0a8e2df5d0ba053ea792ed65f3625a8e26eb11094f57ff
"Misc. utility functions/classes for admin documentation generator." import re from email.errors import HeaderParseError from email.parser import HeaderParser from inspect import cleandoc from django.urls import reverse from django.utils.regex_helper import _lazy_re_compile from django.utils.safestring import mark_sa...
25cc36e032914dcdb5c7600d755365a304083bda55a480f72966eba5cde37473
from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.http import HttpResponse from django.utils.deprecation import MiddlewareMixin from .utils import get_view_name class XViewMiddleware(MiddlewareMixin): """ Add an X-View header to internal HEAD requests. "...
52a2a8089c9939320685739bc031157cec39093838e070d76512747e5a661977
import inspect from importlib import import_module from inspect import cleandoc from pathlib import Path from django.apps import apps from django.contrib import admin from django.contrib.admin.views.decorators import staff_member_required from django.contrib.admindocs import utils from django.contrib.admindocs.utils i...
56185346a3b40ccf5e25f9ed0097f437d0d15f673d6e2610248eb120df8c9bd4
from django.db import NotSupportedError from django.db.backends.ddl_references import Statement, Table from django.db.models import Deferrable, F, Q from django.db.models.constraints import BaseConstraint from django.db.models.sql import Query __all__ = ['ExclusionConstraint'] class ExclusionConstraint(BaseConstrain...
12baaef1cc3c27a3dfd93e5d401717cc9202398547515c7c585a3a44010f2788
from django.contrib import auth from django.contrib.auth import load_backend from django.contrib.auth.backends import RemoteUserBackend from django.core.exceptions import ImproperlyConfigured from django.utils.deprecation import MiddlewareMixin from django.utils.functional import SimpleLazyObject def get_user(request...
84a1fbffd83a1b52f6067bee32801b03b8002d9380ac75e597277f98f1f9b03f
from urllib.parse import urlparse, urlunparse from django.conf import settings # Avoid shadowing the login() and logout() views below. from django.contrib.auth import ( REDIRECT_FIELD_NAME, get_user_model, login as auth_login, logout as auth_logout, update_session_auth_hash, ) from django.contrib.auth.decorato...
0d94fa775381edf13658f90295bbac6108d41688dd1d6947211cea37c790bf15
import functools import gzip import re from difflib import SequenceMatcher from pathlib import Path from django.conf import settings from django.core.exceptions import ( FieldDoesNotExist, ImproperlyConfigured, ValidationError, ) from django.utils.functional import cached_property, lazy from django.utils.html impo...
b07455a496778f62e3c130e00c742d8ab53936e2fad413c2657902c037e9cba6
import collections from itertools import chain from django.apps import apps from django.conf import settings from django.contrib.admin.utils import ( NotRelationField, flatten, get_fields_from_path, ) from django.core import checks from django.core.exceptions import FieldDoesNotExist from django.db import models f...
ce31911ede41b75248efbc1ff0fc0322f2283698cccd82745e00167736d7c881
import copy import json import operator import re from functools import partial, reduce, update_wrapper from urllib.parse import quote as urlquote from django import forms from django.conf import settings from django.contrib import messages from django.contrib.admin import helpers, widgets from django.contrib.admin.ch...
7e6326a281a86863b17368b2828e4713efc42db02bbc98f692b0b5acd0c1aae1
import re from functools import update_wrapper from weakref import WeakSet from django.apps import apps from django.conf import settings from django.contrib.admin import ModelAdmin, actions from django.contrib.admin.views.autocomplete import AutocompleteJsonView from django.contrib.auth import REDIRECT_FIELD_NAME from...
f5c4bb7ade398fd7cf615c768e3d6800d57ac075cc920b7075c0b4e92ea9754c
""" Form Widget classes specific to the Django admin site. """ import copy import json from django import forms from django.conf import settings from django.core.exceptions import ValidationError from django.core.validators import URLValidator from django.db.models import CASCADE from django.urls import reverse from d...
cc13540211e2b3d7ee4dbf32d7df4bbbfbaa801044625cf2c46beeab962bac81
import functools import os from django.apps import apps from django.conf import settings from django.contrib.staticfiles import utils from django.core.checks import Error, Warning from django.core.exceptions import ImproperlyConfigured from django.core.files.storage import ( FileSystemStorage, Storage, default_sto...
85c813d810abee07432cf1d6f5966cde237c533ebaf870631c61a831d04f0316
import hashlib import json import os import posixpath import re from urllib.parse import unquote, urldefrag, urlsplit, urlunsplit from django.conf import settings from django.contrib.staticfiles.utils import check_settings, matches_patterns from django.core.exceptions import ImproperlyConfigured from django.core.files...
376054cd4510f4d09fed9c4ede3195cb9a815c073be70069885f46484afff9f9
import json from django.contrib.messages.storage.base import BaseStorage from django.contrib.messages.storage.cookie import ( MessageDecoder, MessageEncoder, ) from django.core.exceptions import ImproperlyConfigured class SessionStorage(BaseStorage): """ Store messages in the session (that is, django.con...
84381647014f804e24d4e5168700cdae66e4a5f941aea09b74ef0ab75092c9d7
from django.apps import apps from django.core.exceptions import FieldDoesNotExist, PermissionDenied from django.http import Http404, JsonResponse from django.views.generic.list import BaseListView class AutocompleteJsonView(BaseListView): """Handle AutocompleteWidget's AJAX requests for data.""" paginate_by =...
220351bb5c3bd3b29e034cb80c0a9e59078ad66ae8af71cc6296697125bb7479
import os from django.apps import apps from django.contrib.staticfiles.finders import get_finders from django.contrib.staticfiles.storage import staticfiles_storage from django.core.checks import Tags from django.core.files.storage import FileSystemStorage from django.core.management.base import BaseCommand, CommandEr...
aaff53a740f06d37a67eb8957bb533af057c8a4ab5c8dc5bd6436dd271d7b400
import logging import os import re from ctypes import CDLL, CFUNCTYPE, c_char_p, c_int from ctypes.util import find_library from django.contrib.gis.gdal.error import GDALException from django.core.exceptions import ImproperlyConfigured logger = logging.getLogger('django.contrib.gis') # Custom library path set? try: ...
7c579370afcaf438e3ec9eda03ddc3747aa98048b6c4379c4cd1f92dabd21bc4
from django.contrib.admin import ( HORIZONTAL, VERTICAL, AdminSite, ModelAdmin, StackedInline, TabularInline, action, autodiscover, display, register, site, ) from django.contrib.gis.admin.options import GeoModelAdmin, OSMGeoAdmin from django.contrib.gis.admin.widgets import OpenLayersWidget __all__ = [ 'H...
96b22a900ba7ae13c56a656034d0392766bd9f8238e2191089ee61d67a60789d
""" Tests for django.core.servers. """ import errno import os import socket from http.client import HTTPConnection from urllib.error import HTTPError from urllib.parse import urlencode from urllib.request import urlopen from django.conf import settings from django.core.servers.basehttp import WSGIServer from django.te...
8cdab4c2b164f6f54afdd80fd69ff064c77a4faec43cae632a085e7d4f499d62
from django.db import DEFAULT_DB_ALIAS, connections from django.test import LiveServerTestCase, TransactionTestCase from django.test.testcases import LiveServerThread # Use TransactionTestCase instead of TestCase to run outside of a transaction, # otherwise closing the connection would implicitly rollback and not set...
81f5e29937bd1302d9049ae99c928e27a2ff0310df89f3d9465d7d92b4736356
from django.db import migrations, models from django.db.migrations import operations from django.db.migrations.optimizer import MigrationOptimizer from django.db.migrations.serializer import serializer_factory from django.test import SimpleTestCase from .models import EmptyManager, UnicodeModel class OptimizerTests(...
3f44ed258d4cc4e71d56b4c38df7a8fd5a104e83cde0e4faafc2252008e4dd19
import datetime import importlib import io import os import sys from unittest import mock from django.apps import apps from django.core.management import CommandError, call_command from django.db import ( ConnectionHandler, DatabaseError, OperationalError, connection, connections, models, ) from django.db.back...
7d819832d770cc72ce041f35e941cbeac146049552dec5f5eeac92d8b0872ccc
from django.core.exceptions import FieldDoesNotExist from django.db import ( IntegrityError, connection, migrations, models, transaction, ) from django.db.migrations.migration import Migration from django.db.migrations.operations.fields import FieldOperation from django.db.migrations.state import ModelState, Projec...
3bbf6f40ac9f92209824037263bb6318ec8ad457900bc8329e3051b85efa67d2
import functools import re from unittest import mock from django.apps import apps from django.conf import settings from django.contrib.auth.models import AbstractBaseUser from django.core.validators import RegexValidator, validate_slug from django.db import connection, migrations, models from django.db.migrations.auto...
1cccd4c0a6cef9061c03d3fc70c4fb08d73fe21b0e7bec4dccdb6dc269e5457f
from django.apps.registry import Apps from django.contrib.contenttypes.fields import GenericForeignKey from django.db import models from django.db.migrations.exceptions import InvalidBasesError from django.db.migrations.operations import ( AddField, AlterField, DeleteModel, RemoveField, ) from django.db.migrations....
095e852284aeace26fd0d1365b74e47f20997bb47a2417cd3a70eed84271b369
import os import sys import unittest from types import ModuleType, SimpleNamespace from unittest import mock from django.conf import ENVIRONMENT_VARIABLE, LazySettings, Settings, settings from django.core.exceptions import ImproperlyConfigured from django.http import HttpRequest from django.test import ( SimpleTes...
f44c0df2832e5fb0edfca99b9efb9c50e512319701ff2268e27b71851fffec47
import datetime import itertools import re from importlib import import_module from unittest import mock from urllib.parse import quote, urljoin from django.apps import apps from django.conf import settings from django.contrib.admin.models import LogEntry from django.contrib.auth import ( BACKEND_SESSION_KEY, REDI...
6014f02da43141a425ca8b8b9c2569bafa2929b2de3666ea864530ee4975bcdc
from django.contrib import admin from django.contrib.auth import views from django.contrib.auth.decorators import login_required, permission_required from django.contrib.auth.forms import AuthenticationForm from django.contrib.auth.urls import urlpatterns as auth_urlpatterns from django.contrib.auth.views import LoginV...
911bf2b4603f7e8ac6a9654fae79107d1a1918f272b2b66aed29c0bf9f5239ff
from django.contrib.auth.middleware import AuthenticationMiddleware from django.contrib.auth.models import User from django.core.exceptions import ImproperlyConfigured from django.http import HttpRequest, HttpResponse from django.test import TestCase class TestAuthenticationMiddleware(TestCase): @classmethod ...
436f68914c3b69a612dd1cd49453930d57ba9fe1a3aad370c74dbcb44c6d3495
import os import shutil import sys import tempfile import threading import time import unittest from datetime import datetime, timedelta from io import StringIO from pathlib import Path from urllib.request import urlopen from django.core.cache import cache from django.core.exceptions import SuspiciousFileOperation fro...
25157a278b59f9b90f1c8068597816bdc8a52bda2a1518d392ffd1b2c562ffed
import re from django.conf import settings from django.contrib.sessions.backends.cache import SessionStore from django.core.exceptions import ImproperlyConfigured from django.http import HttpRequest, HttpResponse from django.middleware.csrf import ( CSRF_SESSION_KEY, CSRF_TOKEN_LENGTH, REASON_BAD_ORIGIN, REASON_BA...
5fa695b1a74305445d7b68330ce6d493d560e0c91876b7ec4dde2be903def71c
import datetime import re from decimal import Decimal from django.core.exceptions import FieldError from django.db import connection from django.db.models import ( Avg, Case, Count, DecimalField, DurationField, Exists, F, FloatField, IntegerField, Max, Min, OuterRef, Subquery, Sum, Value, When, ) from django.d...
f9aae497fa56e0780006c2ebd2c4fa6f5ef1bfe323320293777143e498cf09b1
import logging import os import unittest import warnings from io import StringIO from unittest import mock from django.conf import settings from django.contrib.staticfiles.finders import get_finder, get_finders from django.contrib.staticfiles.storage import staticfiles_storage from django.core.exceptions import Improp...
b1934ce39a05c53f79f827b23e268175302580d95587c1e11e2a623e17a02200
import datetime import os import re import unittest from unittest import mock from urllib.parse import parse_qsl, urljoin, urlparse import pytz try: import zoneinfo except ImportError: try: from backports import zoneinfo except ImportError: zoneinfo = None from django.contrib import admin...
8d358801d1cf80880aa3642d7db2b81dc73842c7243421af49a60c6918fa79b0
import datetime import tempfile import uuid from django.contrib import admin from django.contrib.auth.models import User from django.contrib.contenttypes.fields import ( GenericForeignKey, GenericRelation, ) from django.contrib.contenttypes.models import ContentType from django.core.exceptions import ValidationErr...
49ba453ce719c9d57215ff14a940739882ed0782e0f04c5aca9d84c827fd988b
import datetime from io import StringIO from wsgiref.util import FileWrapper from django import forms from django.contrib import admin from django.contrib.admin import BooleanFieldListFilter from django.contrib.admin.views.main import ChangeList from django.contrib.auth.admin import GroupAdmin, UserAdmin from django.c...
89512e58848457a0b87be233f0dead4fed420d1a78e28b5af013cb3f3da682d5
from django.contrib import admin from django.contrib.admin.tests import AdminSeleniumTestCase from django.contrib.auth.models import User from django.test import TestCase, override_settings from django.urls import path, reverse class AdminSiteWithSidebar(admin.AdminSite): pass class AdminSiteWithoutSidebar(admi...
d8ebf501f757063e6ae7bfb3b77d353e51e4b7de15637390a4be89a7cb185811
import json from contextlib import contextmanager from django.contrib import admin from django.contrib.admin.tests import AdminSeleniumTestCase from django.contrib.admin.views.autocomplete import AutocompleteJsonView from django.contrib.auth.models import Permission, User from django.contrib.contenttypes.models import...
070f9f2d036f578c8d984a18a6f4d73142950452923a4ce0b2c25f1bc312b45c
import datetime import pickle import django from django.db import models from django.test import TestCase from .models import Container, Event, Group, Happening, M2MModel, MyEvent class PickleabilityTestCase(TestCase): @classmethod def setUpTestData(cls): cls.happening = Happening.objects.create() ...
a76a0601a244a1b688864318a2cd971defcf178f21576ebd0fb2ec52f189c925
from unittest import skipUnless import django.utils.version from django import get_version from django.test import SimpleTestCase from django.utils.version import ( get_complete_version, get_git_changeset, get_version_tuple, ) class VersionTests(SimpleTestCase): def test_development(self): get_git_c...
12f13bf90223d0511b886c6aa21a856286e6f038f46cda22b89763b11d4f2da5
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...
5331307cd1198a08226086c84b49413177b3d60f6b75baa967cf6f07d33117cd
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 ...
3dbb45edb4c98f0fbc6d8e48caccfe6e7e07c55dc50d0a18eca01435d2c5509b
""" Models for testing various aspects of the djang.contrib.admindocs app """ from django.db import models from django.utils.functional import cached_property class Company(models.Model): name = models.CharField(max_length=200) class Group(models.Model): name = models.CharField(max_length=200) class Fami...
8bd4171ae3b179540cb947fe8b7bac69ad834bad0f43249fed34c4ddcd9caa94
from django.contrib.auth.models import User from django.core.exceptions import ImproperlyConfigured from django.test import override_settings from .tests import AdminDocsTestCase, TestDataMixin class XViewMiddlewareTest(TestDataMixin, AdminDocsTestCase): def test_xview_func(self): user = User.objects.ge...
469c72b8beced38842022e450dc7d041aa18d109ab0338f14db880855666d3e2
from django.conf import settings from django.core.exceptions import MiddlewareNotUsed from django.http import HttpResponse from django.test import RequestFactory, SimpleTestCase, override_settings from . import middleware as mw @override_settings(ROOT_URLCONF='middleware_exceptions.urls') class MiddlewareTests(Simpl...
e8ff5081012caa1cd77024093c87a0c6c1ba2d92b411f3fba310863fc33f402b
import asyncio from django.http import Http404, HttpResponse from django.template import engines from django.template.response import TemplateResponse from django.utils.decorators import ( async_only_middleware, sync_and_async_middleware, sync_only_middleware, ) log = [] class BaseMiddleware: def __init__(s...
8180511add2d866007047b41af2904fb055bf16776fbf2e28d48acf21b0278f3
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...
1e0607b917fef9d1fbda4dcd6ba72b9e1366305fb9e304aaecc9b28492a81fbb
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...
1ac72221bf33aff302733b8d96549da3147c79103090c8bfdf1ced4dbdef3744
from django.http import HttpResponse from django.test import RequestFactory, SimpleTestCase from django.test.utils import override_settings class SecurityMiddlewareTest(SimpleTestCase): def middleware(self, *args, **kwargs): from django.middleware.security import SecurityMiddleware return Security...
67e5e8b6200277563252f816f9ba0a890021f448c4bb448ba7703a9522d9369e
import asyncio import sys import threading from pathlib import Path from unittest import skipIf from asgiref.sync import SyncToAsync from asgiref.testing import ApplicationCommunicator from django.contrib.staticfiles.handlers import ASGIStaticFilesHandler from django.core.asgi import get_asgi_application from django....
e88b69e89e2d190337796076f20568afa657dd1dd0489b2ecfa7871d4af85862
from django.contrib.messages import constants from django.contrib.messages.storage.base import Message from django.contrib.messages.storage.session import SessionStorage from django.core.exceptions import ImproperlyConfigured from django.http import HttpRequest from django.test import TestCase from django.utils.safestr...
772a753d51dd92217c8fe85e41d08a39d68acb2d08c4d9734e67bf85fd332105
""" Unit tests for reverse URL lookups. """ 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 ( HttpRequest, ...
e76ab242eff0a99a0376f2d79277b13410e2c851021ed832c6cdd594e125ca82
from django.contrib.staticfiles.utils import check_settings from django.core.exceptions import ImproperlyConfigured from django.test import SimpleTestCase, override_settings class CheckSettingsTests(SimpleTestCase): @override_settings(DEBUG=True, MEDIA_URL='static/media/', STATIC_URL='static/') def test_medi...
1be4b1ef197acef03afe1a5af1a908486fbc3d4740016ed2664b854e03254b7a
""" 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...
8d67f12c5bdef9e2f29530b404543b376b56425dd4e3231be8a2d6883e871846
from pathlib import Path from unittest import mock from django.conf import settings from django.contrib.staticfiles.checks import check_finders from django.contrib.staticfiles.finders import BaseFinder, get_finder from django.core.checks import Error, Warning from django.test import override_settings from .cases impo...
fd2ace5fca3b1cf63075284523b0d13857b5f006b279dc6aa088309dd37a630b
import os.path from pathlib import Path TEST_ROOT = os.path.dirname(__file__) TEST_SETTINGS = { 'MEDIA_URL': 'media/', 'STATIC_URL': 'static/', 'MEDIA_ROOT': os.path.join(TEST_ROOT, 'project', 'site_media', 'media'), 'STATIC_ROOT': os.path.join(TEST_ROOT, 'project', 'site_media', 'static'), 'STATI...
0115573b02a898eb363cbe7f40aabf49e12354b47205227e8103b189e5e1f310
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 ( Command a...
b14963f3a51cfff7519a2d9583dfe948577d2a63f8d10e29af35eac96d6b94dd
import unittest from django.core.exceptions import FieldError from django.db import IntegrityError, connection, transaction from django.db.models import CharField, Count, F, IntegerField, Max from django.db.models.functions import Abs, Concat, Lower from django.test import TestCase from django.test.utils import regist...
6cb558a9778e12df4c6e6a38a1f2a2f5eee1c4c0bd039a87240a33772244dbf2
import unittest from django.utils import inspect class Person: def no_arguments(self): return None def one_argument(self, something): return something def just_args(self, *args): return args def all_kinds(self, name, address='home', age=25, *args, **kwargs): return ...
21bfbcbf3823e2ce63ee1f8d0d6c505e2b83201e5c239f8f1a08e7c287fa215b
import re import unittest from django.test import SimpleTestCase from django.utils import regex_helper class NormalizeTests(unittest.TestCase): def test_empty(self): pattern = r"" expected = [('', [])] result = regex_helper.normalize(pattern) self.assertEqual(result, expected) ...
6bbd9647b6d8047d874a26170afb048ffb45c28d9270e993f04e5879851aefed
from unittest import mock from django.test import SimpleTestCase from django.utils.functional import cached_property, classproperty, lazy class FunctionalTests(SimpleTestCase): def test_lazy(self): t = lazy(lambda: tuple(range(3)), list, tuple) for a, b in zip(t(), range(3)): self.ass...
fca5b718a49537461543c724a5289c9d93508415966bd3467ff6d8c769890708
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 import pytz import...
cb7375a25c995467efb4957ba63966e3b6fe9710d1d9d1f74e92846c1330f3fa
""" Tests for stuff in django.utils.datastructures. """ import collections.abc import copy import pickle from django.test import SimpleTestCase from django.utils.datastructures import ( CaseInsensitiveMapping, DictWrapper, ImmutableList, MultiValueDict, MultiValueDictKeyError, OrderedSet, ) class OrderedSetT...
99f7ecbb154a8e397f0dc7d773c792551aee06778d8469df5073b2aa7db434cb
import platform import unittest from datetime import datetime 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_etags, par...
92857a2eb75ebffb0cdf56fa414d6f656047fbf30828b0b83e73e9d6c0de67b7
import os import stat import sys import tempfile import unittest from django.core.exceptions import SuspiciousOperation from django.test import SimpleTestCase from django.utils import archive try: import bz2 # NOQA HAS_BZ2 = True except ImportError: HAS_BZ2 = False try: import lzma # NOQA HAS_L...
587d1503e0620e6c1c2c26814f9aff41919240977864a55bc277ce249b014ed9
from unittest import mock from django.conf import settings from django.db import connection, models from django.db.models.functions import Lower, Upper from django.test import SimpleTestCase, TestCase, skipUnlessDBFeature from django.test.utils import isolate_apps from .models import Book, ChildModel1, ChildModel2 ...
1cb521c340377d7201591ddeb9ea53fb021c1b1543a9959a0f86d472f0961e61
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...
19613ff26c33aa1dca42aad616c03a07e6bcf2e726b40baa318a627c868589aa
from django.core import serializers from django.db import connection from django.test import TestCase from .models import ( Child, FKAsPKNoNaturalKey, FKDataNaturalKey, NaturalKeyAnchor, NaturalKeyThing, NaturalPKWithDefault, ) from .tests import register_tests class NaturalKeySerializerTests(TestCase): ...
c48fe04ab408772de95c474bdc4e82aab0a24ea0d03079ebfb48769f22b9f420
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...
78380fc1cdb3498c08877b33e716a9accc0aad8b0caa4df3aab2c1b29b4924da
""" Tests for django test runner """ 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 django.core.management import call_command from django.core.management....
5b92dcc90d7ff94b72c3215013a731b83d6dd71147d38a5f865dba4c13cf9767
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 SimpleTestCase from django.test.runner import ...
f51001b127ce21181864402003fba7591c186a75afa4d498611fd5ea337f07d5
import pickle import sys import unittest from django.test import SimpleTestCase from django.test.runner import RemoteTestResult try: import tblib.pickling_support except ImportError: tblib = None class ExceptionThatFailsUnpickling(Exception): """ After pickling, this class fails unpickling with an e...
e29095f6155e38d0489405a700da71c4ce23cc700f64ae950eeff7e5eaf8625d
from io import BytesIO from django.core.exceptions import RequestDataTooBig, TooManyFieldsSent from django.core.handlers.wsgi import WSGIRequest from django.test import SimpleTestCase from django.test.client import FakePayload TOO_MANY_FIELDS_MSG = 'The number of GET/POST parameters exceeded settings.DATA_UPLOAD_MAX_...
10bcaebb215dbcfef424b8871b020ebc76ecbe4460a714f7c7dcac0468214e7a
from django.db.models import Exists, F, OuterRef, Q from django.test import SimpleTestCase from .models import Tag class QTests(SimpleTestCase): def test_combine_and_empty(self): q = Q(x=1) self.assertEqual(q & Q(), q) self.assertEqual(Q() & q, q) q = Q(x__in={}.keys()) s...
08127daec91857c3dd5d06b6ab9a28141b3fdea0f6366fb4017b67a43338847a
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, OuterRef, Q from django.db.models.expressio...
6f0f40a48c050a2ab5e37aca4ec883b68a78c3e028a01cb2d095a2fb77ba4524
import operator from django.db import DatabaseError, NotSupportedError, connection from django.db.models import Exists, F, IntegerField, OuterRef, Value from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature from django.test.utils import CaptureQueriesContext from .models import Number, ReservedName ...
12ad14124ff6aa4f7ddc1a7190fe08a91431f3f8bb39afa205ee255ea0132854
from django.test import TestCase from .models import DumbCategory, NamedCategory, ProxyCategory class ContainsTests(TestCase): @classmethod def setUpTestData(cls): cls.category = DumbCategory.objects.create() cls.proxy_category = ProxyCategory.objects.create() def test_unsaved_obj(self):...
e4e9b5158b8225058ba955132457e4a204a2d0281405ca8bf441079790e67fc8
""" Testing some internals of the template processing. These are *not* examples to be copied in user code. """ from django.template import Library, TemplateSyntaxError from django.template.base import ( FilterExpression, Lexer, Parser, Token, TokenType, Variable, ) from django.template.defaultfilters import registe...
cdd2d3688b3eed39d4f7173b21e07c9e1d7557758b86fece71c481a47e09315b
import logging from django.template import Engine, Variable, VariableDoesNotExist from django.test import SimpleTestCase class VariableResolveLoggingTests(SimpleTestCase): loglevel = logging.DEBUG def test_log_on_variable_does_not_exist_silent(self): class TestObject: class SilentDoesNot...
94dece01a3dbbfbc09453a19b6a3f81f8516013cffe66f8af07a9b59dc24ed85
from django.template import Context, Template, Variable, VariableDoesNotExist from django.test import SimpleTestCase from django.utils.translation import gettext_lazy class TemplateTests(SimpleTestCase): def test_lazy_template_string(self): template_string = gettext_lazy('lazy string') self.assert...
b1a7784e15c418e837b2859df3eb53a00e9b26d392cb4e09bac51506fa46d558
import os from unittest import TestCase from django.template import Engine from .utils import TEMPLATE_DIR class OriginTestCase(TestCase): def setUp(self): self.engine = Engine(dirs=[TEMPLATE_DIR]) def test_origin_compares_equal(self): a = self.engine.get_template('index.html') b = ...
8264df29220fb7983c241501d572147d3f96c1bb2579efe0a662819020e30c89
import datetime from unittest import skipUnless from django.db import connection from django.db.models import CASCADE, ForeignKey, Index, Q from django.db.models.functions import Lower from django.test import ( TestCase, TransactionTestCase, skipIfDBFeature, skipUnlessDBFeature, ) from django.test.utils import ove...
29b972725e220c9e527671a596c01f90ffe041d76e0895b04f58ec7c3f951990
import datetime from copy import deepcopy from django.core.exceptions import FieldError, MultipleObjectsReturned from django.db import IntegrityError, models, transaction from django.test import TestCase from django.utils.translation import gettext_lazy from .models import ( Article, Category, Child, ChildNullabl...
9ccac8b7cf857544679aa7002ae6a8e3fcb6163f8b24a20b8ad298d78866951f
""" Many-to-one relationships To define a many-to-one relationship, use ``ForeignKey()``. """ from django.db import models class Reporter(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30) email = models.EmailField() def __str__(self): ret...
430bbfdb74128bf535198260a1901e82960832ec2396e707cf7326f617e27ac5
import datetime from django.db import connection, models, transaction from django.test import ( SimpleTestCase, TestCase, TransactionTestCase, skipUnlessDBFeature, ) from .models import ( Award, AwardNote, Book, Child, Contact, Eaten, Email, File, Food, FooFile, FooFileProxy, FooImage, FooPhoto, House, Im...
9a9328c9312c415d1414ce692f3d223876182e0c41cb779e450c8def11073db4
""" 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...
187100177166a2c6da34e5ae74958c2e487a6d77324405156d238d690413441a
from django.http import HttpResponse from django.urls import path def empty_response(request): return HttpResponse() urlpatterns = [ path('middleware_urlconf_view/', empty_response, name='middleware_urlconf_view'), ]
05eb5617688d49b88a60c1ff34616d12909cf3d2c0d29032cc5ff62b7261c098
from django.core.exceptions import ImproperlyConfigured from django.core.handlers.wsgi import WSGIHandler, WSGIRequest, get_script_name from django.core.signals import request_finished, request_started from django.db import close_old_connections, connection from django.test import ( RequestFactory, SimpleTestCase, ...
07aafc142fc3248ac7cf6d69c5df7eb557a65e8bba8c3c452ab74a22d8ddc036
from django.core.handlers.wsgi import WSGIHandler from django.test import SimpleTestCase, override_settings from django.test.client import FakePayload class ExceptionHandlerTests(SimpleTestCase): def get_suspicious_environ(self): payload = FakePayload('a=1&a=2&a=3\r\n') return { 'REQU...
530e1f44c15d57ce71e9ef096407a615bceeb79eedadc78264e8a68aeb99edf7
"""Tests related to django.db.backends that haven't been organized.""" import datetime import threading import unittest import warnings from django.core.management.color import no_style from django.db import ( DEFAULT_DB_ALIAS, DatabaseError, IntegrityError, connection, connections, reset_queries, transaction,...
ec7f69cdee1339d0ab0fd8dc1d45b7815710cf3d50762c65815a8ab74b1e9019
from django.db import models from django.template import Context, Template from django.test import SimpleTestCase, TestCase, override_settings from django.test.utils import isolate_apps from .models import ( AbstractBase1, AbstractBase2, AbstractBase3, Child1, Child2, Child3, Child4, Child5, Child6, Child7, Re...
38d26401e7f24189405e652c082d0ef1cae5bd4c704fef26f1315c45e2c8cf6d
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...
2847f185ae572d9124364812b34f7813ab5f03db7d20a7058c6185ff31723c38
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...
817daee888807c73f37450720932ee8570bf563c166f750da092695180d27a38
""" 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...
7ffa8379c3cb922d86f3eac8931030445fa1421144c6c9c3e5891c2b7cbd93fb
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...
c956e2d3ddee64de32ef81e7dedf439833894e927704b8114db93e484db4961a
import sys from io import StringIO from django.apps import apps from django.core import checks from django.core.checks import Error, Warning from django.core.checks.messages import CheckMessage from django.core.checks.registry import CheckRegistry from django.core.management import call_command from django.core.manage...
6f01726167a3e1d67bd019d3efdf025e4f9b33139d3bb4c475a38eb67ee9d4af
from django.conf import settings from django.core.checks.messages import Error from django.core.checks.security import base, csrf, sessions from django.core.management.utils import get_random_secret_key from django.test import SimpleTestCase from django.test.utils import override_settings class CheckSessionCookieSecu...
f71284cdc057b051c6575a1d9661a27922ba00c6f0fbc4a3ee8a8109539f12a5
from django.core.checks import Error from django.core.checks.compatibility.django_4_0 import ( check_csrf_trusted_origins, ) from django.test import SimpleTestCase from django.test.utils import override_settings class CheckCSRFTrustedOrigins(SimpleTestCase): @override_settings(CSRF_TRUSTED_ORIGINS=['example....