hash
stringlengths
64
64
content
stringlengths
0
1.51M
c3b7c48ee72584a4a44d1cd950d2e230dac4ac20899f24994dac9792dea482a2
import copy from django.contrib.gis.db.models.fields import GeometryField from django.contrib.gis.db.models.sql import AreaField, DistanceField from django.test import SimpleTestCase class FieldsTests(SimpleTestCase): def test_area_field_deepcopy(self): field = AreaField(None) self.assertEqual(c...
5e19110375213633dcf29f3c68dea1153ba296396a97179918e7e1b590634ee1
import ctypes from unittest import mock from django.contrib.gis.ptr import CPointerBase from django.test import SimpleTestCase class CPointerBaseTests(SimpleTestCase): def test(self): destructor_mock = mock.Mock() class NullPointerException(Exception): pass class FakeGeom1(...
e497ea9d05da165c1f9428eef6a21fd43ff7ba0fcdb4a4eb0bddbf8bda5a4cbb
import re from django.contrib.gis import forms from django.contrib.gis.forms import BaseGeometryWidget, OpenLayersWidget from django.contrib.gis.geos import GEOSGeometry from django.forms import ValidationError from django.test import SimpleTestCase, override_settings from django.utils.html import escape class Geome...
1cc95dd53ea2c5816fa3adf46d1e09bb8bba9731efd3bd380a6dffe0e01c4c36
from math import ceil from django.db import IntegrityError, connection, models 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 .models import ( MR, A, Avatar, Base, Child,...
42f9d851056b0543a0296a1b8b44a71119d675afa8278db5d50561f1b6d7abb4
from django.db import models class R(models.Model): is_default = models.BooleanField(default=False) def __str__(self): return "%s" % self.pk def get_default_r(): return R.objects.get_or_create(is_default=True)[0].pk class S(models.Model): r = models.ForeignKey(R, models.CASCADE) class T...
bdde97a1f2631cf73afbf2779d5a091afadd2bc5b3a9f7c42d9532341dbd1719
from django.urls import path from .admin import site urlpatterns = [ path('admin/', site.urls), ]
02f4a6f65c8a0467956a759d33d2a7e3de6800cd8035bf4208ee9b464a45dd19
from unittest import mock from django.core.checks import Error, Warning as DjangoWarning from django.db import connection, models from django.db.models.fields.related import ForeignObject from django.test.testcases import SimpleTestCase from django.test.utils import isolate_apps, override_settings @isolate_apps('inv...
169bb037fbdf336b32165edfc5959e5757d596d78fb1e52017ad0c24c8b8b967
import unittest from django.conf import settings from django.core.checks import Error, Warning from django.core.checks.model_checks import _check_lazy_references from django.core.exceptions import ImproperlyConfigured from django.db import connection, connections, models from django.db.models.functions import Lower fr...
577f0920a260b57460e44bae6ad259d21070dcaebe906255edf9a4b6675895f3
import unittest from django.core.checks import Error, Warning as DjangoWarning from django.db import connection, models from django.test import SimpleTestCase, TestCase, skipIfDBFeature from django.test.utils import isolate_apps, override_settings from django.utils.functional import lazy from django.utils.timezone imp...
ba23c821d9b3656d91f86de18d12ea7490c8801fa05220ad71350d743149f496
from datetime import datetime from operator import attrgetter from django.db.models import Q from django.test import TestCase from .models import Article class OrLookupsTests(TestCase): @classmethod def setUpTestData(cls): cls.a1 = Article.objects.create( headline='Hello', pub_date=date...
c6895de15cc5b5009baf133f9da6cee5d531dbd076f2991f76d645ecd7848929
import asyncore import base64 import mimetypes import os import shutil import smtpd import sys import tempfile import threading from email import charset, message_from_binary_file, message_from_bytes from email.header import Header from email.mime.text import MIMEText from email.utils import parseaddr from io import St...
d42c1c5362c80eebe654c4463c1d05d869865a917423e5d8dace35c78c421e2f
from django.test import TestCase from .models import Category, Person class ManyToOneRecursiveTests(TestCase): @classmethod def setUpTestData(cls): cls.r = Category.objects.create(id=None, name='Root category', parent=None) cls.c = Category.objects.create(id=None, name='Child category', pare...
ffb621394a10b33e5e3b1f8911a825af790028e101e1b366e557085c28d3530f
import unittest from django.core import validators from django.core.exceptions import ValidationError from django.db import IntegrityError, connection, models from django.test import SimpleTestCase, TestCase from .models import ( BigIntegerModel, IntegerModel, PositiveIntegerModel, PositiveSmallIntegerModel, ...
0a42d725a415e32905d73bad3a66294692458a8aaa616b1fd03a1984b3cd0b5a
import datetime import json from django import forms from django.core import exceptions, serializers from django.db import models from django.test import SimpleTestCase, TestCase from .models import DurationModel, NullDurationModel class TestSaveLoad(TestCase): def test_simple_roundtrip(self): duration...
8be8e792c3159a4db1e90c3430a238766f27d8a7373b09922baad127f6e03fed
from decimal import Decimal from django.apps import apps from django.core import checks from django.db import models from django.test import TestCase, skipIfDBFeature from django.test.utils import isolate_apps from .models import Bar, FkToChar, Foo, PrimaryKeyCharModel class ForeignKeyTests(TestCase): def test...
f5512dea4730fee68a0726e77fd3db96ba8d6483df8a439f96149ed64d39b146
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...
91044d3419618c44a40929559fad9db83c37badcfdf9d9fed979d77b3548cb68
import os import tempfile import uuid from django.contrib.contenttypes.fields import ( GenericForeignKey, GenericRelation, ) from django.contrib.contenttypes.models import ContentType from django.core.files.storage import FileSystemStorage from django.db import models from django.db.models.fields.files import Imag...
3d52026b67214a088a32be291bfa287ae8abacdd0d028d3abe9fdd7f6af71557
from django import test from django.contrib.contenttypes.fields import ( GenericForeignKey, GenericRelation, ) from django.db import models from django.db.models.fields.related import ( ForeignKey, ForeignObject, ForeignObjectRel, ManyToManyField, ManyToOneRel, OneToOneField, ) from .models import AllField...
66826871c7c4d1c6bdedfc642ae18faa8550dbb337c0df5d9fcc46dcedf1cb42
import json import uuid from django.core import exceptions, serializers from django.db import IntegrityError, models from django.test import ( SimpleTestCase, TestCase, TransactionTestCase, skipUnlessDBFeature, ) from .models import ( NullableUUIDModel, PrimaryKeyUUIDModel, RelatedToUUIDModel, UUIDGrandchild,...
ed93b49a46def0cc9c31e684bfc1e4307753815410855bab1d7cc3c486db8aea
from django.core.exceptions import ValidationError from django.db import models from django.test import TestCase from .models import DataModel class BinaryFieldTests(TestCase): binary_data = b'\x00\x46\xFE' def test_set_and_retrieve(self): data_set = (self.binary_data, bytearray(self.binary_data), m...
805a530e676cf0ba4177153eb82b4635e7132a7a82af57d4e0245ef44dd03724
import os from django.db.models import FilePathField from django.test import SimpleTestCase class FilePathFieldTests(SimpleTestCase): def test_path(self): path = os.path.dirname(__file__) field = FilePathField(path=path) self.assertEqual(field.path, path) self.assertEqual(field.fo...
1da60f5e17c32e736f25f59071f3d07207b12c3737cdba244490041dcc033cda
from django.core.exceptions import ValidationError from django.db import IntegrityError, connection, models from django.db.models.constraints import BaseConstraint from django.test import SimpleTestCase, TestCase, skipUnlessDBFeature from .models import Product def get_constraints(table): with connection.cursor(...
6f80527cd2dea3ef8553b31c18038159b02bc172f15d68b7c892bef420a92d58
from django.db import models class Product(models.Model): name = models.CharField(max_length=255) color = models.CharField(max_length=32, null=True) price = models.IntegerField(null=True) discounted_price = models.IntegerField(null=True) class Meta: constraints = [ models.Chec...
42781860df60b1a12e53153fd49f3f9beb32c79acc9a4b31982e4320a449fd59
import warnings from datetime import datetime from django.core.paginator import ( EmptyPage, InvalidPage, PageNotAnInteger, Paginator, QuerySetPaginator, UnorderedObjectListWarning, ) from django.test import SimpleTestCase, TestCase from django.utils.deprecation import RemovedInDjango31Warning from .custom im...
e311c3a9a74cba693dfae75aba7dec334d030a04ce5323eeafb5d27c7ae1ff42
from django import forms from django.contrib import admin from django.contrib.admin import AdminSite from django.contrib.auth.backends import ModelBackend from django.contrib.auth.middleware import AuthenticationMiddleware from django.contrib.contenttypes.admin import GenericStackedInline from django.contrib.messages.m...
bb02e0cb3d7e13d518e626a006bbac91c45924d36fc270f6d3cf2f6067150609
from django.core import management from django.core.management import CommandError from django.test import TestCase from .models import Article class SampleTestCase(TestCase): fixtures = ['fixture1.json', 'fixture2.json'] def test_class_fixtures(self): "Test cases can load fixture objects into model...
fd81fd7f89a2e7afbaa2ce8b58ab23189076eec59ef207508eb6c1acc33c79db
import datetime import pickle import unittest import uuid from copy import deepcopy from django.core.exceptions import FieldError from django.db import DatabaseError, connection, models from django.db.models import CharField, Q, TimeField, UUIDField from django.db.models.aggregates import ( Avg, Count, Max, Min, S...
298736a455ae15ae60a451f3865cc3e86ed93edf0389b5797995f83b83e39da7
""" Tests for F() query expression syntax. """ import uuid from django.db import models class Employee(models.Model): firstname = models.CharField(max_length=50) lastname = models.CharField(max_length=50) salary = models.IntegerField(blank=True, null=True) def __str__(self): return '%s %s' %...
c10561d0331c0daf37cc282d901447cde2dfc8f4caf69a39abe29ff4a01faed2
from django.db.models import Count, Func from django.test import SimpleTestCase from django.utils.deprecation import RemovedInDjango40Warning from .models import Employee class MissingAliasFunc(Func): template = '1' def get_group_by_cols(self): return [] class GetGroupByColsTest(SimpleTestCase): ...
f6e205f3575ae6129b44de2393d3df0d08da314e75c9760314f3f2013e325291
import datetime from operator import attrgetter from django.core.exceptions import FieldError from django.db import models from django.db.models.fields.related import ForeignObject from django.test import SimpleTestCase, TestCase, skipUnlessDBFeature from django.test.utils import isolate_apps from django.utils import ...
56353dda73cbb9165cc538b4084c582914c5542a628b32bfdb67f59c9ab1f3de
from django.test import TestCase from .models import SlugPage class RestrictedConditionsTests(TestCase): @classmethod def setUpTestData(cls): slugs = [ 'a', 'a/a', 'a/b', 'a/b/a', 'x', 'x/y/z', ] SlugPage.objects....
1cedb2b77223cbac5b0727855b5505d58b07af36d1270352f914021d2c2857db
import datetime import re import sys from contextlib import contextmanager from unittest import SkipTest, skipIf from xml.dom.minidom import parseString import pytz from django.contrib.auth.models import User from django.core import serializers from django.core.exceptions import ImproperlyConfigured from django.db im...
f74dbd566eca95e9b24f75d70fd153ed0b42d518dd0143a882420c59d9751abb
from django.urls import path from . import admin as tz_admin # NOQA: register tz_admin urlpatterns = [ path('admin/', tz_admin.site.urls), ]
a150164ddfe3a74680bfa5082ce21dfd609f403c1b2ade375bde7810fb4bd575
from django.apps import apps from django.conf import settings from django.db import connection from django.test import ( TransactionTestCase, skipIfDBFeature, skipUnlessDBFeature, ) from .models.tablespaces import ( Article, ArticleRef, Authors, Reviewers, Scientist, ScientistRef, ) def sql_for_table(model):...
551437ddd8c1ff83198e47f504ca7a7342143a8bed85a3bd5ad7da620e929cf0
import datetime from unittest import skipUnless from django.core.exceptions import FieldError from django.db import connection from django.test import TestCase, override_settings from .models import Article, Category, Comment class DatesTests(TestCase): def test_related_model_traverse(self): a1 = Articl...
def261de97af63002114b46795d946e5251e0d9d4076afe1a1e4ad41fe61bad2
from django.conf import settings from django.contrib.sites.managers import CurrentSiteManager from django.contrib.sites.models import Site from django.core import checks from django.db import models from django.test import SimpleTestCase, TestCase from django.test.utils import isolate_apps from .models import CustomAr...
314ddfff71792a091fb258adb6c27741f7e19613cc94d6af470e23529798c8e3
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 from django.db.models.query import get_prefetcher, prefetch_related_objects from django.test import TestCase, override_setting...
c7234963f13f74940d546576ae36b843ad3790d016e04bee88793c25a86b8f9e
import uuid from django.contrib.contenttypes.fields import ( GenericForeignKey, GenericRelation, ) from django.contrib.contenttypes.models import ContentType from django.db import models from django.db.models.query import ModelIterable, QuerySet from django.utils.functional import cached_property class Author(mo...
3942e8f8f58485e694c151ed53da0027c43363a16699f9980c04ca95b7099ea3
from django.db.models import CharField, Value as V from django.db.models.functions import Coalesce, Length, Upper from django.test import TestCase from django.test.utils import register_lookup from .models import Author class UpperBilateral(Upper): bilateral = True class FunctionTests(TestCase): def test_...
93372bca61a4522a4df7e54ac333864aa47161c6bc9e492ad4006783f994f93e
""" Tests for built in Function expressions. """ from django.db import models class Author(models.Model): name = models.CharField(max_length=50) alias = models.CharField(max_length=50, null=True, blank=True) goes_by = models.CharField(max_length=50, null=True, blank=True) age = models.PositiveSmallInt...
c15bf769cfe190a8355e03d2e1a7a4ca6065f0f97cf63d9a9842a9cc6c4f1dd3
from unittest import mock, skipUnless from django.db import connection from django.db.models import Index from django.db.utils import DatabaseError from django.test import TransactionTestCase, skipUnlessDBFeature from .models import Article, ArticleReporter, City, Comment, District, Reporter class IntrospectionTest...
907a069eb705eb2a81d8f6d0a0b89a0572d287e75d5419e1a8e49712b6ab457d
from django.db import models class City(models.Model): id = models.BigAutoField(primary_key=True) name = models.CharField(max_length=50) def __str__(self): return self.name class District(models.Model): city = models.ForeignKey(City, models.CASCADE, primary_key=True) name = models.CharF...
f1e0c1d1ffe0de8e5b2eaa974d0ef3841387265f0dea4a76168df846c1bd66e6
import os import re import shutil import tempfile import time import warnings from io import StringIO from unittest import mock, skipIf, skipUnless from admin_scripts.tests import AdminScriptTestCase from django.core import management from django.core.management import execute_from_command_line from django.core.manag...
19ef9a6ed754d4c76bb76b89f81064535b1115510d30e073d3f3d2a2744a5fb3
from django.conf.urls.i18n import i18n_patterns from django.http import HttpResponse from django.urls import path, re_path from django.utils.translation import gettext_lazy as _ urlpatterns = i18n_patterns( re_path(r'^(?P<arg>[\w-]+)-page', lambda request, **arg: HttpResponse(_('Yes'))), path('simple/', lambda...
4db91f16ea3bf9455f729ba2229146a199fbde9365b79b4706ee326d8f6a550a
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 threading import local from unittest import mock import _thread from django import forms from django...
937605a0948536997394a2fe64dc51b877c09cabe8c2a0b5f636bc4a5c5e795d
import gettext as gettext_module import os import stat import unittest from io import StringIO from pathlib import Path from subprocess import Popen from unittest import mock from django.core.management import ( CommandError, call_command, execute_from_command_line, ) from django.core.management.commands.makemessa...
b6e56aa4164f9b422d8282fe482dd4e2989abdcf83bb511f43787b66304b8cb5
import os import re import shutil import tempfile source_code_dir = os.path.dirname(__file__) def copytree(src, dst): shutil.copytree(src, dst, ignore=shutil.ignore_patterns('__pycache__')) class POFileAssertionMixin: def _assertPoKeyword(self, keyword, expected_value, haystack, use_quotes=True): ...
da1c4d0c2ec7553f95ed54b94999efc84d9347790c0f5a08225634c3feccf92e
from django.conf.urls.i18n import i18n_patterns from django.http import HttpResponse, StreamingHttpResponse from django.urls import path from django.utils.translation import gettext_lazy as _ urlpatterns = i18n_patterns( path('simple/', lambda r: HttpResponse()), path('streaming/', lambda r: StreamingHttpRespo...
81b583479011f6e8b851908cb199113515e03091546c8eca62dff09ca9f27463
import os from django.template import Context, Template from django.test import SimpleTestCase, override_settings from django.utils.translation import activate, get_language, trans_real from .utils import POFileAssertionMixin SAMPLEPROJECT_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'sampleproject...
61c7d3db7c066ad2fe9ff288fd5a2be7841f91c8ffa596bada8208e844b94096
from datetime import datetime from django.test import TestCase from .models import Article, IndexErrorArticle, Person class EarliestOrLatestTests(TestCase): """Tests for the earliest() and latest() objects methods""" @classmethod def setUpClass(cls): super().setUpClass() cls._article_ge...
d8edf4db249726be052564138cceabc9fb8578b4984aea33a8e694a6db7e9ccf
import unittest from django.test import TestCase from .models import PersonWithCustomMaxLengths, PersonWithDefaultMaxLengths class MaxLengthArgumentsTests(unittest.TestCase): def verify_max_length(self, model, field, length): self.assertEqual(model._meta.get_field(field).max_length, length) def te...
3f9328ae94383959d82e869344760d7cd27e5af9d147d59dee8ed975dd9f3b54
import time import unittest from datetime import date, datetime from django.core.exceptions import FieldError from django.db import connection, models from django.test import SimpleTestCase, TestCase, override_settings from django.test.utils import register_lookup from django.utils import timezone from .models import...
6c503b204f0c02f6d2c81b0e6a870126bffe8bcc6801ee6582a257cab95f66cd
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 from django.db.models.functions import Substr from django.test import TestCase, skipUnlessDBFeature from .models import ( Articl...
ea2358a36e8e80d1d24e9f87d4b9ccc4f0753e5549a504f6e50c7d8280294f39
from datetime import datetime from django.db.models import Value from django.db.models.fields import DateTimeField from django.db.models.lookups import YearLookup from django.test import SimpleTestCase class YearLookupTests(SimpleTestCase): def test_get_bound_params(self): look_up = YearLookup( ...
aa80b96be1ecddb805dab69bf6c678942e4aab71ec0b7c554f180bb6a59fd22a
from django import forms from django.forms.formsets import DELETION_FIELD_NAME, BaseFormSet from django.forms.models import ( BaseModelFormSet, inlineformset_factory, modelform_factory, modelformset_factory, ) from django.forms.utils import ErrorDict, ErrorList from django.test import TestCase from .models imp...
23f1e9a030970d46197230bc40ea5600c01d3db6a83bdeb3218e2ed31f1695ce
from django.db import models class User(models.Model): username = models.CharField(max_length=12, unique=True) serial = models.IntegerField() class UserSite(models.Model): user = models.ForeignKey(User, models.CASCADE, to_field="username") data = models.IntegerField() class UserProfile(models.Mode...
ca3eefb92c96c7aec959fd33743c3fa4c8e771cb4fae0561ed454afc9c8178f3
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...
963d08b0f34073e7ac8585138201cb33298dfe3bb9f2b20f9d6ac683c4bf0d7d
from operator import attrgetter from django.core.exceptions import FieldError, ValidationError from django.db import connection, models from django.test import SimpleTestCase, TestCase from django.test.utils import CaptureQueriesContext, isolate_apps from .models import ( Base, Chef, CommonInfo, GrandChild, Grand...
d7e8854bff17fc240fb5f0d872796d1dd17b84c854da1da78ae9b28416668c32
from django.contrib.contenttypes.fields import ( GenericForeignKey, GenericRelation, ) from django.contrib.contenttypes.models import ContentType from django.core.checks import Error from django.core.exceptions import FieldDoesNotExist, FieldError from django.db import models from django.test import SimpleTestCase ...
d0f4389f527fe9633852bf84cd8c862c2c3c3e00dadb525fdd061deac59c36c7
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...
93c14bec70095ed87415c14b3288b079919d86757b82e7e6b12733e4d6804e23
from unittest import mock from django.apps.registry import Apps from django.db import models from django.db.models import signals from django.dispatch import receiver from django.test import SimpleTestCase, TestCase from django.test.utils import isolate_apps from .models import Author, Book, Car, Person class BaseS...
1b882ba506b055fa63306f2ad31b51363ccb087903435e671b103bbcdd956925
from django.contrib import admin from django.contrib.admin.decorators import register from django.contrib.admin.sites import site from django.core.exceptions import ImproperlyConfigured from django.test import SimpleTestCase from .models import Location, Person, Place, Traveler class NameAdmin(admin.ModelAdmin): ...
03cb3bb7e9fd05bada0b440721986ef734fca505ffa73578033de09c2a4c5ddd
from operator import attrgetter from django.db import models from django.test import SimpleTestCase, TestCase from django.test.utils import isolate_apps from .base_tests import BaseOrderWithRespectToTests from .models import Answer, Dimension, Entity, Post, Question class OrderWithRespectToBaseTests(BaseOrderWithRe...
aefac714d2ace291813eb718b441fde3a72880124ae1e2f6ba8955d6625ad52c
""" The tests are shared with contenttypes_tests and so shouldn't import or reference any models directly. Subclasses should inherit django.test.TestCase. """ from operator import attrgetter class BaseOrderWithRespectToTests: # Hook to allow subclasses to run these tests with alternate models. Answer = None ...
46082e3e5e0c41a7ab77d957669447156507cf10ce777f2a3e26b7b1f9b6197c
import datetime import pickle from io import StringIO from operator import attrgetter from unittest.mock import Mock from django.contrib.auth.models import User from django.contrib.contenttypes.models import ContentType from django.core import management from django.db import DEFAULT_DB_ALIAS, connections, router, tra...
9d8c63b4ac17ea125eecc636a37703bfb772e955002537700ed015f44bc4017a
from django.contrib.auth.models import User from django.contrib.contenttypes.fields import ( GenericForeignKey, GenericRelation, ) from django.contrib.contenttypes.models import ContentType from django.db import models class Review(models.Model): source = models.CharField(max_length=100) content_type = mo...
6771cfe1f6440b03a9ca877ac425746610ffd6ae2c4447bc945290b53356a07a
import datetime from django.contrib import admin from django.contrib.admin.models import LogEntry from django.contrib.admin.options import IncorrectLookupParameters from django.contrib.admin.templatetags.admin_list import pagination from django.contrib.admin.tests import AdminSeleniumTestCase from django.contrib.admin...
a4ea837a5f3da149a7d099aa4c351aba750f4ef44259dd409e015378f1453760
from unittest import mock, skipUnless from django.db import connection from django.db.backends.oracle.client import DatabaseClient from django.test import SimpleTestCase @skipUnless(connection.vendor == 'oracle', 'Oracle tests') class OracleDbshellTests(SimpleTestCase): def _run_dbshell(self, rlwrap=False): ...
d5cb2139bbb0cb91e8c2d7339f6dadd3441b77f7a92670e36929188cf217cebf
import os import signal import subprocess from unittest import mock from django.db.backends.postgresql.client import DatabaseClient from django.test import SimpleTestCase class PostgreSqlDbshellCommandTestCase(SimpleTestCase): def _run_it(self, dbinfo): """ That function invokes the runshell com...
f7d1aaf76a43347b1120abf9436dd3d3f2be3708fc598e5c4ce44ee8856d9185
from django.db import connection, transaction from django.db.models import Case, Count, F, FilteredRelation, Q, When from django.test import TestCase from django.test.testcases import skipUnlessDBFeature from .models import Author, Book, Borrower, Editor, RentalSession, Reservation class FilteredRelationTests(TestCa...
a26290097957a1e98c52b9b855082ffc46077ac5251fe211a1329bf04e578448
import gettext import os import re from datetime import datetime, timedelta from importlib import import_module import pytz from django import forms from django.conf import settings from django.contrib import admin from django.contrib.admin import widgets from django.contrib.admin.tests import AdminSeleniumTestCase f...
0dcf735cac8fca62e557f4e3a294de9cb95570ac7fee2763bc3f3345cd8aff2c
import uuid from django.contrib.auth.models import User from django.db import models class MyFileField(models.FileField): pass class Member(models.Model): name = models.CharField(max_length=100) birthdate = models.DateTimeField(blank=True, null=True) gender = models.CharField(max_length=1, blank=Tr...
3629ee992a4bb4d174476b1e474436b92ae61fd57cc44f851fe40445572ce54f
from django import forms from django.contrib import admin from django.contrib.admin.widgets import AutocompleteSelect from django.forms import ModelChoiceField from django.test import TestCase, override_settings from django.utils import translation from .models import Album, Band class AlbumForm(forms.ModelForm): ...
7e1d6d6ec0b896b4c8f322cf6694f13e56184657f2e8b2f8f95a17bbae2bc957
from django.urls import path from . import widgetadmin urlpatterns = [ path('', widgetadmin.site.urls), ]
e62775e44114d11f92ab19ef847f38493f1294a7e7d1b2a6ec29044271951414
# Unittests for fixtures. import json import os import re from io import StringIO from django.core import management, serializers from django.core.exceptions import ImproperlyConfigured from django.core.serializers.base import DeserializationError from django.db import IntegrityError, transaction from django.db.models...
41fd97f59358bd16f40b14e096f21f518f5fa3414980dddfafdb1cb1cb5e5209
from django.contrib.auth.models import User from django.db import models class Animal(models.Model): name = models.CharField(max_length=150) latin_name = models.CharField(max_length=150) count = models.IntegerField() weight = models.FloatField() # use a non-default name for the default manager ...
fe35ee426818f52fbffb2d9d2485e6f1f553c1b652bf99f0c8c5d5088005b1c0
from django.core.exceptions import FieldError from django.test import TestCase from .models import ( Entry, Line, Post, RegressionModelSplit, SelfRefer, SelfReferChild, SelfReferChildSibling, Tag, TagCollection, Worksheet, ) class M2MRegressionTests(TestCase): def test_multiple_m2m(self): # Multi...
145c684d73bae3d055b2a1b693fed0eb005c44af72a1c05d20d15f0806158224
from django.contrib.auth import models as auth from django.db import models # No related name is needed here, since symmetrical relations are not # explicitly reversible. class SelfRefer(models.Model): name = models.CharField(max_length=10) references = models.ManyToManyField('self') related = models.Many...
b09f4eb2447476e4b1df4604d47767f9550166ea61a0ccf8b0958571b34266ca
from django.db import migrations class Migration(migrations.Migration): dependencies = [('migrations', 'a')]
ffa7c91f3c44fa6714b1774453bef04331b023918aec83c8ebbcf1809937bd99
from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('migrations', '0001_initial'), ] operations = [ migrations.CreateModel( 'Book', [ ('id', models.AutoField(primary_key=True)), ], ...
2a005ad243c051b41902c8f45b3950cbaa00b5c413b00ef178e85c1c12d2d4aa
from django.db import migrations class Migration(migrations.Migration): dependencies = [ ("migrations", "0003_third"), ] operations = [ migrations.RunSQL('SELECT * FROM migrations_author WHERE id = 1') ]
4802b0aee2bd330f51f2ebc3c6af9d08306dec80912cd5e25c696e0119c25041
from django.db import migrations, models def grow_tail(x, y): """Grow salamander tail.""" pass def shrink_tail(x, y): """Shrink salamander tail.""" pass class Migration(migrations.Migration): initial = True operations = [ migrations.CreateModel( 'Salamander', ...
714ef1d583665069d84ca7d790bbedf806c0252afb168894f4dac77c4cb4518d
from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('migrations', '0002_second'), ] operations = [ migrations.CreateModel( 'Author', [ ('id', models.AutoField(primary_key=True)), ], ...
7f368909fee9002aa0985f7468229092f530fc4aa8aa46bd2e3e6b49d7d90694
from django.db import models class UnmigratedModel(models.Model): """ A model that is in a migration-less app (which this app is if its migrations directory has not been repointed) """ pass
4825bc0c76c53f9b8e6c849b892cf31b87089d4a403c22497ff3ee2e1ef2be3d
from django.contrib.auth.models import User from django.db import models class Concrete(models.Model): pass class Proxy(Concrete): class Meta: proxy = True permissions = ( ('display_proxys', 'May display proxys information'), ) class UserProxy(User): class Meta: ...
0660c7428618f2bd2015e024d6f98ed7e82fd0fe26dd6fb86fbaed43a11c3bac
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...
765f1000d072ba423b76d4b84ba2e603519c340d943867440856907def319e00
from django.contrib.auth.models import ( AbstractBaseUser, AbstractUser, BaseUserManager, Group, Permission, PermissionsMixin, UserManager, ) from django.db import models # The custom user uses email as the unique identifier, and requires # that every user provide a date of birth. This lets us test # changes ...
d8e181ef907fa406f01389232cff9cf02924d77b9c89c73029ca0007e3368d18
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager from django.db import models class UserManager(BaseUserManager): def _create_user(self, username, **extra_fields): user = self.model(username=username, **extra_fields) user.save(using=self._db) return user def...
9a5d1f18f92f03066e634762f25308324da884fdc10213acf9004a8585db75e8
""" Doctest example from the official Python documentation. https://docs.python.org/library/doctest.html """ def factorial(n): """Return the factorial of n, an exact integer >= 0. >>> [factorial(n) for n in range(6)] [1, 1, 2, 6, 24, 120] >>> factorial(30) # doctest: +ELLIPSIS 265252859812191058...
9a6444b1a1ce255ddf89ab4c2974dcb8555365cb63f81bb12b063c5156f26547
from unittest import TestCase from django.test import SimpleTestCase, TestCase as DjangoTestCase class DjangoCase1(DjangoTestCase): def test_1(self): pass def test_2(self): pass class DjangoCase2(DjangoTestCase): def test_1(self): pass def test_2(self): pass cl...
92bb127a0cc47e98bec2ccff56cee6bc791b82ad22142efcf1d664ff2c70e152
import unittest class NoDatabaseTests(unittest.TestCase): def test_nothing(self): pass class DefaultDatabaseTests(NoDatabaseTests): databases = {'default'} class OtherDatabaseTests(NoDatabaseTests): databases = {'other'} class AllDatabasesTests(NoDatabaseTests): databases = '__all__'
30aeb7e372a91d49d4e5f679141a0c83b123fae03e807996a062e0332e71ecc5
from django.core.management.base import BaseCommand, CommandError class Command(BaseCommand): help = "Useless command." def add_arguments(self, parser): parser.add_argument('args', metavar='app_label', nargs='*', help='Specify the app label(s) to works on.') parser.add_argument('--empty', act...
dab498ab5ce03ef5a3e71b513cdabbe34c5236cc5b6256ee73f5257b6a010e64
from django.core.serializers.json import DjangoJSONEncoder from django.db import migrations, models from ..fields import ( ArrayField, BigIntegerRangeField, CICharField, CIEmailField, CITextField, DateRangeField, DateTimeRangeField, DecimalRangeField, EnumField, HStoreField, IntegerRangeField, JSONField, S...
db12783c8fb6a80788522f140ac1f73040813401d83c4143d1640204742917ad
from app2.models import NiceModel class ProxyModel(NiceModel): class Meta: proxy = True
e8d7fb903b659856c9f933262b2450aa1e3c19e4b3c03370fac6baff6011aea1
from django.contrib.staticfiles.apps import StaticFilesConfig class IgnorePatternsAppConfig(StaticFilesConfig): ignore_patterns = ['*.css', '*/vendor/*.js']
313022a3894309019767f939655c2b8fd2fccff3dc7d9d757ee5e560831d78dc
from django.contrib.staticfiles import views from django.urls import re_path urlpatterns = [ re_path('^static/(?P<path>.*)$', views.serve), ]
ff4b11626e4b08e3f916acacf6756283a5b8ca61f332016ef6eaa77d4a9cb4db
from django.core.files.uploadedfile import SimpleUploadedFile from django.forms import ClearableFileInput, MultiWidget from .base import WidgetTest class FakeFieldFile: """ Quacks like a FieldFile (has a .url and string representation), but doesn't require us to care about storages etc. """ url =...
1935129edaf68bf0396eccfe2dd7f313873ff9535c9488a7632849f709e1d790
from django.forms.renderers import DjangoTemplates, Jinja2 from django.test import SimpleTestCase try: import jinja2 except ImportError: jinja2 = None class WidgetTest(SimpleTestCase): beatles = (('J', 'John'), ('P', 'Paul'), ('G', 'George'), ('R', 'Ringo')) @classmethod def setUpClass(cls): ...
5774ac04efe985b259eb6c6b67b418fcec38cd04eb4e99ca1e95a7913cfe240b
from datetime import date from django.forms import DateField, Form, SelectDateWidget from django.test import override_settings from django.utils import translation from django.utils.dates import MONTHS_AP from .base import WidgetTest class SelectDateWidgetTest(WidgetTest): maxDiff = None widget = SelectDate...
a3b85c450e1cdedb2b921ae327a5e7e9e1111d9adcc0a64c32ed3910695c2c5d
from django.forms import NullBooleanSelect from django.test import override_settings from django.utils import translation from .base import WidgetTest class NullBooleanSelectTest(WidgetTest): widget = NullBooleanSelect() def test_render_true(self): self.check_html(self.widget, 'is_cool', True, html=...