hash
stringlengths
64
64
content
stringlengths
0
1.51M
c0245a2f09a163337e01194e3600aba353f365647ee94c1509fa318fd0f79768
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...
77119ea8912468cc906af0e0a910d4b64fe0e5851149013100fdb59b63c158c9
from django.contrib.auth.models import User from django.test import override_settings from .tests import AdminDocsTestCase, TestDataMixin class XViewMiddlewareTest(TestDataMixin, AdminDocsTestCase): def test_xview_func(self): user = User.objects.get(username='super') response = self.client.head(...
878c89f0ddbcd15232ef9494afc9c93a183fb528c8edcf4dbcaab005c68d030b
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 ...
28ffcd570fbbfe3106bde76cea6ca91e7fc8d5bdffa08adb4813dbc855a2bb5c
import json from django.db.models import CharField, F, 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.utils import Approximate from . import PostgreSQLTestCase from .models import Aggrega...
dfed9602fd143408733a613a490d3e83e5b5e40c818d72f9baaec39a00b5c365
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...
765fc77ffb65d3ab0324fce8cb863af8a383ca75cfe44bd5cef9688b6f6979d6
import unittest from unittest import mock from migrations.test_base import OperationTestBase from django.db import NotSupportedError, connection from django.db.migrations.state import ProjectState from django.db.models import Index from django.db.utils import ProgrammingError from django.test import modify_settings, ...
ef06542e8747137825ea93c0b2eaf5753cd567ebd9b49fbafb1ee0b8d64c0a76
import datetime from unittest import mock from django.db import ( IntegrityError, NotSupportedError, connection, transaction, ) from django.db.models import ( CheckConstraint, Deferrable, F, Func, Q, UniqueConstraint, ) from django.db.models.fields.json import KeyTextTransform from django.db.models.functions i...
69f4b5044e984ade14316f109789c3f844874d8f93d2c67069ae601256a335ad
import datetime from xml.dom import minidom from django.contrib.sites.models import Site from django.contrib.syndication import views from django.core.exceptions import ImproperlyConfigured from django.test import TestCase, override_settings from django.test.utils import requires_tz_support from django.utils import ti...
9fce085495e1c1b848bcc1a92ab84a2946cef8bac52feff3cf4fed37908f3483
from django.db import models class Entry(models.Model): title = models.CharField(max_length=200) updated = models.DateTimeField() published = models.DateTimeField() class Meta: ordering = ('updated',) def __str__(self): return self.title def get_absolute_url(self): r...
f52e1248a22d5598d5e53061405e4bb6e5b47b442d7b2bb0528b86b3003fafc4
from django.contrib.syndication import views from django.utils import feedgenerator from django.utils.timezone import get_fixed_timezone from .models import Article, Entry class TestRss2Feed(views.Feed): title = 'My blog' description = 'A more thorough description of my blog.' link = '/blog/' feed_gu...
b44435f94dfc4ed2cd7dfbf7094628e6ff13eae5ba6b95b0f9bb9f45ab5caa81
from django.urls import path from . import feeds urlpatterns = [ path('syndication/rss2/', feeds.TestRss2Feed()), path('syndication/rss2/articles/<int:entry_id>/', feeds.TestGetObjectFeed()), path( 'syndication/rss2/guid_ispermalink_true/', feeds.TestRss2FeedWithGuidIsPermaLinkTrue()), ...
c511da83c55b4c59d549f331b92f680b29a64650df4fdd467a2fe76fb708a362
import datetime from decimal import Decimal from django.core.exceptions import FieldDoesNotExist, FieldError from django.db import connection from django.db.models import ( BooleanField, Case, Count, DateTimeField, Exists, ExpressionWrapper, F, FloatField, Func, IntegerField, Max, NullBooleanField, OuterRef, Q...
f35c77eae01fd64322d3f948ba3ab472d9e4c55fb6a6d83e4904ac08b9093865
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 ...
db07c1d8260ad31d2761c5082db96e22772c86dc89aff2edf57792bed4a48e15
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...
01f5deace90414a6b330fa846f437d2700c57154297fd5b08f05bce8309be6d1
from django.test import SimpleTestCase, override_settings from django.test.utils import require_jinja2 @override_settings(ROOT_URLCONF='shortcuts.urls') class RenderTests(SimpleTestCase): def test_render(self): response = self.client.get('/render/') self.assertEqual(response.status_code, 200) ...
46c6331b262673f7b06e2d4b2b430688745f4ab5a25074f7aee787b9873d16db
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...
34a3ecb2b096e6acff614ca5c9e422cae8b30d489eb36bda8bed15998eddb5e2
from django.contrib.auth import views as auth_views from django.contrib.auth.decorators import login_required from django.urls import path, re_path from django.views.decorators.cache import cache_page from django.views.generic import TemplateView, dates from . import views from .models import Book urlpatterns = [ ...
bc71f4ec6d7001e36e9d9c474683c12c1bca8bdb41a2709a7e58bfe8380d504b
import gzip import random import re import struct from io import BytesIO from urllib.parse import quote from django.conf import settings from django.core import mail from django.core.exceptions import PermissionDenied from django.http import ( FileResponse, HttpRequest, HttpResponse, HttpResponseNotFound, Http...
8815bdb62d9e15ad815b93f3c321aee2030f2f89b045df9e38f1795398a2cb8a
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...
043180fdce380f45a432e8de381e21dd07402cb0c2d353f37ac8b4b460bb3325
from django.urls import path, re_path from . import views urlpatterns = [ path('noslash', views.empty_view), path('slash/', views.empty_view), path('needsquoting#/', views.empty_view), # Accepts paths with two leading slashes. re_path(r'^(.+)/security/$', views.empty_view), # Should not append...
f6c8efe70199b2b997b20ddeac094fe2031607a94dec9dd8d75ca24dc26d053b
from django.http import HttpResponse from django.utils.decorators import method_decorator from django.views.decorators.common import no_append_slash from django.views.generic import View def empty_view(request, *args, **kwargs): return HttpResponse() @no_append_slash def sensitive_fbv(request, *args, **kwargs):...
34579d26ad19e2de0650af0fd418ec1ed56435fa592d01ea97106d446ee504bf
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....
4dfe7edf55f5dc1731e5872ef5e0d97f3608542a0f51c952c2ed1c4853a0ab50
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...
b30857dc968f9463b1ea12be87680054c9e6ec43068001e3c784840ba294931a
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...
df910860ff9f15d727a29e377a54b18b04c02cbdc0c6a43bad948ee3bd4a1c50
import time from datetime import datetime, timedelta from http import cookies from django.http import HttpResponse from django.test import SimpleTestCase from django.test.utils import freeze_time from django.utils.http import http_date from django.utils.timezone import utc class SetCookieTests(SimpleTestCase): ...
28bef90b374d4973887c6f620dc6ae9f3b39901c2c1cce181ce8608f63c04242
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...
f375dcdaf051fd0b93bd3d12713c5e54a4ddba00652eb6f338d9aaa72535e299
import io from django.conf import settings from django.core.cache import cache from django.http import HttpResponse from django.http.response import HttpResponseBase from django.test import SimpleTestCase UTF8 = 'utf-8' ISO88591 = 'iso-8859-1' class HttpResponseBaseTests(SimpleTestCase): def test_closed(self): ...
64aafce922693ab4af29cddcfed44e2d0ee6a8fbe7958d115661cb829dc7959b
import datetime from unittest import mock from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.views import shortcut from django.contrib.sites.models import Site from django.contrib.sites.shortcuts import get_current_site from django.http import Http404, HttpRequest from django.t...
7372aad6d1d3d4e913dd5ad50066d74ef05491a21e2f262a3d97be56df87007a
""" 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...
4386f5c910fc91383718e41ced969536740485c4f065118bd591025fa9c021b0
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...
dcb11674d4909980266c8aca0b5145ec3094c3a349281677d03a6306e64d976f
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...
97be09ec278e9093b1842482cf6665ab85c9134e0f6a613e022fa645417c3177
# 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...
fdbc8e20761c78feb86f0b37cb13d8fdc295f0b8ffd19e9c174a60bc36f2ab8e
from django.test import SimpleTestCase from django.utils.hashable import make_hashable class TestHashable(SimpleTestCase): def test_equal(self): tests = ( ([], ()), (['a', 1], ('a', 1)), ({}, ()), ({'a'}, ('a',)), (frozenset({'a'}), {'a'}), ...
503a5642de9b253cbc4d65f360631b5ec3dd97e30068648706aba1817798a9b1
import platform import unittest from datetime import datetime from unittest import mock from django.test import SimpleTestCase, ignore_warnings from django.utils.datastructures import MultiValueDict from django.utils.deprecation import RemovedInDjango40Warning from django.utils.http import ( base36_to_int, escape_...
ea19872657c1ba02cd227eaadf5fc219d16df25dd838bf644366c5bbc3522fd0
""" A test spanning all the capabilities of all the serializers. This class defines sample data and a dynamically generated test case that is capable of testing the capabilities of the serializers. This includes all valid data values, plus forward, backwards and self references. """ import datetime import decimal impo...
55e56d02f563e43c57af81e200dcb1b7dda93e405912af6283dc5604070524ec
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....
33ea1d2539f478ed0f5ef4b5853680bb4af15100fb51f224547b10c519fbf101
""" 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....
72e480d412000545d68a06ee1de2d45abf8a20e8250d2f3fe2895adb32d4a191
import os from argparse import ArgumentParser from contextlib import contextmanager from unittest import ( TestSuite, TextTestRunner, defaultTestLoader, mock, skipUnless, ) from django.db import connections from django.test import SimpleTestCase from django.test.runner import DiscoverRunner from django.test.utils ...
260adaa1c927e80a69736c22c27d19cf4532891d2c7038585bdb114f5567196c
from datetime import datetime from decimal import Decimal from django import forms from django.conf import settings from django.contrib.admin import helpers from django.contrib.admin.utils import ( NestedObjects, display_for_field, display_for_value, flatten, flatten_fieldsets, help_text_for_field, label_for_f...
e9b3fb4024120e1b4cc2420938701a43e8d2b2ef36487ab9f6526c0fb1b89647
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...
2959269eb5e06652bb845ad56e37e157923951d0ea5eb258f6e244dcbdd9644f
""" 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...
d6ebf251541da82ddd465e03003e09cb34fb80a99b19192e22c9f210198eb3a1
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 .models import Number, ReservedName @skipUnlessDBFeature('supports_select_union') class...
4a5516dcd9eec40875ce741f5f892a6d7f3789c75f1ac593bd4cfefcdc4d6a70
import unittest from django.db import NotSupportedError, connection, transaction from django.db.models import Count from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature from django.test.utils import CaptureQueriesContext from .models import Tag @skipUnlessDBFeature('supports_explaining_query_execu...
f8a962849b142dafa7ed3537886013bfc589df5d9b185ef2b699661eca546c55
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...
dc573da178fe630edaa6b1fb9b0cab7ed52ad6dbeec2f6204e4cc537d631ae07
from django.db import models class CurrentTranslation(models.ForeignObject): """ Creates virtual relation to the translation with model cache enabled. """ # Avoid validation requires_unique_target = False def __init__(self, to, on_delete, from_fields, to_fields, **kwargs): # Disable r...
8faf023a714de838d8e264df37b71835178f49049680a498498b32af95895ee1
import datetime import re from datetime import date from decimal import Decimal from django import forms from django.core.exceptions import ImproperlyConfigured, ValidationError from django.db import models from django.forms.models import ( BaseModelFormSet, _get_foreign_key, inlineformset_factory, modelformse...
dd4ae4764084a22611a193a864a0c9ee5797933ce126a31aab249b889e3bc485
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 django.conf import settings from django.contrib.sessions.backends.base import UpdateError from django.contrib.sessions.backends.cache import SessionS...
a72daae0e8fd4d4772a2b598fe7de6cbf9025bb2a8af6f62fe3ae3cb478356c9
from datetime import datetime from django.contrib.sitemaps import GenericSitemap from django.test import override_settings from .base import SitemapTestsBase from .models import TestModel @override_settings(ABSOLUTE_URL_OVERRIDES={}) class GenericViewsSitemapTests(SitemapTestsBase): def test_generic_sitemap_at...
c5c83523e7c7d6675cda76237ea5c4716aff2f6e0e46095282dc8707a174e778
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 modify_settings, override_settings from django.utils import translation from django.utils.formats import localize ...
1fa0ed75576aa81a0b09698ac22e9eafad8ae61fa5fc139dcdf2d7e32bea0b96
""" 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...
f3ed1cbcae87ec8cb8fa04de18a5b233d5cb56a1aef799cea3ae47c053621c38
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 ...
b280d38814102733c4174097d58801c73d6e306fe2155b40a287c9ae45d79a02
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, ...
635316d77b554f4689a43bdb2b5d0d58963e2e4d9e7234834fb62e39852ad639
from django.urls import path from . import views urlpatterns = [ path('regular/', views.regular), path('async_regular/', views.async_regular), path('no_response_fbv/', views.no_response), path('no_response_cbv/', views.NoResponse()), path('streaming/', views.streaming), path('in_transaction/',...
17bda7516799561c6b5c007970b33453e7e0873370c412947488cdc0c139a90d
import asyncio from http import HTTPStatus from django.core.exceptions import BadRequest, SuspiciousOperation from django.db import connection, transaction from django.http import HttpResponse, StreamingHttpResponse from django.views.decorators.csrf import csrf_exempt def regular(request): return HttpResponse(b"...
aeeb86e8deb7ae22df55b8aff21fc0bf4a8c2cb5d3fb5e76c2f9f41f2af1980f
import datetime import itertools import unittest from copy import copy from unittest import mock from django.core.management.color import no_style from django.db import ( DatabaseError, DataError, IntegrityError, OperationalError, connection, ) from django.db.models import ( CASCADE, PROTECT, AutoField, BigAut...
0b87a36ea6c9dcf976f761c07934564c291b8575a361d9481dabb6a66a0bd9f1
from functools import update_wrapper, wraps from unittest import TestCase 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, HttpResponseNotA...
39de702019b00266f34432e290b4c87fb6aa3b9b91aff27aa8639eda853d7d88
from datetime import datetime from django.test import SimpleTestCase, override_settings FULL_RESPONSE = 'Test conditional get response' LAST_MODIFIED = datetime(2007, 10, 21, 23, 21, 47) LAST_MODIFIED_STR = 'Sun, 21 Oct 2007 23:21:47 GMT' LAST_MODIFIED_NEWER_STR = 'Mon, 18 Oct 2010 16:56:23 GMT' LAST_MODIFIED_INVALID...
02b8b806d3cec741c3c8a5d008ecab0ae73db81a26e10534d7f2ab6c0ddc243f
""" 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 subprocess import sys import tempfile import unittest from io imp...
5ae8876bcf0251aa437b4790cd5406e634c7cb9faf40c715abc1b5d7565c846f
from math import ceil from operator import attrgetter from django.db import IntegrityError, NotSupportedError, connection from django.db.models import FileField, Value from django.db.models.functions import Lower from django.test import ( TestCase, override_settings, skipIfDBFeature, skipUnlessDBFeature, ) from ....
d19940fa1bb82826a894a1d5b0230d523e145e2241bfa019f6217d413198a594
import datetime from decimal import Decimal from unittest import mock, skipIf 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, V...
b03d1bc5494f46754d1394bfd8790df6cf117f41937bc51c25e3b717e4d38e8c
from django.db import models class Classification(models.Model): code = models.CharField(max_length=10) class Employee(models.Model): name = models.CharField(max_length=40, blank=False, null=False) salary = models.PositiveIntegerField() department = models.CharField(max_length=40, blank=False, null=...
eb8820419aefbaa5ba0207d90eaa01e5124673a280d231366c041768556bcc4f
import asyncio import threading from asgiref.sync import async_to_sync from django.contrib.admindocs.middleware import XViewMiddleware from django.contrib.auth.middleware import ( AuthenticationMiddleware, RemoteUserMiddleware, ) from django.contrib.flatpages.middleware import FlatpageFallbackMiddleware from djan...
50c39b60f32414ed20293a604fd6bc971c48708527cd8edff88b8064315d4570
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.files import temp as tempfile from django.core.files.uploadedfile import SimpleUploadedFile from dja...
98fd5a32743e44723c48600a79fc61737ad664e7f0ff067d489dfca2f48808c7
""" Upload handlers to test the upload API. """ from django.core.files.uploadhandler import ( FileUploadHandler, StopUpload, TemporaryFileUploadHandler, ) class QuotaUploadHandler(FileUploadHandler): """ This test upload handler terminates the connection if more than a quota (5MB) is uploaded. ""...
c6a4b8558f99a78ed712d80f16cdcde3c0e6532c45018edeaeb11f32286027bd
from django.urls import path, re_path from . import views urlpatterns = [ path('upload/', views.file_upload_view), path('verify/', views.file_upload_view_verify), path('unicode_name/', views.file_upload_unicode_name), path('echo/', views.file_upload_echo), path('echo_content_type_extra/', views.fi...
de27718a04b9ea87b08d1e6fec9a300102b978fb9fda724ac38f3c8b8c07ed9c
import hashlib import os from django.core.files.uploadedfile import UploadedFile from django.core.files.uploadhandler import TemporaryFileUploadHandler from django.http import HttpResponse, HttpResponseServerError, JsonResponse from .models import FileModel from .tests import UNICODE_FILENAME, UPLOAD_TO from .uploadh...
9615aad97f961c8e46c290bfe86ae82f8694398602b4a2244ecb2dc24431a71f
import datetime import os from decimal import Decimal from unittest import mock, skipUnless from django import forms from django.core.exceptions import ( NON_FIELD_ERRORS, FieldError, ImproperlyConfigured, ValidationError, ) from django.core.files.uploadedfile import SimpleUploadedFile from django.db import connec...
f7c75c7e5cd45bb0204756bc20509839214c2aed67c983efed5d3447b17105c1
import datetime import os import tempfile import uuid from django.core import validators from django.core.exceptions import ValidationError from django.core.files.storage import FileSystemStorage from django.db import models temp_storage_dir = tempfile.mkdtemp() temp_storage = FileSystemStorage(temp_storage_dir) cl...
c07c4998a53dfd717e97f7e63451f009cdbc6d048255e7431d2886bc6d0fdc89
import re from django.db import connection from django.test import TestCase, skipUnlessDBFeature from django.utils.functional import cached_property from .utils import oracle, postgis, spatialite test_srs = ({ 'srid': 4326, 'auth_name': ('EPSG', True), 'auth_srid': 4326, # Only the beginning, because...
2e9b01ba8c014bf610bc8df582f997b34bff84983331734d26f2494cd6a97385
import copy import unittest from functools import wraps from unittest import mock from django.conf import settings from django.db import DEFAULT_DB_ALIAS, connection from django.db.models import Func def skipUnlessGISLookup(*gis_lookups): """ Skip a test unless a database supports all of gis_lookups. """...
c6dd098929b6c32d88fc2c66b07a075efb5cfbe515b87837b3670067bca5f165
from math import ceil from django.db import connection, models from django.db.models import ProtectedError, RestrictedError from django.db.models.deletion import Collector from django.db.models.sql.constants import GET_ITERATOR_CHUNK_SIZE from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature from .mo...
98b6b8d7e15a16e5afeb3a96038d7b633da25f40e320dd41cad9c15330986b49
from django.contrib.contenttypes.fields import ( GenericForeignKey, GenericRelation, ) from django.contrib.contenttypes.models import ContentType from django.db import models class P(models.Model): pass class R(models.Model): is_default = models.BooleanField(default=False) p = models.ForeignKey(P, m...
f402780df1f1ea95051389a2d5bbe5f93caae4e5d969293bc5fad2b9faf86499
import unittest import uuid from django.core.checks import Error, Warning as DjangoWarning from django.db import connection, models from django.test import ( SimpleTestCase, TestCase, skipIfDBFeature, skipUnlessDBFeature, ) from django.test.utils import isolate_apps, override_settings from django.utils.functional ...
3c7530dd4db91690de59fc555caf712ce9257c1a7a1cb69626db70a771cc1b46
from unittest import skipIf from django import forms from django.db import connection, models from django.test import SimpleTestCase, TestCase from .models import Post class TextFieldTests(TestCase): def test_max_length_passed_to_formfield(self): """ TextField passes its max_length attribute to...
9c8277fcb5059b52d6626bb5473f6c2cec26bad519d9dc537aea06284c0d07c0
import pickle from django import forms from django.core.exceptions import ValidationError from django.db import models from django.test import SimpleTestCase, TestCase from django.utils.functional import lazy from .models import ( Bar, Choiceful, Foo, RenamedField, VerboseNameField, Whiz, WhizDelayed, WhizIte...
a456426b1b007677ec15fd814add9e89f6666d0fef419cabd5d836bcc85d5670
import operator import uuid from unittest import mock, skipIf from django import forms from django.core import serializers from django.core.exceptions import ValidationError from django.core.serializers.json import DjangoJSONEncoder from django.db import ( DataError, IntegrityError, NotSupportedError, OperationalE...
349aea64b005b774a173115cecf1804e31db68d7b0ec249ba6699bde60b47a5a
from django import forms from django.core.exceptions import ValidationError from django.db import IntegrityError, models, transaction from django.test import SimpleTestCase, TestCase from .models import BooleanModel, FksToBooleans, NullBooleanModel class BooleanFieldTests(TestCase): def _test_get_prep_value(self...
b1193669f8aa88667bdd0a53079ba580c8ecebe5471924cae3092ced5ab6c95d
from unittest import skipIf from django.core.exceptions import ValidationError from django.db import connection, models from django.test import SimpleTestCase, TestCase from .models import Post class TestCharField(TestCase): def test_max_length_passed_to_formfield(self): """ CharField passes it...
8bafd891ded5dba47d3daf3b2269be88930e1d484ddea071dd4393dc217ab86d
import datetime import pickle import unittest import uuid from collections import namedtuple from copy import deepcopy from decimal import Decimal from unittest import mock from django.core.exceptions import FieldError from django.db import DatabaseError, NotSupportedError, connection from django.db.models import ( ...
a25dc81f4df2ac5f6f9cbb93bdeef876a3c4f87656f83852f607e0a4f7efe76c
from unittest import mock from django.contrib.contenttypes.models import ContentType from django.core.exceptions import ObjectDoesNotExist from django.db import connection from django.db.models import Prefetch, QuerySet, prefetch_related_objects from django.db.models.query import get_prefetcher from django.db.models.s...
2acb5903b88d72bb8773ab1803b234579b783c341ba91447754a0756e7a0b4cd
from unittest import mock, skipUnless from django.db import DatabaseError, connection from django.db.models import Index from django.test import TransactionTestCase, skipUnlessDBFeature from .models import ( Article, ArticleReporter, CheckConstraintModel, City, Comment, Country, District, Reporter, ) class ...
1f394c247bdc29920b33d2a13afcba7ba87fe54c840c2670151c4389156eaae3
import datetime import decimal import gettext as gettext_module import os import pickle import re import tempfile from contextlib import contextmanager from importlib import import_module from pathlib import Path from unittest import mock from asgiref.local import Local from django import forms from django.apps impor...
2f9f008b611c1f36de59957d59cb163e380de662bff3e6108fea72b190383a8a
import collections.abc from datetime import datetime from math import ceil from operator import attrgetter from django.core.exceptions import FieldError from django.db import connection, models from django.db.models import Exists, Max, OuterRef from django.db.models.functions import Substr from django.test import Test...
e6f1a1a3cf13a192933c635e6ed52fc14883ab36a003eed5daa6e297ddcdc8d0
import copy import json import os import pickle import unittest import uuid from django.core.exceptions import DisallowedRedirect from django.core.serializers.json import DjangoJSONEncoder from django.core.signals import request_finished from django.db import close_old_connections from django.http import ( BadHead...
8f761e51d4ca7f325c6d3bef8ac8b5a418957cd3aee1eae0a6c5c49925d20d4c
from django.contrib import admin from django.contrib.admin.options import ModelAdmin from django.contrib.auth.models import User from django.db.models import F from django.test import RequestFactory, TestCase from .models import ( Band, DynOrderingBandAdmin, Song, SongInlineDefaultOrdering, SongInlineNewOrderi...
2fbee52887db33073b11d4fa915c245eeb16dba6c743df19176936fad917ded0
from django.db import connection, transaction from django.test import TransactionTestCase, skipUnlessDBFeature from .models import Thing class ForcedError(Exception): pass class TestConnectionOnCommit(TransactionTestCase): """ Tests for transaction.on_commit(). Creation/checking of database object...
6728609b0d1e370495d8d96dd5d4ec947d6bfb67eb05c8e7570d0ae3eadf4654
from django.db.backends.mysql.client import DatabaseClient from django.test import SimpleTestCase class MySqlDbshellCommandTestCase(SimpleTestCase): def test_fails_with_keyerror_on_incomplete_config(self): with self.assertRaises(KeyError): self.get_command_line_arguments({}) def test_bas...
1c284a7dcd9a1fc263c0c37247c047219d1ad812424b83c997554cd5dd16d152
from .custom_permissions import CustomPermissionsUser from .custom_user import ( CustomUser, CustomUserWithoutIsActiveField, ExtensionUser, ) from .invalid_models import CustomUserNonUniqueUsername from .is_active import IsActiveTestUser1 from .minimal import MinimalUser from .no_password import NoPasswordUser from...
b629d3b26c5ad16e03c62533a80f5a8cd355944838069899b7e60b5462fba1bd
from django.contrib.auth.base_user import AbstractBaseUser from django.contrib.auth.models import BaseUserManager from django.db import models class CustomEmailFieldUserManager(BaseUserManager): def create_user(self, username, password, email): user = self.model(username=username) user.set_passwor...
529909c439266e83d9009229d870a0ff6a2b34f322f42dcdf93c64ee5e7bfb50
from django.core.management.base import BaseCommand class Command(BaseCommand): def handle(self, **options): self.stdout.write('Working...') self.stdout.flush() self.stdout.write('OK')
7b3fd4d41225877697cce4e7406f01bceaa3db0a6726297354e5ca4a706cba45
from django.core.management.base import BaseCommand class Command(BaseCommand): def add_arguments(self, parser): parser.add_argument( '--append_const', action='append_const', const=42, required=True, ) parser.add_argument('--const', action='s...
b1b671a9e0bc98f0d5b472f75ded8b5c6b68005df9db277df5fcbc27015a20a5
from django.core.management.base import BaseCommand class Command(BaseCommand): def add_arguments(self, parser): group = parser.add_mutually_exclusive_group(required=True) group.add_argument('--foo-id', type=int, nargs='?', default=None) group.add_argument('--foo-name', type=str, nargs='?...
02ab17e1d7a23004f3b3518e5e335a9a758089e2561be4e7d0e42b2e210cde3e
from django.db import migrations, models from ..fields import ( ArrayField, BigIntegerRangeField, CICharField, CIEmailField, CITextField, DateRangeField, DateTimeRangeField, DecimalRangeField, EnumField, HStoreField, IntegerRangeField, SearchVectorField, ) from ..models import TagField class Migration(mi...
2a279e3cf0891d8ce0645d907397b319409d539c6a69c414c4d7602cdc00ef77
import datetime from django import forms from django.forms import CheckboxSelectMultiple from django.test import override_settings from .base import WidgetTest class CheckboxSelectMultipleTest(WidgetTest): widget = CheckboxSelectMultiple def test_render_value(self): self.check_html(self.widget(choi...
a2a5600a4d4f7c0b4df8e908b22fc1b762dfe6f27e006aaec116d0bf45ab442d
import json import uuid from django.core.serializers.json import DjangoJSONEncoder from django.forms import ( CharField, Form, JSONField, Textarea, TextInput, ValidationError, ) from django.test import SimpleTestCase class JSONFieldTest(SimpleTestCase): def test_valid(self): field = JSONField() ...
9ec70d46c3855a5e2e217c435eabc96eb0a9bd9ebde7cfda1229ac9473078e67
import uuid from django.core.exceptions import ValidationError from django.forms import UUIDField from django.test import SimpleTestCase class UUIDFieldTest(SimpleTestCase): def test_uuidfield_1(self): field = UUIDField() value = field.clean('550e8400e29b41d4a716446655440000') self.asser...
9966f210aaf8c8b6382ff444bd71f81f13e3087ef6ab6b074a53f6f94ac8d995
from django.core.exceptions import ValidationError from django.db import models from django.forms import ChoiceField, Form from django.test import SimpleTestCase from . import FormFieldAssertionsMixin class ChoiceFieldTest(FormFieldAssertionsMixin, SimpleTestCase): def test_choicefield_1(self): f = Choi...
7808310bd3fbf33232551eb8268e8cecd4b7557883e0b1d70ad5bfc87622789c
from django.core.exceptions import ValidationError from django.forms import URLField from django.test import SimpleTestCase from . import FormFieldAssertionsMixin class URLFieldTest(FormFieldAssertionsMixin, SimpleTestCase): def test_urlfield_1(self): f = URLField() self.assertWidgetRendersTo(f,...
bfa286bb7f66012d116a8e0ab1272206113946fefafced9ee39eafb6bcedac76
from django.core.exceptions import ValidationError from django.forms import EmailField from django.test import SimpleTestCase from . import FormFieldAssertionsMixin class EmailFieldTest(FormFieldAssertionsMixin, SimpleTestCase): def test_emailfield_1(self): f = EmailField() self.assertWidgetRend...
ef99b4a1d0a6a25afe6d508fd5c4289435ff30f9025d85e6746845ef435e7caa
from django.forms import SlugField from django.test import SimpleTestCase class SlugFieldTest(SimpleTestCase): def test_slugfield_normalization(self): f = SlugField() self.assertEqual(f.clean(' aa-bb-cc '), 'aa-bb-cc') def test_slugfield_unicode_normalization(self): f = SlugFie...