hash
stringlengths
64
64
content
stringlengths
0
1.51M
a0d219e1eb26a31c01cc4cf9399fa98d444024c05c4d855373f6eeebcdad0042
from decimal import Decimal from django.contrib.gis.db.models.fields import BaseSpatialField, GeometryField from django.contrib.gis.db.models.sql import AreaField, DistanceField from django.contrib.gis.geos import GEOSGeometry from django.core.exceptions import FieldError from django.db.models import ( BooleanFiel...
a24a634122c2d56477e0895aa1805c6928aee9f97d9162ce14575105ebee2c00
""" This module contains the spatial lookup types, and the `get_geo_where_clause` routine for Oracle Spatial. Please note that WKT support is broken on the XE version, and thus this backend will not work on such platforms. Specifically, XE lacks support for an internal JVM, and Java libraries are required to use...
873f61fc3e410f7f4cd7eb86be23884ab3dfb021fb10b24bd4c60cd078911324
import re from django.contrib.gis.db.models import aggregates class BaseSpatialFeatures: gis_enabled = True # Does the database contain a SpatialRefSys model to store SRID information? has_spatialrefsys_table = True # Does the backend support the django.contrib.gis.utils.add_srs_entry() utility? ...
aeaa4c0514685dc62812427abee308dcdab27fc57b9c883f93d79fb0cfd2b299
from django.contrib.gis.db.models import GeometryField from django.contrib.gis.db.models.functions import Distance from django.contrib.gis.measure import ( Area as AreaMeasure, Distance as DistanceMeasure, ) from django.db.utils import NotSupportedError from django.utils.functional import cached_property class Ba...
de3b725beece59058220082bb748ee9aad9c78846e157971758b471d84a4abdc
from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures from django.db.backends.mysql.features import ( DatabaseFeatures as MySQLDatabaseFeatures, ) from django.utils.functional import cached_property class DatabaseFeatures(BaseSpatialFeatures, MySQLDatabaseFeatures): has_spatialrefsys_ta...
896360b7da69b667f47d259318a73827bc5d9a98ef8d32df342b606501667fc1
from MySQLdb.constants import FIELD_TYPE from django.contrib.gis.gdal import OGRGeomType from django.db.backends.mysql.introspection import DatabaseIntrospection class MySQLIntrospection(DatabaseIntrospection): # Updating the data_types_reverse dictionary with the appropriate # type for Geometry fields. ...
d9e2c5c2f418760f2e87ed5bf7e7700a170c7320287ba005ec68b9bb289fc556
from django.contrib.gis.db.backends.base.adapter import WKTAdapter from django.contrib.gis.db.backends.base.operations import ( BaseSpatialOperations, ) from django.contrib.gis.db.backends.utils import SpatialOperator from django.contrib.gis.db.models import aggregates from django.contrib.gis.geos.geometry import G...
0eda5113a6219b78915805356727dd518964115d73a5029ee50c3315d8d150ca
""" SQL functions reference lists: https://www.gaia-gis.it/gaia-sins/spatialite-sql-4.2.1.html """ from django.contrib.gis.db.backends.base.operations import ( BaseSpatialOperations, ) from django.contrib.gis.db.backends.spatialite.adapter import SpatiaLiteAdapter from django.contrib.gis.db.backends.utils import Sp...
ff42a1cf2f436a9ede421d8dafb33a14f24909d680c2fbfc0b6bd9ec2f768ba4
import re from django.conf import settings from django.contrib.gis.db.backends.base.operations import ( BaseSpatialOperations, ) from django.contrib.gis.db.backends.utils import SpatialOperator from django.contrib.gis.db.models import GeometryField, RasterField from django.contrib.gis.gdal import GDALRaster from d...
c9f1c95cffb3a640ed00cfed8b0f6df8a435ae9fd6ee3453ee65300d0eee508c
""" 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.test import LiveServerTestCase, override_settings from .models import Person TEST_ROO...
e36a7f1d1c0f3ce44bbf72cc371ffdbb3adbf54001300257c35196c93c47447f
from urllib.request import urlopen from django.http import HttpResponse, StreamingHttpResponse from django.views.decorators.csrf import csrf_exempt from .models import Person def example_view(request): return HttpResponse('example view') def streaming_example_view(request): return StreamingHttpResponse((b...
0d6a54d56f7b6738eb503f55bec43bbf609aab1ba94673f98305aaf48dbc3dd3
from django.db import migrations, models from django.db.migrations import operations from django.db.migrations.optimizer import MigrationOptimizer from django.test import SimpleTestCase from .models import EmptyManager, UnicodeModel class OptimizerTests(SimpleTestCase): """ Tests the migration autodetector. ...
b7cdf96d92f1a9b7d5fad15a24de26f3c1165aad1a43abfaa3c874803cddb13f
from unittest import mock from django.apps.registry import apps as global_apps from django.db import connection from django.db.migrations.exceptions import InvalidMigrationPlan from django.db.migrations.executor import MigrationExecutor from django.db.migrations.graph import MigrationGraph from django.db.migrations.re...
22780acec8716ed149a8f96f326782d00d59619b1b7105ec4d56c7dbf2aedd66
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, connection, connections, models, ) from django.db.backends.base.schema impor...
2a67c92c11deae99a465ba61a0f54839b81ae375f5e1236d98cff879af5c8df2
import datetime import decimal import enum import functools import math import os import re import uuid from unittest import mock import custom_migration_operations.more_operations import custom_migration_operations.operations from django import get_version from django.conf import SettingsReference, settings from dja...
8df93b930a777084c5b4de7eb8e31e1585c363b4d3bd1f3f64ff94e0eeaf4c2d
import compileall import os from django.db import connection, connections from django.db.migrations.exceptions import ( AmbiguityError, InconsistentMigrationHistory, NodeNotFoundError, ) from django.db.migrations.loader import MigrationLoader from django.db.migrations.recorder import MigrationRecorder from django....
75ba3e37e480be0b284b3d59219f178e0ebe7649d7935f8af98c18ad8199df07
from django.core.exceptions import FieldDoesNotExist from django.db import connection, migrations, models, transaction from django.db.migrations.migration import Migration from django.db.migrations.operations import CreateModel from django.db.migrations.operations.fields import FieldOperation from django.db.migrations....
14324e9241db462dd6722a5fb89d6d23f4586c9c59af44a93b70b81b3523ac64
from django.db import connection, migrations, models from django.db.migrations.state import ProjectState from django.test import override_settings from .test_operations import OperationTestBase class AgnosticRouter: """ A router that doesn't have an opinion regarding migrating. """ def allow_migrate(...
3141476001d02f093887c7af13b3a38e70139d16aa3a465aa7669bfd94ba0864
import os import sys import tempfile import unittest import warnings from io import StringIO from unittest import mock from django.apps import apps from django.contrib.sites.models import Site from django.core import management from django.core.files.temp import NamedTemporaryFile from django.core.management import Co...
4bf4f951bed0912bd136a0d7d49eb4fea7a34b3dcb53ce7184c4fe0212978e0f
import os import sys import unittest from types import ModuleType 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 ( SimpleTestCase, TestCase, ...
a7abfdbb9d36b9cec6ebe04cf67e1024eee34003e43a8583250e92d88ca0148d
import datetime import itertools import os import re from importlib import import_module from unittest import mock from urllib.parse import quote 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, RED...
80693b49aee6cef9fabecf3a7440562a14abff3efdb6a25c911bfbc67d755d3b
from unittest import mock from django.conf.global_settings import PASSWORD_HASHERS from django.contrib.auth import get_user_model from django.contrib.auth.base_user import AbstractBaseUser from django.contrib.auth.hashers import get_hasher from django.contrib.auth.models import ( AbstractUser, AnonymousUser, Group...
9e2ebb7839ea2815a861a77d6e6b2e5759da7491ebbfc0952567368263cb0815
from importlib import import_module from django.apps import apps from django.contrib.auth.models import Permission, User from django.contrib.contenttypes.models import ContentType from django.test import TestCase from .models import Proxy, UserProxy update_proxy_permissions = import_module('django.contrib.auth.migra...
9214afe3d8cd17e349a5448a4617b3316acabc9a9560871f1e761d9e0b352247
from datetime import date from unittest import mock from django.contrib.auth import ( BACKEND_SESSION_KEY, SESSION_KEY, authenticate, get_user, signals, ) from django.contrib.auth.backends import ModelBackend from django.contrib.auth.hashers import MD5PasswordHasher from django.contrib.auth.models import Anonymous...
6a55cd23bf1dee70fcc6d192ec83c1cf4dfce2159b4e56a36eb325b47cb211ef
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.messages.api import info...
6fcc95504251673322925d719dd05475988c7f4538e4af63b50d63355ea5bd89
import os from django.contrib.auth import validators from django.contrib.auth.models import User from django.contrib.auth.password_validation import ( CommonPasswordValidator, MinimumLengthValidator, NumericPasswordValidator, UserAttributeSimilarityValidator, get_default_password_validators, get_password_v...
81bf7e92d89cbe05a0e9e3694cebc7f60d2f852e232e188f96b9304cbfb3a2dc
import datetime import re from unittest import mock from django import forms from django.contrib.auth.forms import ( AdminPasswordChangeForm, AuthenticationForm, PasswordChangeForm, PasswordResetForm, ReadOnlyPasswordHashField, ReadOnlyPasswordHashWidget, SetPasswordForm, UserChangeForm, UserCreationForm, ...
3b97adf7fcf1c675f0760e90ef5970da7f211f053506f6e6aba5d6c825be179d
from django.conf import settings from django.contrib.auth import models from django.contrib.auth.decorators import login_required, permission_required from django.core.exceptions import PermissionDenied from django.http import HttpResponse from django.test import TestCase, override_settings from django.test.client impo...
ff55c5b83e3c59d7c64cb7e093792e147c5aa86ab4129396c788a5df8bf2388b
import os import shutil import sys import tempfile import threading import time import unittest from datetime import datetime, timedelta from io import StringIO from urllib.request import urlopen from django.core.cache import cache from django.core.exceptions import SuspiciousFileOperation from django.core.files.base ...
531eefa4d04ee5fcf812870fdedd06fc8ced9e9a4312ce03f8df7fa11b3b8d8d
import uuid from django.core.exceptions import ImproperlyConfigured from django.test import SimpleTestCase from django.test.utils import override_settings from django.urls import Resolver404, path, resolve, reverse from .converters import DynamicConverter from .views import empty_view included_kwargs = {'base': b'he...
8ed4be73b3977a27a4a63ffef7e38783ca518dcad74a24df80bf35ef7ca5cce6
import threading import time from unittest import mock from multiple_database.routers import TestRouter from django.core.exceptions import FieldError from django.db import ( DatabaseError, NotSupportedError, connection, connections, router, transaction, ) from django.test import ( TransactionTestCase, ove...
1a2bfed9dd14177c19e17d3f4578849de94ff99fc0454c172c81cdca2e5c70c8
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 from django.middleware.csrf import ( CSRF_SESSION_KEY, CSRF_TOKEN_LENGTH, REASON_BAD_TOKEN, REASON_NO_CSRF_COOKI...
b5153ded04be746e721fd552f71229b0feeff5fc27914a596fff3a6fd19582f5
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, Count, DecimalField, DurationField, F, FloatField, Func, IntegerField, Max, Min, Sum, Value, ) from django.test import TestCase from django.te...
a1a1be7ef27e32445fdd9b5ff1bf506e11f76604a07e5578a315e91bfd996267
import datetime from decimal import Decimal from django.db.models import Case, Count, F, Q, Sum, When from django.test import TestCase from .models import Author, Book, Publisher class FilteredAggregateTests(TestCase): @classmethod def setUpTestData(cls): cls.a1 = Author.objects.create(name='test', ...
7f4d6982e2c10a96083404dad3a5ade6d4285f9bd90b2c996c5b4a214e708705
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 ImproperlyConfigured ...
f35a3f4aa3114f1c088b836ec5ed9cc1a270b0f39eb0f805bd0be09188b87bb2
from django.urls import path from . import views urlpatterns = [ path('test_utils/get_person/<int:pk>/', views.get_person), path('test_utils/no_template_used/', views.no_template_used), ]
1a91a333dbffa9c765f668cbf12f871dcd24648a8bbb5b2defb5163c30f3145a
import datetime import os import re import unittest from unittest import mock from urllib.parse import parse_qsl, urljoin, urlparse import pytz from django.contrib.admin import AdminSite, ModelAdmin from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME from django.contrib.admin.models import ADDITION, DELETIO...
d3ad30be770081f3bdf4e901b300516c79d08b9b655043a409baf7687e4a5a4c
import datetime import os import tempfile import uuid 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 ValidationError from django.core.fil...
440dff4ce679e61ba065df61bbbe978477760709a5c354bb6cd4d35ab375bbc5
import datetime import os import tempfile 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 GroupAdmi...
e0bf3aace19d5b5076942619f4690ecd7988500af3db23e9c082f74b78fb73d3
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 PermissionDenied from django.core.files.temp import NamedTemporaryFile from django.core.mana...
52021f8a172e91be6196781ea563a55a446e5eb870ed1272c04b106fb782aeaa
from django.contrib.contenttypes.models import ContentType from django.core.exceptions import FieldError from django.db import IntegrityError from django.db.models import Q from django.test import SimpleTestCase, TestCase from .models import ( AllowsNullGFK, Animal, Carrot, Comparison, ConcreteRelatedModel, Fo...
778960649dbaa48358a3d2f376a501415c3418c7d815c9b9f27fd0add4457197
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.management import BaseCommand, CommandError, find_commands from django.core.management.utils import ( find_command, get_r...
cc13fc76d8c361a30f829f435d9831e98b5f51dafaa360ea5103b55a6ef18773
import sys import unittest from django.conf import settings 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 import fields from django.test im...
bfbf353fa71f9359a353f0ab2da28db78af3a7504b080451db241e36ddae388e
import errno import gzip import os import struct import tempfile import unittest from io import BytesIO, StringIO, TextIOWrapper from unittest import mock from django.core.files import File from django.core.files.base import ContentFile from django.core.files.move import file_move_safe from django.core.files.temp impo...
6ca13e50fd5af9e01464f0001ba2ab888cb85c2200b110eefe93ab2824eb8667
import decimal 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 django.test imp...
9278164f2ff98bda813e9285a6fb5c1e7ff890aa571e1f4f6ce79ded94a31960
import json from django.db.models.expressions import F, Value from django.test.testcases import skipUnlessDBFeature from django.test.utils import Approximate from . import PostgreSQLTestCase from .models import AggregateTestModel, StatTestModel try: from django.contrib.postgres.aggregates import ( ArrayA...
d3e414651de24120caf7f4508adf90a5eb80fabd36eac2f5fc33b66bf79b4ea2
""" Test PostgreSQL full text search. These tests use dialogue from the 1975 film Monty Python and the Holy Grail. All text copyright Python (Monty) Pictures. Thanks to sacred-texts.com for the transcript. """ from django.contrib.postgres.search import ( SearchQuery, SearchRank, SearchVector, ) from django.db.mode...
f653ebf1ccd41079cacf809881d49fbfad089b19e091801100cbc5e043e33356
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.test import ignore_warnings, override_settings from django.utils import timezone from django.utils.deprecati...
19bba564b360403b3ac636313fd314bea706258c6e14641a56752d400d171564
from django.core.serializers.json import DjangoJSONEncoder from django.db import models from .fields import ( ArrayField, BigIntegerRangeField, CICharField, CIEmailField, CITextField, DateRangeField, DateTimeRangeField, DecimalRangeField, HStoreField, IntegerRangeField, JSONField, SearchVectorField, ) cl...
66889acec3d2021c5ce016f49a9d0845bfc2d61ed71a7767a8e54f62fe9f4ca8
""" Indirection layer for PostgreSQL-specific fields, so the tests don't fail when run with a backend other than PostgreSQL. """ from django.db import models try: from django.contrib.postgres.fields import ( ArrayField, BigIntegerRangeField, CICharField, CIEmailField, CITextField, DateRangeField, D...
c4f83dff73cf26772a13256a4df6094bf303a1b3b2a846332d91a945c103043e
from unittest import mock from django.contrib.postgres.indexes import ( BrinIndex, BTreeIndex, GinIndex, GistIndex, HashIndex, SpGistIndex, ) from django.db import connection from django.db.models import CharField from django.db.models.functions import Length from django.db.models.query_utils import Q from django....
40efdafc7e60c9a7b3069b92393622c22e8af9b55f1c70749e04c7c0db573e3c
import datetime import uuid from decimal import Decimal from django.core import checks, exceptions, serializers from django.core.serializers.json import DjangoJSONEncoder from django.db.models import Q from django.forms import CharField, Form, widgets from django.test.utils import isolate_apps from django.utils.html i...
b46f5a3745537d286dd06f6143a0e11a455c32c24dcf05511567618954585367
from django.urls import path from . import feeds urlpatterns = [ path('syndication/rss2/', feeds.TestRss2Feed()), path( 'syndication/rss2/guid_ispermalink_true/', feeds.TestRss2FeedWithGuidIsPermaLinkTrue()), path( 'syndication/rss2/guid_ispermalink_false/', feeds.TestRss2F...
a3272dc010fba6cdd137444ef24efee03af8669599e4345a22244bf7a3aac329
import datetime from decimal import Decimal from django.core.exceptions import FieldDoesNotExist, FieldError from django.db.models import ( BooleanField, CharField, Count, DateTimeField, ExpressionWrapper, F, Func, IntegerField, NullBooleanField, OuterRef, Q, Subquery, Sum, Value, ) from django.db.models.expre...
a49d0eb7fac4360a31a9df12849af89bbc7959c673bed5b3e234a00779f723ca
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 PeopleMore...
aa35dc58b0dd31fe7cd1c5efdc9735db62e25e25db32c6f98fcecfc9dde43b20
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...
a21d561ba3f618f7a6c7216c20e99d33f16616b1bf4116f54c3bac6914275eb4
from django.http import HttpResponse from django.test import RequestFactory, SimpleTestCase from django.test.utils import override_settings class SecurityMiddlewareTest(SimpleTestCase): @property def middleware(self): from django.middleware.security import SecurityMiddleware return SecurityMid...
9aa29ff1c764480ef073d6ed8e9a4c5fc758773c617884ae993c47e1b3a092c1
from django.contrib import admin from django.contrib.admin.sites import AdminSite from django.contrib.auth.models import User from django.contrib.contenttypes.admin import GenericTabularInline from django.contrib.contenttypes.models import ContentType from django.forms.formsets import DEFAULT_MAX_NUM from django.forms....
afa57385f9a3dcf848bbed3839adfcd62c490b2065601d72b0b85a902eb8a1cc
""" 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, ...
e3600224a9ca64e7e201895c25934f25c9195588e26914a7aa7af017bea56e73
import codecs import datetime import os import shutil import tempfile import unittest from io import StringIO 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.management.command...
3e342e01bc4b6997d62dfbe5f949eeedb926730d2c5a4e954c118518fd245b34
import os import shutil import sys import tempfile import unittest from io import StringIO from django.conf import settings from django.contrib.staticfiles import finders, storage from django.contrib.staticfiles.management.commands.collectstatic import ( Command as CollectstaticCommand, ) from django.core.cache.ba...
6e705b38ca27b2897c3e201430602ef4dd43b9a7bc708e0ae358c6cc0dd3dd57
import io 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 FileResponseTests(SimpleTestCase): def test_file_from_disk_response(self): response = FileResponse(op...
cb0d7e8e66e6df728204a2f6594096dd08dba65c722719fdfa972ab40c47a274
from django.contrib.contenttypes.models import ContentType, ContentTypeManager from django.db import models from django.test import TestCase, override_settings from django.test.utils import isolate_apps from .models import Author, ConcreteModel, FooWithUrl, ProxyModel class ContentTypesTests(TestCase): def setU...
2fdba58fa7ecd358cbf37926c91f8820c788fb9b787ebcb48483d682ac92987c
""" 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...
da93938f9df74d141c17726af6c595d04c7ba22322172f1c7bd744b8f9c25ef6
from django.urls import include, path from django.views.generic import RedirectView from . import views urlpatterns = [ path('', include('test_client.urls')), path('no_template_view/', views.no_template_view), path('staff_only/', views.staff_only_view), path('get_view/', views.get_view), path('re...
57fbbd6301c766fd8fca1dc3b74c6e834538e9eff4e31cc99ab1f77470375509
from operator import attrgetter from django.test import TestCase from .models import Person class RecursiveM2MTests(TestCase): @classmethod def setUpTestData(cls): cls.a, cls.b, cls.c, cls.d = [ Person.objects.create(name=name) for name in ["Anne", "Bill", "Chuck", "David"] ...
7af3d246775bc7fdae4b12b742b94bface58e7fd0e41a36efac942cb2198f0c4
from django.core.exceptions import FieldError from django.db.models import Count, F, Max from django.test import TestCase from .models import A, B, Bar, D, DataPoint, Foo, RelatedPoint class SimpleTest(TestCase): @classmethod def setUpTestData(cls): cls.a1 = A.objects.create() cls.a2 = A.obje...
c70d4b0c32744ac2d56dfc41f11a254dc6a0d0254b4ba247913fa090c549bb8f
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 ( TransactionTestCase, skipIfDBFeature, skipUnlessDBFeature, ) from .models import Reporter @...
3ef6e4b3bd216f7ae4f31ce7840d40df2b95856f5866c8a716cc2522331779b6
# 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 tempfile import threading import time import unittest from unittest import mock from django.conf import settings from django.core import manageme...
a75ba111b3ae5ab84c9e1704cfeba3d5cdc6943254c40100f6ca7300dc5a6ed3
import datetime import unittest from unittest import mock from urllib.parse import quote_plus from django.test import SimpleTestCase from django.utils.encoding import ( DjangoUnicodeDecodeError, escape_uri_path, filepath_to_uri, force_bytes, force_text, get_system_encoding, iri_to_uri, smart_bytes, smart_text,...
e71fdab3a5bc021e61386024fc8bbaa18e1c4a7038144047a58378845ca58bb3
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...
fe89e3e0c3f85b6caee406d73f44100b42cab025b625f2d75ede97a8155988a4
from django.template import Context, Template from django.test import SimpleTestCase from django.utils import html from django.utils.functional import lazy, lazystr from django.utils.safestring import SafeData, mark_safe class customescape(str): def __html__(self): # implement specific and obviously wrong...
83d450064b19e26e563cfeecb0a99e12ae9dbba79219328c01c7f593a3242de6
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...
5ad60b39431d7561d55319bbeb78df9ba419238434f1a54eea810b0ade301613
import unittest from django.test import SimpleTestCase from django.utils.functional import cached_property, lazy from django.utils.version import PY36 class FunctionalTests(SimpleTestCase): def test_lazy(self): t = lazy(lambda: tuple(range(3)), list, tuple) for a, b in zip(t(), range(3)): ...
4b98909c6549ccf74f37b9908f6ff0d70e5cbc7912c948a9cd89b111635f4e55
import contextlib import os import py_compile import shutil import sys import tempfile import threading import time import zipfile from importlib import import_module from pathlib import Path from unittest import mock, skip from django.apps.registry import Apps from django.test import SimpleTestCase from django.test.u...
bc00311c668ea03dafbafa07f753ef886b220a0133104a2788ba9e931d476b3e
""" Tests for stuff in django.utils.datastructures. """ import copy from django.test import SimpleTestCase from django.utils.datastructures import ( CaseInsensitiveMapping, DictWrapper, ImmutableList, MultiValueDict, MultiValueDictKeyError, OrderedSet, ) class OrderedSetTests(SimpleTestCase): def test_...
cfd4d9bae1475dca4ce2985cf9f10d5359ba7c1f69ad06618101f99e94500ea7
import unittest from datetime import datetime 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_safe_url, is_same_domain, parse_etags, parse_http_date, quote_etag, ...
4ea54d2bef691673bfa069e61a7e3db7cd1515d9c070a893600c8aaa6130c428
import json import sys 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('\U0001F4A9') == 1) class TestUtilsText(SimpleTestCase): ...
9f2175b02e97a3ae479097b7e3a7cadaba4fe9fae04d741d23f9dc3f4b5372fa
import threading from datetime import datetime, timedelta from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist from django.db import DEFAULT_DB_ALIAS, DatabaseError, connections from django.db.models.manager import BaseManager from django.db.models.query import EmptyQuerySet, QuerySet from dj...
39ae666717fc819d286891cc8c6dd888d9073156302db4822cea853fda2d1173
""" 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....
9b5a77de146b1679d310daf732c9a4a904905eccf44df2f8739f8e86118a7cd3
import os from argparse import ArgumentParser from contextlib import contextmanager from unittest import TestSuite, TextTestRunner, defaultTestLoader from django.db import connections from django.test import SimpleTestCase from django.test.runner import DiscoverRunner from django.test.utils import captured_stdout @c...
8b715bbace4db65718da98c5fa582668d66f1a2f6e67c3910f1233344a8f0a4b
from unittest import mock from django.db import connection, transaction from django.test import TestCase, skipUnlessDBFeature from django.test.utils import CaptureQueriesContext from .models import ( Article, InheritedArticleA, InheritedArticleB, NullablePublicationThrough, NullableTargetArticle, Publication,...
dc0373ce789ae2b5a136d561952bc922066066aa7ae0b349bc65374e5f46a67f
""" Many-to-many relationships To define a many-to-many relationship, use ``ManyToManyField()``. In this example, an ``Article`` can be published in multiple ``Publication`` objects, and a ``Publication`` has multiple ``Article`` objects. """ from django.db import models class Publication(models.Model): title =...
f8262bca7cb02d18c2e7cf0a4657cc17fd238fda90e7b3fb049dad6fae820a94
from io import BytesIO from itertools import chain from urllib.parse import urlencode from django.core.exceptions import DisallowedHost from django.core.handlers.wsgi import LimitedStream, WSGIRequest from django.http import HttpRequest, RawPostDataException, UnreadablePostError from django.http.request import HttpHea...
094d78e128de28b30d03e845887106eb7c01af7f29f41f3768ba9231f56594de
import datetime import pickle import unittest from collections import OrderedDict from operator import attrgetter from django.core.exceptions import EmptyResultSet, FieldError from django.db import DEFAULT_DB_ALIAS, connection from django.db.models import Count, F, Q from django.db.models.sql.constants import LOUTER f...
22ab2859ee1343e764ac6dd248d7ada5bab7d4ba8839eb55e10b7de69bca4efb
from django.db.models import Exists, F, IntegerField, OuterRef, Value from django.db.utils import DatabaseError, NotSupportedError from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature from .models import Number, ReservedName @skipUnlessDBFeature('supports_select_union') class QuerySetSetOperationTe...
f6f7875e8eedca288532d34a0f0ffe2f01161799fab6fe32f1dc4bbb2f0dcf4e
from datetime import datetime from django.core.exceptions import FieldError from django.db.models import CharField, F, Q from django.db.models.expressions import SimpleCol from django.db.models.fields.related_lookups import RelatedIsNull from django.db.models.functions import Lower from django.db.models.lookups import...
277ad80b4f7be075deb7f01675ed7e2cef84f22abb93e4b16d083f3bb9daeeb7
from django.http import HttpRequest from django.template import ( Context, Engine, RequestContext, Template, Variable, VariableDoesNotExist, ) from django.template.context import RenderContext from django.test import RequestFactory, SimpleTestCase class ContextTests(SimpleTestCase): def test_context(self): ...
2958fe45c288a13d3b348111b5e0c9a6c689fb8d08424aca9e90d0d3e2334321
from django.template import Library from django.template.base import Node from django.test import SimpleTestCase class FilterRegistrationTests(SimpleTestCase): def setUp(self): self.library = Library() def test_filter(self): @self.library.filter def func(): return '' ...
a2974d8583b19cff5bb47940c976cb2c4f29ea588437403d50a5d04b766ef222
import os.path import sys import tempfile import unittest from contextlib import contextmanager from django.template import TemplateDoesNotExist from django.template.engine import Engine from django.test import SimpleTestCase, override_settings from django.utils.functional import lazystr from .utils import TEMPLATE_D...
35e57ad711ff0c563a0c568218aa5c89d18f18942471eece956d2021988588f5
import pickle import time from datetime import datetime from django.template import engines from django.template.response import ( ContentNotRenderedError, SimpleTemplateResponse, TemplateResponse, ) from django.test import ( RequestFactory, SimpleTestCase, modify_settings, override_settings, ) from django.tes...
331135f2f418e2667b0162630c4984fec65a3f9d3637221dead780fbfede1014
import datetime from unittest import skipIf, skipUnless from django.db import connection from django.db.models import Index from django.db.models.deletion import CASCADE from django.db.models.fields.related import ForeignKey from django.db.models.query_utils import Q from django.test import ( TestCase, Transaction...
b2c47e237323785ec79b170e46e752004e5e8067673dc4a8f1ddcc1173d84bd7
import datetime from copy import deepcopy from django.core.exceptions import FieldError, MultipleObjectsReturned from django.db import models, transaction from django.db.utils import IntegrityError from django.test import TestCase from django.utils.translation import gettext_lazy from .models import ( Article, Ca...
bb5bba3216555e41e09036c98caaad8cd929889ff0701bd1d8a5310a5ee5843a
""" 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...
fc8eb6836c75141f823e5dda42685e94a509f25d4b79855da17cb4d7fe903990
import base64 import os import shutil import string import tempfile import unittest from datetime import timedelta from http import cookies from django.conf import settings from django.contrib.sessions.backends.base import UpdateError from django.contrib.sessions.backends.cache import SessionStore as CacheSession from...
85e66661365fcd0c85b5fa89eab864c981d01151e749373670c329b7264268b6
""" 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...
0899e6cc16888f9794691236eebb5612f3105b88ab70bf931340a01c8107cce0
"""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,...
45efe2023eae9abbf9900454117cd8d0e454e2ca755be13603a8d98d4aeed27b
import datetime import itertools import unittest from copy import copy from unittest import mock from django.db import ( DatabaseError, IntegrityError, OperationalError, connection, ) from django.db.models import Model from django.db.models.deletion import CASCADE, PROTECT from django.db.models.fields import ( ...
28062509e2b8e4c4ff69c9db3c4b88ba86fd56ca048aabcd187e9b68f3b8bb02
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...
517bff27e9a2b90b36444bc54b1131f59492e989c67153d9426fba11d786478e
""" 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...