hash
stringlengths
64
64
content
stringlengths
0
1.51M
fc6e2fac65a89dc26c389996f01170d5a0ae5d2a99b8c3671cc187f827debfb2
from functools import wraps from django.db import IntegrityError, connections, transaction from django.test import TestCase, ignore_warnings, skipUnlessDBFeature from django.test.testcases import TestData from django.utils.deprecation import RemovedInDjango41Warning from .models import Car, Person, PossessedCar cla...
8bdfe04aa3f5ef15fa584fc8a7f4924082f16507d2baa70dc25cf0060ea9b471
from django.test import SimpleTestCase from django.test.testcases import SerializeMixin class TestSerializeMixin(SimpleTestCase): def test_init_without_lockfile(self): msg = ( "ExampleTests.lockfile isn't set. Set it to a unique value in the " "base class." ) with s...
6fdc0c1db30f7e13f96e38aef662afa7ce640bf681af03298349920a7c1f94bc
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...
3e34c47faf083b072e11016748cca28cac59ffc5f80bab18d3c6b43be8976eca
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...
74f9f5a843197cb14820e248e097b5f7a046e92bc378a656cba715240a5568bb
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...
30e75b3709d3b3a524d71f37a5f52fcd1152bc08eb677548a813ae1aa997cb86
from django.contrib import admin from django.contrib.admin.actions import delete_selected from django.contrib.auth.models import User from django.test import SimpleTestCase, TestCase, override_settings from django.test.client import RequestFactory from django.urls import path, reverse from .models import Article site...
6a6d660e23ec6daea24d5a7bc15286f33242ee260914391b6cbaae1c97abcaf4
from django.contrib.admin.forms import AdminAuthenticationForm from django.contrib.admin.helpers import AdminForm from django.contrib.auth.models import User from django.test import SimpleTestCase, TestCase, override_settings from .admin import ArticleForm # To verify that the login form rejects inactive users, use ...
0a2ad1d7c49826fe894f0be871ef0d79cec1239c64f0a36ad44812bc8a857e29
from django.apps import apps from django.apps.registry import Apps from django.conf import settings from django.contrib.sites import models from django.contrib.sites.checks import check_site_id from django.contrib.sites.management import create_default_site from django.contrib.sites.middleware import CurrentSiteMiddlew...
272a168b29a8ec4538d6eb25bb07c98e18701428b632bf08c56302657962e904
from django.core.exceptions import FieldError from django.test import TestCase from .models import Article, Author class CustomColumnsTests(TestCase): @classmethod def setUpTestData(cls): cls.a1 = Author.objects.create(first_name="John", last_name="Smith") cls.a2 = Author.objects.create(firs...
526fe993ef6a759e442bb55ae659aa90a0dc660bad0159be054b8c2bb1773fc9
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...
80da95b4dd779e3aeb295da25269cc1d7817002dc742c2dc9fc8a99f816e01c4
import datetime import pickle from decimal import Decimal from operator import attrgetter from unittest import mock from django.contrib.contenttypes.models import ContentType from django.core.exceptions import FieldError from django.db import connection from django.db.models import ( Aggregate, Avg, Case, Count, D...
afea726b89324a3832ee981800233e5ca3194005dc138e9a67107415c2f9ca62
import datetime from django.core import signing from django.test import SimpleTestCase from django.test.utils import freeze_time from django.utils.crypto import InvalidAlgorithm class TestSigner(SimpleTestCase): def test_signature(self): "signature() method should generate a signature" signer = ...
22cec0afd258414b379eb719d5004253f4edfcbae9b5d88db78b0fed72ff1a68
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...
fec657e53a77627abb7c0ef3d6f4ae2c1e1150b8b2d929ef8e6ead0272ef1f20
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 ...
9f564f1f1a147c43f93e8557623b38ecaf3290a51fef4f3f5bd8171011de9a07
from django.db import IntegrityError from django.db.models import ProtectedError, Q, Sum from django.forms.models import modelform_factory from django.test import TestCase, skipIfDBFeature from .models import ( A, Address, B, Board, C, Cafe, CharLink, Company, Contact, Content, D, Developer, Guild, HasLinkThin...
1e0373a8a26c6c1e70a94de8f75198f692e33e38bb81318f453b0ff5e73a1c56
import decimal import enum import json import unittest import uuid from django import forms from django.core import checks, exceptions, serializers, validators from django.core.exceptions import FieldError from django.core.management import call_command from django.db import IntegrityError, connection, models from dja...
d1495db0a573f36c44d46cc08fd4801cf6920ba6b4348e4a988a9be68d13d2f7
from django.db.models import ( CharField, F, Func, IntegerField, OuterRef, Q, Subquery, Value, ) from django.db.models.fields.json import KeyTextTransform, KeyTransform from django.db.models.functions import Cast, Concat, Substr from django.test.utils import Approximate, ignore_warnings from django.utils import tim...
68a3ac871b64b410028fd1af7851d26df1e50372d16571f59eb0db7f691f5235
""" 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.db import connection from django.db.models import F, Value from django.test import modify_setting...
8085560283e6dddef2a18dc7a80e6cd6f98b375de98c21d35ae0f4e4b99ac02d
import unittest from unittest import mock from migrations.test_base import OperationTestBase from django.db import ( IntegrityError, NotSupportedError, connection, transaction, ) from django.db.migrations.state import ProjectState from django.db.models import CheckConstraint, Index, Q, UniqueConstraint from djang...
4ef3811cd50182ff8e70143e343facee4a85b111eb1ca1514bebb04da5e4a95e
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...
966738f530a41afc111b7edfac42db21565b6cdf39827b6643a7dc8f48608a96
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...
3cd374bee2c9ec3a4726ebb2361f4a2480321c27171d7c14682ed050a3744da7
import datetime from decimal import Decimal from django.core.exceptions import FieldDoesNotExist, FieldError from django.db.models import ( BooleanField, Case, CharField, Count, DateTimeField, DecimalField, Exists, ExpressionWrapper, F, FloatField, Func, IntegerField, Max, OuterRef, Q, Subquery, Sum, Value...
3e764900b33ff5cc9f2c7a2dd7a7a27494db818607ba917002db6fa2b56bc739
import re import types from datetime import datetime, timedelta from decimal import Decimal from unittest import TestCase, mock from django.core.exceptions import ValidationError from django.core.files.base import ContentFile from django.core.validators import ( BaseValidator, DecimalValidator, EmailValidator, Fil...
b3d7b0f358012809025f7cfeb5cd967ac6d8f529232bc9c5ce1e8275e7cc230c
from django import forms from django.core.exceptions import ImproperlyConfigured from django.test import SimpleTestCase, TestCase, override_settings from django.test.client import RequestFactory from django.urls import reverse from django.views.generic.base import View from django.views.generic.edit import CreateView, ...
8682ffef9d8e5dd7c3edbd004ede4bcc966fce93cb7b0bf84097e77405772340
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 = [ ...
91b6c77ca4b315b5a31b71715187b09a6456aec4e8bfac4082438c65e21921b8
from django import forms from .models import Author class AuthorForm(forms.ModelForm): name = forms.CharField() slug = forms.SlugField() class Meta: model = Author fields = ['name', 'slug'] class ContactForm(forms.Form): name = forms.CharField() message = forms.CharField(widget...
e8e3d5be72514dad758a69a473963cbaab44c3e2a24696b928ec7407a6d89076
from django.contrib.auth.decorators import login_required from django.core.paginator import Paginator from django.urls import reverse, reverse_lazy from django.utils.decorators import method_decorator from django.views import generic from .forms import AuthorForm, ConfirmDeleteForm, ContactForm from .models import Art...
eb8ad84ee8b7ae70ca2f3987dd905151d79ad4a75ad9233f88b681c2e563e7a6
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...
afe2d806742294992dd77f578f6495bc94f183b8975f99d2d0d66670020ca365
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...
1d63c3e33ef8d8783475efd18fd6b7d1f88c6417ac46d6af59ca592f9a119d72
import asyncio import sys import threading from pathlib import Path from unittest import skipIf from asgiref.testing import ApplicationCommunicator from django.contrib.staticfiles.handlers import ASGIStaticFilesHandler from django.core.asgi import get_asgi_application from django.core.signals import request_finished,...
e0cf5eeba6437d740f15e85409659840ffad7fbcd2ca5590e6d591aa7374fe7b
import threading from django.http import FileResponse, HttpResponse from django.urls import path def hello(request): name = request.GET.get('name') or 'World' return HttpResponse('Hello %s!' % name) def hello_meta(request): return HttpResponse( 'From %s' % request.META.get('HTTP_REFERER') or ''...
a90afdca113c26c941c66320bc5fbd39463697ee4c98a175a4f24087be998823
import binascii import json import random from django.conf import settings from django.contrib.messages import constants from django.contrib.messages.storage.base import Message from django.contrib.messages.storage.cookie import ( CookieStorage, MessageDecoder, MessageEncoder, ) from django.core.signing import b64...
22a374c886e7a777ebca7e39e5273d883f0240fa8438870ecc3c4c5037b4dd8e
from django.db import models class SomeObject(models.Model): name = models.CharField(max_length=255)
acd42717486b77dc37d9344e097df05f859c20cd1328cfa095ecfab64371cfa7
from django.core.signing import b64_decode from django.test import TestCase, override_settings from django.urls import reverse from .models import SomeObject from .urls import ContactFormViewWithMsg, DeleteFormViewWithMsg @override_settings(ROOT_URLCONF='messages_tests.urls') class SuccessMessageMixinTests(TestCase)...
06afeb89b0cdb6591def63bf0cebef84747e4616f333fbc71cc783689c46fe69
from django.contrib.messages import constants, get_level, set_level, utils from django.contrib.messages.api import MessageFailure from django.contrib.messages.constants import DEFAULT_LEVELS from django.contrib.messages.storage import base, default_storage from django.contrib.messages.storage.base import Message from d...
35b45d1d38c897feb869f02b5f68ea5162cdae665984b4c05457e08c30156c11
from django import forms from django.contrib import messages from django.contrib.messages.views import SuccessMessageMixin from django.http import HttpResponse, HttpResponseRedirect from django.template import engines from django.template.response import TemplateResponse from django.urls import path, re_path, reverse f...
e60727d2111bc5c37cd2e0da98c81d87f0cb7f266baf0d43c3edabeaef93f944
""" Unit tests for reverse URL lookups. """ import pickle import sys import threading from admin_scripts.tests import AdminScriptTestCase from django.conf import settings from django.contrib.auth.models import User from django.core.exceptions import ImproperlyConfigured, ViewDoesNotExist from django.http import ( ...
11ca1efb58420a8ef430f3c3143f194684107578761e5b5e3f68d4e625389628
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...
e8f8f146c5a00416d9949ee10776a88aa3281fa9fbba25dba75215b827c6423b
import os from datetime import datetime, timedelta from django.conf import settings from django.contrib.staticfiles.storage import ManifestStaticFilesStorage from django.core.files import storage from django.utils import timezone class DummyStorage(storage.Storage): """ A storage class that implements get_mo...
0f0d266aad6f4a8ee60779fc4a46cccca182a0ff678009e50858d8034cc8ad66
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): ...
03d277ee194f69797ce094ebb47b026fb2ca362e48295f308e496e13b8ddff0a
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...
a8938cd58c81308be483afa7c2ede6120ee95a6d0c7ef74a572c6e648b14b20a
from django.apps import apps from django.db import models from django.test import SimpleTestCase, override_settings from django.test.utils import isolate_lru_cache class FieldDeconstructionTests(SimpleTestCase): """ Tests the deconstruct() method on all core fields. """ def test_name(self): "...
c1c74f77a7e50c934c5e7f9259378986f3a9079816da985f39b2d680f6cb5ae5
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...
041cb50dc497ea31a90f2c0af209dd084519b4b1a686f0c59ecc7d4c27a0c379
""" Tests for the update() queryset method that allows in-place, multi-object updates. """ from django.db import models class DataPoint(models.Model): name = models.CharField(max_length=20) value = models.CharField(max_length=20) another_value = models.CharField(max_length=20, blank=True) class Related...
bfaa4cdf513ca41093f6b9cd85a418187438aed34937f27a064141deec77affc
import sys import threading import time from unittest import skipIf, skipUnless from django.db import ( DatabaseError, Error, IntegrityError, OperationalError, connection, transaction, ) from django.test import ( TestCase, TransactionTestCase, skipIfDBFeature, skipUnlessDBFeature, ) from .models import Re...
646f49dba387fea1aa9800a4eab7428d9aac178469a0e1cee28f964f3536d019
# 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 import warnings from pathlib import Path from unittest import mock, skipIf from ...
d9ff22bd43d25c4c13f9ea5e170adb742402f486299eb208d0dbef9e6839c72b
from datetime import date, datetime, time, tzinfo from django.test import SimpleTestCase, override_settings from django.test.utils import TZ_SUPPORT, requires_tz_support from django.utils import dateformat, translation from django.utils.dateformat import format from django.utils.timezone import ( get_default_timez...
1a3f681e8b27c408244a6c9c10b30dfe7bf8c2afad16016772a288203eae6c7e
import unittest from datetime import date, datetime, time, timedelta from django.utils.dateparse import ( parse_date, parse_datetime, parse_duration, parse_time, ) from django.utils.timezone import get_fixed_timezone class DateParseTests(unittest.TestCase): def test_parse_date(self): # Valid inputs ...
1bb9144b003ee80c3b44cb825f86f3aee3a109a6dc1f02d68cff21f8094d8abb
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...
c7db223a2668792109398e28e3cd290796faf7aa8c2a03e99089ca8a005252af
import copy import unittest from django.utils.tree import Node class NodeTests(unittest.TestCase): def setUp(self): self.node1_children = [('a', 1), ('b', 2)] self.node1 = Node(self.node1_children) self.node2 = Node() def test_str(self): self.assertEqual(str(self.node1), "(DE...
77cd574e4e4cfe43dec9d91ea244b52ffea4d2eb751c71eff42241cf24669fc2
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...
cd48c4b4a1caaf94e2407ef0a4f3e8e5d6bcdf23d1b132e1567d18e4ff93dc33
from datetime import date as original_date, datetime as original_datetime from django.test import SimpleTestCase, ignore_warnings from django.utils.deprecation import RemovedInDjango50Warning with ignore_warnings(category=RemovedInDjango50Warning): from django.utils.datetime_safe import date, datetime class Dat...
96123eb4605d9a6d62967814c4ec4fa43b45ca6cbfd0d8fa0ac9a4b6560efd88
import platform import unittest from datetime import datetime, timezone from unittest import mock from django.test import SimpleTestCase from django.utils.datastructures import MultiValueDict from django.utils.http import ( base36_to_int, escape_leading_slashes, http_date, int_to_base36, is_same_domain, parse_...
cf5d1513fcf218c3e4ef4b6560edc89543f8d79331e06a57b2c1c23f24c16bf5
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...
a9f28fc8f21c6bca35accbb808a8563917284aa790b7c899dac8b8e1e61e6a42
from unittest import TestCase from django.test import ignore_warnings from django.utils.deprecation import RemovedInDjango50Warning with ignore_warnings(category=RemovedInDjango50Warning): from django.utils.baseconv import ( BaseConverter, base2, base16, base36, base56, base62, base64, ) # RemovedIn...
3ecc057762354595b9c8e3afe598d5e12bb25d3d993b6c4cbc2276b594d386aa
import json import sys from django.core.exceptions import SuspiciousFileOperation from django.test import SimpleTestCase from django.utils import text from django.utils.functional import lazystr from django.utils.text import format_lazy from django.utils.translation import gettext_lazy, override IS_WIDE_BUILD = (len(...
02fa97c589f06005933b2821c41cac4ea0bdd2c60e70248c2036289617a9f9bf
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 ...
d07e105f2f3ab2761e2a4add33a0a0a04701b9d9f901b36a118b6118d7e2b4fe
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....
1e0bb68d86c84cd4c373b5b00a2389d05885ed8f271ccf714646eafb98cee1ee
""" Tests for django test runner """ import collections.abc 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 ...
bcb5e84c857290673b2c2cb89a84ef1aff30ab5b87c4402c59ca80a5ed81c10c
from django.test.runner import DiscoverRunner class CustomOptionsTestRunner(DiscoverRunner): def __init__(self, verbosity=1, interactive=True, failfast=True, option_a=None, option_b=None, option_c=None, **kwargs): super().__init__(verbosity=verbosity, interactive=interactive, failfast=fa...
3ab8caf09cb0019f62d405546c9f9012650e806da13b7b51599bd4ef931c68ef
from unittest import mock from django.test import SimpleTestCase from django.test.runner import Shuffler class ShufflerTests(SimpleTestCase): def test_hash_text(self): actual = Shuffler._hash_text('abcd') self.assertEqual(actual, 'e2fc714c4727ee9395f324cd2e7f331f') def test_hash_text_hash_a...
90ede07171d6158f1692be521ee28a68aaf6ec007155425c7182928e472c8cf4
import logging import multiprocessing import os import unittest.loader from argparse import ArgumentParser from contextlib import contextmanager from importlib import import_module from unittest import TestSuite, TextTestRunner, defaultTestLoader, mock from django.db import connections from django.test import SimpleTe...
597ff179a86061b55fb5bce4e61f49eca18b0f0007a8eb869328b0706b11a2fc
from unittest import mock from django.db import transaction from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature from .models import ( Article, InheritedArticleA, InheritedArticleB, Publication, User, ) class ManyToManyTests(TestCase): @classmethod def setUpTestData(cls): # Cr...
ba009e2d7191f07be297986e5245921e0342e4363509f0bef678fc30d7a87ddf
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.multipartparser import...
210639a09cad418d5e8c106e37ec4771f01aa00172b4044b4fb6c51122414d3b
from django.db.models import BooleanField, Exists, F, OuterRef, Q from django.db.models.expressions import RawSQL 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.ass...
c75d459da1e0cbcd1f95f9443f28183b56014708c4b5789d36c1a059425d87fc
import datetime import pickle import sys import unittest from operator import attrgetter from threading import Lock from django.core.exceptions import EmptyResultSet, FieldError from django.db import DEFAULT_DB_ALIAS, connection from django.db.models import Count, Exists, F, Max, OuterRef, Q from django.db.models.expr...
f3647e9167f1bed90ac3ec25e288248a49e3284ce99a9508c589cb36659286ce
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 Celebrity, Number, Res...
76a092141099a88398aa93249dfcdf2d1afc4da69ef314222d85b7c967684dbd
import json import unittest import xml.etree.ElementTree 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 @skipUnlessD...
b0544e928d50f0c66d9cb157cc543bd3d7f0bbd9fabca20f083eccdce9a366b8
import datetime from django.core.exceptions import FieldDoesNotExist from django.db.models import F from django.db.models.functions import Lower from django.test import TestCase, skipUnlessDBFeature from .models import ( Article, CustomDbColumn, CustomPk, Detail, Individual, JSONFieldNullable, Member, Note, N...
46eed24a2446f8b626c0bd8215e212f6b5b7b34997ddd7f9b5ec68a1efbef168
""" 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...
625331fd69f37bc09d9eba264ebcf2c2403b63b3d8c998857f3424e7b03ba350
import sys from django.contrib.auth.models import Group from django.template import ( Context, Engine, TemplateDoesNotExist, TemplateSyntaxError, ) from django.template.base import UNKNOWN_SOURCE from django.test import SimpleTestCase, override_settings from django.urls import NoReverseMatch from django.utils impo...
c8612c54d4adf202fe92d3e811a3c37a25c1153cc6ae3beb431b7395ae4576ea
from pathlib import Path from unittest import mock from django.template import autoreload from django.test import SimpleTestCase, override_settings from django.test.utils import require_jinja2 ROOT = Path(__file__).parent.absolute() EXTRA_TEMPLATES_DIR = ROOT / "templates_extra" @override_settings( INSTALLED_AP...
5515e2fcef0f3ea3a7e7f07f8be40cc1d2367649ee1cbce32c0492137e606f33
import os from django.core.exceptions import ImproperlyConfigured from django.template import Context from django.template.engine import Engine from django.test import SimpleTestCase, override_settings from .utils import ROOT, TEMPLATE_DIR OTHER_DIR = os.path.join(ROOT, 'other_templates') class EngineTest(SimpleTe...
fd95c2ad1f5a58d3bd549c5178221749151dd899e68a1898a59cc75bcd856d17
from datetime import date, datetime, timedelta from operator import attrgetter from django.db import IntegrityError from django.test import TestCase from .models import ( CustomMembership, Employee, Event, Friendship, Group, Ingredient, Invitation, Membership, Person, PersonChild, PersonSelfRefM2M, Recipe, ...
8b7e0f9a6f14462e22eba194cc18d99065b405cd67ce07fe707532085d544ffd
from datetime import datetime from django.db import models # M2M described on one of the models class Person(models.Model): name = models.CharField(max_length=128) class Meta: ordering = ('name',) class PersonChild(Person): pass class Group(models.Model): name = models.CharField(max_leng...
42749445c75be645e03f5b91321ce7e56e75610142490a3ddb896fff953afea8
from django.db.models.utils import create_namedtuple_class from django.test import SimpleTestCase class NamedTupleClassTests(SimpleTestCase): def test_immutability(self): row_class = create_namedtuple_class('field1', 'field2') row = row_class('value1', 'value2') with self.assertRaises(Attr...
eceb1277e640f8e1a0b9d53028a1fb2c9d2b38ab087d99d8c731402750b3ec36
from datetime import datetime from django.contrib.sitemaps import GenericSitemap from django.test import ignore_warnings, override_settings from django.utils.deprecation import RemovedInDjango50Warning from .base import SitemapTestsBase from .models import TestModel @override_settings(ABSOLUTE_URL_OVERRIDES={}) cla...
5071f7551f7c22400c637bf1fa06fc278f73365d62a74560089a5fb9f4eabcec
import os from datetime import date from django.contrib.sitemaps import Sitemap from django.contrib.sites.models import Site from django.core.exceptions import ImproperlyConfigured from django.test import ignore_warnings, modify_settings, override_settings from django.utils import translation from django.utils.depreca...
7a5975abc200b16a36a9e97c78a39f31f901292b6ff1c1edb80cad820d5887e0
import datetime from django.db import connection, models, transaction from django.db.models import Exists, OuterRef from django.test import ( SimpleTestCase, TestCase, TransactionTestCase, skipUnlessDBFeature, ) from .models import ( Award, AwardNote, Book, Child, Contact, Eaten, Email, File, Food, FooFile, ...
e36dda25f1aaa135b5e0ebdef2dc832ac838c4ec33e6d6efc09698455414d7af
from django.contrib.contenttypes.fields import ( GenericForeignKey, GenericRelation, ) from django.contrib.contenttypes.models import ContentType from django.db import models class Award(models.Model): name = models.CharField(max_length=25) object_id = models.PositiveIntegerField() content_type = mode...
f2f425cf6e1afb5ea9c4113f2aae97122629e2b514a535a1bb523c64ff59b9db
""" 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...
9ecc9c2ea52a2dac191f93743d469198f929cd3606298d1140fdab1e971c3f4b
from django.contrib.auth import views as auth_views from django.urls import path from django.views.generic import RedirectView from . import views urlpatterns = [ path('upload_view/', views.upload_view, name='upload_view'), path('get_view/', views.get_view, name='get_view'), path('post_view/', views.post_...
c6971f23189de58c160a8f0ec33a969e2df55f34313c1fc0e280bce9bddd7b59
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 ...
10af424550a68bdf00d5fb2f69b1f3b92b2abeecef7de9aae31db192faf931bb
"""Tests related to django.db.backends that haven't been organized.""" import datetime import threading import unittest import warnings from unittest import mock from django.core.management.color import no_style from django.db import ( DEFAULT_DB_ALIAS, DatabaseError, IntegrityError, connection, connections, r...
b380b580cc36ca2febd3beb78b5e520b0825f3f3062ba41f1ab160fc0888f7b5
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...
e2b27a7472233ca71b9311269ac73303d16687c7b233f32516bcd9812487f4da
from django.apps.registry import Apps from django.db import models # Because we want to test creation and deletion of these as separate things, # these models are all inserted into a separate Apps so the main test # runner doesn't migrate them. new_apps = Apps() class Author(models.Model): name = models.CharFie...
2b3903c97b89580e839de813ceafc61443d6838b35811daec61ee0d4c72b595a
from functools import partial from django.db import models from django.db.models.fields.related import ( RECURSIVE_RELATIONSHIP_CONSTANT, ManyToManyDescriptor, RelatedField, create_many_to_many_intermediary_model, ) class CustomManyToManyField(RelatedField): """ Ticket #24104 - Need to have a custom ...
c0a710c26e04e3a18a495d718702da91ebede58d37fb220c786355e85ca3bffd
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...
be13d696f4fa892b9b94e5959bcf376bdc94263a8745bec14a40c654b540b1dd
from unittest import mock from django.core import checks from django.core.checks import Error, Warning from django.db import models from django.test import SimpleTestCase, TestCase, skipUnlessDBFeature from django.test.utils import ( isolate_apps, modify_settings, override_settings, override_system_checks, ) cla...
f423957ad83f5099794068a1c9748488ce46fefd3ee0385c86d5a58f5767e0b9
import pathlib from django.core.checks import Warning from django.core.checks.caches import ( E001, check_cache_location_not_exposed, check_default_cache_is_configured, check_file_based_cache_is_absolute, ) from django.test import SimpleTestCase from django.test.utils import override_settings class CheckCach...
62df66ef46af991867a8f0195043d0505c7f5f7373eddf7b6f2eefa97784fa4f
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...
ca1d3e3c43fd39a415f8b5e2a875ecc98a2d135e7ba2ca872df870b51f609f7d
from django.conf import settings from django.core.checks.messages import Error, Warning from django.core.checks.urls import ( E006, check_url_config, check_url_namespaces_unique, check_url_settings, get_warning_for_invalid_pattern, ) from django.test import SimpleTestCase from django.test.utils import override_...
c2d51edb4627a4ade7d0cfe0555ec0428f7a5fa34aa04fa25811e6f07dbd9770
from django.contrib.admin.utils import quote from django.contrib.admin.views.main import IS_POPUP_VAR from django.contrib.auth.models import User from django.template.response import TemplateResponse from django.test import TestCase, override_settings from django.urls import reverse from .models import Action, Car, Pe...
71f77b0d054ddd329dafa3054741be5fc665060402df22b7a8bb577850df0fbc
""" 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...
7a3e8db97a6a257a20484c6b731b6054e166400304afa94b0696fd8350807394
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 ....
2a26c78a66c8c5821265c637fada705dd45c78dc56a94bf5a0093c36bd2b876c
import base64 import hashlib import os import shutil import sys import tempfile as sys_tempfile import unittest from io import BytesIO, StringIO from unittest import mock from urllib.parse import quote from django.core.exceptions import SuspiciousFileOperation from django.core.files import temp as tempfile from django...
8b3ffbdaa46c6f9471ccd64b712e820066cf8a816f459c948510aacc92a990b2
from django.db import connection from django.db.models import CharField, Max from django.db.models.functions import Lower from django.test import TestCase, skipUnlessDBFeature from django.test.utils import register_lookup from .models import Celebrity, Fan, Staff, StaffTag, Tag @skipUnlessDBFeature('can_distinct_on_...
f466bde9c5bb4b231c62833d4aa5aef5282d64d188e25d43848dde105e7ce7a9
import datetime import pytz from django.test import TestCase, override_settings from django.utils import timezone from .models import Article, Category, Comment class DateTimesTests(TestCase): def test_related_model_traverse(self): a1 = Article.objects.create( title="First one", ...
fd12baa1a4234ddc45363a561d8fdd38d24d67dbc36ab88de43f5565ab0e1639
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...
fdf534b4cb3f2d8f24ecb26035b10bb32a61f1be2f4f2fcb747f5e69d67f6109
import unittest from django.core.checks import Error, Warning from django.core.checks.model_checks import _check_lazy_references from django.db import connection, connections, models from django.db.models.functions import Abs, Lower, Round from django.db.models.signals import post_init from django.test import SimpleTe...