hash stringlengths 64 64 | content stringlengths 0 1.51M |
|---|---|
906e064c11d4429811a4aaaa768d8a360454e88435a7641073325ded25f39f33 | from datetime import datetime
from functools import partialmethod
from io import StringIO
from unittest import mock, skipIf
from django.core import serializers
from django.core.serializers import SerializerDoesNotExist
from django.core.serializers.base import ProgressBar
from django.db import connection, transaction
f... |
5779be6cedc1f593f35d9dd6a507fd1e2367ee0d802e933afbd2bcd0932ddf9b | from django import forms
from django.contrib.admin import BooleanFieldListFilter, SimpleListFilter
from django.contrib.admin.options import VERTICAL, ModelAdmin, TabularInline
from django.contrib.admin.sites import AdminSite
from django.core.checks import Error
from django.db.models import F, Field, Model
from django.d... |
168f97cdcb4495cabb37f970c191961d785450f0432acd46c6d9f87435421d78 | """
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.... |
0ebba818dfec8a88cbe05d28efd0fb56c0b984fa66388525f7b5896d0cb35f1e | import json
from datetime import datetime
from django.contrib.admin.models import ADDITION, CHANGE, DELETION, LogEntry
from django.contrib.admin.utils import quote
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.test import TestCase, override_settings
... |
8ab0ec548806b3544099230fc7196fccd90b1c1214032a0638b096eac217c0c1 | 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... |
a47ad75f093a7688ce2c0fd6431e4e49533982d51b164374f67cb75d5b44f090 | import datetime
import pickle
import sys
import unittest
from operator import attrgetter
from django.core.exceptions import EmptyResultSet, FieldError
from django.db import DEFAULT_DB_ALIAS, connection
from django.db.models import Count, Exists, F, OuterRef, Q
from django.db.models.sql.constants import LOUTER
from dja... |
5e5402d55cbbb3a47fa7adc0c0bcb154cc03d08c1d989ca832482f4d62eb3189 | """
Various complex queries that have been problematic in the past.
"""
import threading
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):
... |
535b5a32f2525a614d900440eb66bb2d661aaf257c8527169801d2f041e480c8 | from django.db import connection
from django.db.models import Exists, F, IntegerField, OuterRef, Value
from django.db.utils import DatabaseError, NotSupportedError
from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature
from .models import Number, ReservedName
@skipUnlessDBFeature('supports_select_uni... |
e6ea47177c0b9b0e94ce7fa9446b9c7b684a88f6afae34c3f82c5039f3a25673 | import datetime
from django.db import connection
from django.test import TestCase, skipUnlessDBFeature
from django.test.utils import CaptureQueriesContext
from .models import DumbCategory, NonIntegerPKReturningModel, ReturningModel
@skipUnlessDBFeature('can_return_columns_from_insert')
class ReturningValuesTests(Te... |
77cf015fda3a3d48fb107e536e068394a9732dd1009346046e999486072668d5 | from datetime import datetime
from django.core.exceptions import FieldError
from django.db.models import CharField, F, Q
from django.db.models.expressions import SimpleCol
from django.db.models.fields.related_lookups import RelatedIsNull
from django.db.models.functions import Lower
from django.db.models.lookups import... |
470c82fe9166b721b1d837195bbbd5542b14ee4d434f306407ce3bf9b476fd6f | from unittest import mock
from django.http import HttpRequest
from django.template import (
Context, Engine, RequestContext, Template, Variable, VariableDoesNotExist,
)
from django.template.context import RenderContext
from django.test import RequestFactory, SimpleTestCase
class ContextTests(SimpleTestCase):
... |
21320cefeeb91fb38e55d63f7c9d40010cabe69454d129e5722bd2ab7fbf3f46 | import datetime
from unittest import skipIf, skipUnless
from django.db import connection
from django.db.models import Index
from django.db.models.deletion import CASCADE
from django.db.models.fields.related import ForeignKey
from django.db.models.query_utils import Q
from django.test import (
TestCase, Transaction... |
83ff6300e212c8043999e2e35095e430a697185ec073b3079a3b7aa759c336b2 | from datetime import date, datetime
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, PersonSelfRefM2M, Recipe, RecipeIngredient,
Rela... |
76e46ae01d9bff51dc912507f0d3f7be85c674368cbae72b19be351678199505 | 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',)
def __str__(self):
return self.name
class Group(models.Model):
name = models.CharFie... |
4d714a5cbec281e87d4d352c25e7003dd7194c75062d144a179b9d4958142e39 | import datetime
from copy import deepcopy
from django.core.exceptions import FieldError, MultipleObjectsReturned
from django.db import models, transaction
from django.db.utils import IntegrityError
from django.test import TestCase
from django.utils.translation import gettext_lazy
from .models import (
Article, Ca... |
60a8a8ab2587fd6c52a4a5cc100970558b5870634030c7b55c11ae5cb766fbdd | """
Many-to-one relationships
To define a many-to-one relationship, use ``ForeignKey()``.
"""
from django.db import models
class Reporter(models.Model):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)
email = models.EmailField()
def __str__(self):
ret... |
dd849fdbd00ce961ca228c33c88a27522d2e37b833c75a4dad5950a6674cdb72 | """
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... |
46d961c54e3d69fb286c59b24e438fd1f48f6a49fda8397c4da4499c96cdef5e | from django.core.exceptions import ImproperlyConfigured
from django.core.servers.basehttp import get_internal_wsgi_application
from django.core.signals import request_started
from django.core.wsgi import get_wsgi_application
from django.db import close_old_connections
from django.http import FileResponse
from django.te... |
c1e7bfbd6ef1a86180c1990457f78c0f8265a81c42dcdebfc2404fa13d591189 | 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, IntegrityError, OperationalError, connection,
)
from django.db.models import Index, Model, Q
from django.db.models.constraints im... |
6f5c5d39d26026468f1e9d5656652dcdfd5c0a0ece4dbcebc47d3b173ae481c4 | 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,
)
class EmptyRouter:
pass
... |
aee799a59cafcec31fd050440b46b27a7b8f07009ac5e355e8311ade3a4db5e3 | from django.conf import settings
from django.core.checks.security import base, csrf, sessions
from django.test import SimpleTestCase
from django.test.utils import override_settings
class CheckSessionCookieSecureTest(SimpleTestCase):
@property
def func(self):
from django.core.checks.security.sessions i... |
fdaa47aa4743f14652337c4582fa13b68d016b089dabf3edf94ee2b9d7deaa45 | 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... |
c5da17f2fba4251f5ae18b549dcab11973a0633661778455d2702913de3d6bd4 | import os
import shutil
import tempfile
from django import conf
from django.test import SimpleTestCase
from django.test.utils import extend_sys_path
class TestStartProjectSettings(SimpleTestCase):
def setUp(self):
self.temp_dir = tempfile.TemporaryDirectory()
self.addCleanup(self.temp_dir.cleanup... |
f68c9d8c559b3bf757d07faf1d0963f74a0b651905c6eea1fe040908301baefd | """
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... |
422b8fc46dcdd8a19875b9ebbaabd0cc7d99c84fb90c34c9de84231412b0b09c | 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 .models import (
Co... |
77e6e30f94e3ea2dcbf92bc5c81cf839435e473752d0aa7f94f89a22e602fff8 | import datetime
from unittest import mock, skipIf, skipUnless
from django.core.exceptions import FieldError
from django.db import NotSupportedError, connection
from django.db.models import (
F, Func, OuterRef, Q, RowRange, Subquery, Value, ValueRange, Window,
WindowFrame,
)
from django.db.models.aggregates imp... |
aff454076ec1ab9be243ad18576e519d839f8fbb0d7fa81a2b51bd2825d7e9b5 | from datetime import datetime
from operator import attrgetter
from django.core.exceptions import FieldError
from django.db.models import (
CharField, DateTimeField, F, Max, OuterRef, Subquery, Value,
)
from django.db.models.functions import Upper
from django.test import TestCase
from .models import Article, Autho... |
57d3cb42eea7b1f280787919579ce4a2e0ae2665e3fcec632d46ce77f15403b2 | """
Specifying ordering
Specify default ordering for a model using the ``ordering`` attribute, which
should be a list or tuple of field names. This tells Django how to order
``QuerySet`` results.
If a field name in ``ordering`` starts with a hyphen, that field will be
ordered in descending order. Otherwise, it'll be ... |
564296d8c79123c91a37f84df6e75e8b5b7ed28a268ee28182145881a6e04c4d | from django.conf import settings
from django.contrib.flatpages.forms import FlatpageForm
from django.contrib.flatpages.models import FlatPage
from django.contrib.sites.models import Site
from django.test import TestCase, modify_settings, override_settings
from django.utils import translation
@modify_settings(INSTALLE... |
1e47f5f36eafe2d2d6e3a87a1b8a306c86ae54cfa2a996ebb167c7648fedcfe1 | from datetime import datetime
from django.test import TestCase
from .models import Article, Reporter, Writer
class M2MIntermediaryTests(TestCase):
def test_intermediary(self):
r1 = Reporter.objects.create(first_name="John", last_name="Smith")
r2 = Reporter.objects.create(first_name="Jane", last_... |
0179329ef40bdf41a77638731ed8ce01c3707143e5a45c00a0809a2124cd8106 | 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,
)
from django.core.files.uploadedfile import SimpleUploadedFile
from django.core.validators import Validation... |
f550eead7fbcf3be16d187ae1f8b462f11eb370bf9778fbe60669521b222f40e | from django import forms
from django.core.exceptions import ValidationError
from django.test import TestCase
from .models import UUIDPK
class UUIDPKForm(forms.ModelForm):
class Meta:
model = UUIDPK
fields = '__all__'
class ModelFormBaseTest(TestCase):
def test_create_save_error(self):
... |
4258000cead2fe202e0173b98eac8e729514de07308cd2f3f0733bd483bba921 | import os
import pathlib
from unittest import mock, skipUnless
from django.conf import settings
from django.contrib.gis.geoip2 import HAS_GEOIP2
from django.contrib.gis.geos import GEOSGeometry
from django.test import SimpleTestCase
if HAS_GEOIP2:
from django.contrib.gis.geoip2 import GeoIP2, GeoIP2Exception
# ... |
976a2a4ed8b57c591b6a7e61c7e775e54285e0783b702df6ef2cd15cb547af67 | 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... |
5c24869b73905595c87c8e3c3cd3fa5c68576d7857ade45f139ce584e7e73659 | 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,... |
2e815308781d39aa5566e60a03331c33522d76de77f5b7db8b5c6abe875bafe8 | 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... |
3b4671f6944c62648c050c27f76f85fa6d751b2eda35e82b498dd92e471f8696 | 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... |
541da126124a37f7704ee36ec7676315945ff53e64c14e9baf95c6e7f396f627 | 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... |
97367d92e2936c811335e56bebd310b0c896c8311e7e77fee1301041890772b0 | 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... |
e4fc0b657330baef087761b8c28a53fbc2afbc49c806c26a07d6424e81713b3b | 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, ... |
312c2b8a66be8049b35a79d6535f08667e8185b62f5b9f3c28f3b7480e3144a9 | 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... |
ab6aacf835064ca6020072ae69d43940ba7cf51e6fd33ceedcf00c6f6f6566dd | from django.db import models
from django.test import SimpleTestCase
from .models import AutoModel, BigAutoModel, SmallAutoModel
from .test_integerfield import (
BigIntegerFieldTests, IntegerFieldTests, SmallIntegerFieldTests,
)
class AutoFieldTests(IntegerFieldTests):
model = AutoModel
class BigAutoFieldTe... |
d8c73a6da1db734cf1d7424edd3d63cfccf07a332e55e3ed3bed13c0c7d51498 | 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... |
e126d28e37f521899424c5c60367556fa3b744344b5483fec29e24a426f677fa | 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... |
75f9166281c839bca2c8678ec95489c1d49365e004caa256d1d0f564f2610701 | import json
import uuid
from django.core import exceptions, serializers
from django.db import IntegrityError, connection, models
from django.db.models import CharField, F, Value
from django.db.models.functions import Concat, Repeat
from django.test import (
SimpleTestCase, TestCase, TransactionTestCase, skipUnless... |
8fee6c86633d1e4bc3805900dbb59839c866d1f5c8f8076e0f5d8b86fadea113 | import unittest
from decimal import Decimal
from django.core import validators
from django.core.exceptions import ValidationError
from django.db import connection, models
from django.test import TestCase
from .models import BigD, Foo
class DecimalFieldTests(TestCase):
def test_to_python(self):
f = mode... |
c9309596f0080d68d2a653fe5b75b404030957dbc959457ff34bbf4c8dd10e41 | 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... |
ad421538b0c2eafd4403344a764c719def7ddfdbbf66fa6649870db2f69d5e1e | from django.db import transaction
from django.test import TestCase
from .models import FloatModel
class TestFloatField(TestCase):
def test_float_validates_object(self):
instance = FloatModel(size=2.5)
# Try setting float field to unsaved object
instance.size = instance
with trans... |
0cabe9a78015c56515689ba6828b58b3194e08e05f9f929c6084cb9ee9432b5c | from unittest import mock
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 ChildModel, Product, UniqueConstraintP... |
8dc38b12e2be07054e39c630407533b5eb7808d20d4596c431a337e0d6a4ae87 | from django.db import models
class Product(models.Model):
price = models.IntegerField(null=True)
discounted_price = models.IntegerField(null=True)
class Meta:
required_db_features = {
'supports_table_check_constraints',
}
constraints = [
models.CheckConstra... |
c5802ed573cf87f0877f07834cfd6f5c3270258f36bae98b73df405a0aa88ccf | import warnings
from datetime import datetime
from django.core.paginator import (
EmptyPage, InvalidPage, PageNotAnInteger, Paginator,
UnorderedObjectListWarning,
)
from django.test import SimpleTestCase, TestCase
from .custom import ValidAdjacentNumsPaginator
from .models import Article
class PaginationTes... |
03f35abe645ff67b3a904d045c3bb7fa48499a640a3422f148423bcb0dd7319d | import datetime
import pickle
import unittest
import uuid
from copy import deepcopy
from unittest import mock
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 (
... |
98c21eb0ee4fc2ca7454fe8fbac4b83a4e1395be16df0dc25a5331790043e0d3 | """
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' %... |
d6b3b36988bfbd135ede0a2e002fa995e3c93aeaeb961a7eb4fc921b2179143a | import io
from django.core.management import call_command
from django.test import TestCase
class CoreCommandsNoOutputTests(TestCase):
available_apps = ['empty_models']
def test_sqlflush_no_tables(self):
err = io.StringIO()
call_command('sqlflush', stderr=err)
self.assertEqual(err.get... |
a48d9e3b2e3442f3af371bba11911dbe319e9dc374b6bac4fd4bb1f958a7c769 | 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... |
98cf14215e73f9c124307b2d04e52d9a03f1b3b6112fc33918985efba1432d29 | import datetime
import decimal
import ipaddress
import uuid
from django.db import models
from django.test import SimpleTestCase
from django.utils.functional import Promise
from django.utils.translation import gettext_lazy as _
class Suit(models.IntegerChoices):
DIAMOND = 1, _('Diamond')
SPADE = 2, _('Spade')... |
ce8a66105b069164482db6424233d314271b12c7e499b1d38f0a4fa2fadcf15c | 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
from django.db.models.query import get_prefetcher, prefetch_related_objects
from django.test import... |
256f09fa360ba8abcdc8702acdb1ab7db87fb6ccb8ce0e436e1792243fbbbf2d | 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, CheckConstraintModel, City, Comment, Country,
Dis... |
606c2d65f706d0e9776068edb9c5029670b7871ceffe3763a176442218540d05 | 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 Country(models.Model):
id = models.SmallAutoField(primary_key=True)
name = models.CharField(max_length=50)
... |
2023337c7e9ea73fea12a393e0e1c1a46f6eeb634090b19b84279506768430f2 | 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... |
2c620a7e768983ffaeb6461f2df6d6c4ad2a673b52d055b71bbe0c69818b482c | import gettext as gettext_module
import os
import stat
import unittest
from io import StringIO
from pathlib import Path
from subprocess import run
from unittest import mock
from django.core.management import (
CommandError, call_command, execute_from_command_line,
)
from django.core.management.commands.makemessage... |
bcb70fe5c06b70b949417de4a54b37d318ec38eac7e3f6b4de55dcd1b8e2d6da | 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 import Max
from django.db.models.expressions import Exists, OuterRef
from django.db.models.functions import Sub... |
6af51e7542c62ad0426a7fb35a1d7132f10532b6e62c2ea5b0a8dbd2a87ea5b3 | from django.db.models.query_utils import InvalidQuery
from django.test import TestCase
from .models import (
BigChild, Child, ChildProxy, Primary, RefreshPrimaryProxy, Secondary,
)
class AssertionMixin:
def assert_delayed(self, obj, num):
"""
Instances with deferred fields look the same as no... |
051de7cda3f3990304b53db7b212027d43bb943f042ce4eb36bc9640179c3463 | from asgiref.sync import async_to_sync
from django.core.exceptions import SynchronousOnlyOperation
from django.test import SimpleTestCase
from django.utils.asyncio import async_unsafe
from .models import SimpleModel
class DatabaseConnectionTest(SimpleTestCase):
"""A database connection cannot be used in an asyn... |
b8e5942784b9da5d0d533c70a6695c4505426000b04b6168d7b893f54dcd5ca5 | from django.db import models
class SimpleModel(models.Model):
field = models.IntegerField()
|
6dc59b3816715b39de695ddde82e83623a3f78608496906cd8c5c12d3ecdceae | """
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
... |
4d788c1e6fc8a43f7b0e4873c29ba5419f252dda9e77993a03fc5e66931bf0dd | 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... |
e166ae067d9b5d8b5fa4afbc65e989f129ac71f5ff2db013b2df7cb671f39190 | from subprocess import CompletedProcess
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):
de... |
2bf0c0617e2a8a74350c1e924d5d090940d4eee4a0f27bed3f9a5113a0bffe2b | 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... |
81eca42cadbb905c37691583d84b92b777bfc20cb1c396417976e3709066f084 | from unittest import mock
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 F... |
43829fd823fd8c0daecf135a518a52dd310f784bd2ee944aa7de7710384e29f0 | 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... |
b90e3d271eeae5d1ddaf3f53021804f3819768adad6b66a05378c7af13ab1627 | 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):
... |
c5f533b63d7aefca3ae8a02badec5605c5b37bb10f3d69605a090a31cb010ee5 | from django.db import migrations
class Migration(migrations.Migration):
dependencies = []
operations = []
|
2ed198a3ab3765742dbf6f9fb2eb283b3561e4208b1d998b2cb22c8f7211517b | 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... |
c7cd95dded86b9154757de870534ce7f3556278761f6a688889d4348adf8f9c5 | from django.contrib.auth.models import AbstractBaseUser, BaseUserManager
from django.db import models
class Organization(models.Model):
name = models.CharField(max_length=255)
class CustomUserWithM2MManager(BaseUserManager):
def create_superuser(self, username, orgs, password):
user = self.model(use... |
d2dbb2307ecc48a1165b0807ad924599048246ba1610fba82ccf39091009e6a4 | from django.core.management.base import BaseCommand
class Command(BaseCommand):
def add_arguments(self, parser):
subparsers_1 = parser.add_subparsers(dest='subcommand_1')
parser_foo_1 = subparsers_1.add_parser('foo_1')
subparsers_2 = parser_foo_1.add_subparsers(dest='subcommand_2')
... |
eaf8e457af096dd8ee9e54fa4544d93a0cfc4eba06c1ec355c219090f88e1e52 | from django.core.management.base import BaseCommand
from django.utils.version import PY37
class Command(BaseCommand):
def add_arguments(self, parser):
kwargs = {'required': True} if PY37 else {}
subparsers = parser.add_subparsers(dest='subcommand', **kwargs)
parser_foo = subparsers.add_par... |
aa9f0c3d6f61f59fc3f7febed0f42558475fac58398cf3c43f406ace7d67b31f | 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='?... |
ef5866b1b7d907ab3037300dee0b683b019a08affca4fef78c423400f0001c2a | 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... |
d2e59d4cdbc33d02ed2b54c1259b1b541a431fb16b22aca2cafa3d4289fde55b | 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... |
e703de634c4f5e07e20f2950fe56c621bb75a904e624127061e5298ecd87e7d6 | import copy
import datetime
from django.forms import Select
from django.test import override_settings
from django.utils.safestring import mark_safe
from .base import WidgetTest
class SelectTest(WidgetTest):
widget = Select
nested_widget = Select(choices=(
('outer1', 'Outer 1'),
('Group "1"',... |
8f7f80a4af4b6f628b3468208cc4d6ee630782f0b678442eb3ad7e5cee698a7d | from datetime import date, datetime
from django.forms import (
DateField, Form, HiddenInput, SelectDateWidget, ValidationError,
)
from django.test import SimpleTestCase, override_settings
from django.utils import translation
class GetDate(Form):
mydate = DateField(widget=SelectDateWidget)
class DateFieldTe... |
726f532b4363c2c8aebc2ab4d0d084d319b9af13e96d16d538706d929802e746 | import os
import unittest
from django.core.files.uploadedfile import SimpleUploadedFile
from django.forms import (
ClearableFileInput, FileInput, ImageField, ValidationError, Widget,
)
from django.test import SimpleTestCase
from . import FormFieldAssertionsMixin
try:
from PIL import Image
except ImportError:... |
310ee954572b45b6ed7964d4f4dcf9e9f04110b3ea516e4e89c99ba8797e7f7b | from django.core.files.uploadedfile import SimpleUploadedFile
from django.forms import (
BooleanField, CharField, ChoiceField, DateField, DateTimeField,
DecimalField, EmailField, FileField, FloatField, Form,
GenericIPAddressField, IntegerField, ModelChoiceField,
ModelMultipleChoiceField, MultipleChoiceF... |
da069abe08e525b4c92a7c48a612836c796673598655af5596e951efc19ffd51 | import copy
import datetime
import json
import uuid
from django.core.exceptions import NON_FIELD_ERRORS
from django.core.files.uploadedfile import SimpleUploadedFile
from django.core.validators import MaxValueValidator, RegexValidator
from django.forms import (
BooleanField, CharField, CheckboxSelectMultiple, Choi... |
d01b7eab741face8c1d1f83ef0ea6b74f63fef3b4be827c4f13e602736d3a609 | from django.template import TemplateDoesNotExist
from django.test import (
Client, RequestFactory, SimpleTestCase, override_settings,
)
from django.utils.translation import override
from django.views.csrf import CSRF_FAILURE_TEMPLATE_NAME, csrf_failure
@override_settings(ROOT_URLCONF='view_tests.urls')
class Csrf... |
72d9ad5293321150ee537a008527dad12630d6d4938fe82ad75ef9ed6eb5f047 | import importlib
import inspect
import os
import re
import sys
import tempfile
import threading
from io import StringIO
from pathlib import Path
from unittest import mock
from django.core import mail
from django.core.files.uploadedfile import SimpleUploadedFile
from django.db import DatabaseError, connection
from djan... |
3bb41de3234e80d957961db2db27dd5739f0136f011c240cccac4cbd06bef69d | from django.db import models
class ParentManager(models.Manager):
def get_by_natural_key(self, parent_data):
return self.get(parent_data=parent_data)
class Parent(models.Model):
parent_data = models.CharField(max_length=30, unique=True)
parent_m2m = models.ManyToManyField('self')
objects = ... |
65c5382ca1a0f0b9214eb61573ba13fe13a3c719152de2b55654cb1c0c230f04 | from django.template.base import TemplateSyntaxError
from django.template.context import Context
from django.test import SimpleTestCase
from ..utils import SilentAttrClass, SilentGetItemClass, SomeClass, setup
basic_templates = {
'basic-syntax01': 'something cool',
'basic-syntax02': '{{ headline }}',
'bas... |
027afcd98812a2605f74ac462ec903ac22a30f72d02a1c78ddc3e827f039478b | from django.template.defaultfilters import truncatewords_html
from django.test import SimpleTestCase
class FunctionTests(SimpleTestCase):
def test_truncate_zero(self):
self.assertEqual(truncatewords_html('<p>one <a href="#">two - three <br>four</a> five</p>', 0), '')
def test_truncate(self):
... |
7d2b9011d3f8146e9e46bc7017b83b73bf6c5a7ef10618395c8a117e6c13342a | import os
from asgiref.local import Local
from django.template import Context, Template, TemplateSyntaxError
from django.test import SimpleTestCase, override_settings
from django.utils import translation
from django.utils.safestring import mark_safe
from django.utils.translation import trans_real
from ...utils impor... |
f8484fd73f9d87812cd80f19db0d7d752ecd17856c350189ad72addef64cc26f | from asgiref.local import Local
from django.template import Context, Template, TemplateSyntaxError
from django.templatetags.l10n import LocalizeNode
from django.test import SimpleTestCase, override_settings
from django.utils import translation
from django.utils.safestring import mark_safe
from django.utils.translation... |
744be77e34b87955012e3cb18d82299f88aacabb5a85ddcb4203e50a24c2231e | from unittest import skipUnless
from django.db import connection
from django.test import TestCase
@skipUnless(connection.vendor == 'mysql', 'MySQL tests')
class ParsingTests(TestCase):
def test_parse_constraint_columns(self):
_parse_constraint_columns = connection.introspection._parse_constraint_columns
... |
227336d295b72511d0a6b66b4128e23a9da74026f0c7bed086f2720cde4f4eb2 | import subprocess
import unittest
from io import StringIO
from unittest import mock
from django.db import connection
from django.db.backends.base.creation import BaseDatabaseCreation
from django.db.backends.mysql.creation import DatabaseCreation
from django.db.utils import DatabaseError
from django.test import SimpleT... |
a537420943f7085460d851d3e2454d93edb7dbd973fa4c56ec57bb888837de85 | import unittest
from django.contrib.gis.db.models.functions import (
Area, Distance, Length, Perimeter, Transform, Union,
)
from django.contrib.gis.geos import GEOSGeometry, LineString, Point
from django.contrib.gis.measure import D # alias for Distance
from django.db import NotSupportedError, connection
from dja... |
5e509edd6536e85f834a6521750ea6ffabe4b6adfc63d0ce29cc61adddfd0fc8 | from django.contrib.gis.db import models
from ..utils import gisfield_may_be_null
class NamedModel(models.Model):
name = models.CharField(max_length=30)
class Meta:
abstract = True
def __str__(self):
return self.name
class SouthTexasCity(NamedModel):
"City model on projected coord... |
585727eaadc73c37b680b7fd11733b0e3b3eebc2e25b2ce37e30c7fd284a0071 | import ctypes
import itertools
import json
import pickle
import random
from binascii import a2b_hex
from io import BytesIO
from unittest import mock
from django.contrib.gis import gdal
from django.contrib.gis.geos import (
GeometryCollection, GEOSException, GEOSGeometry, LinearRing, LineString,
MultiLineString... |
042e85a8fb067cae1cc5abe5b3f1f613d1ef98248eb6e7684f1bb2a392e2b539 | from datetime import datetime, timedelta, timezone as datetime_timezone
import pytz
from django.conf import settings
from django.db.models import (
DateField, DateTimeField, F, IntegerField, Max, OuterRef, Subquery,
TimeField,
)
from django.db.models.functions import (
Extract, ExtractDay, ExtractHour, Ex... |
aa3526d554884545bfbb615912797cd64b2e0f518b748d3ed988b67f4ba3cb83 | import datetime
import decimal
import unittest
from django.db import connection, models
from django.db.models import Avg
from django.db.models.expressions import Value
from django.db.models.functions import Cast
from django.test import (
TestCase, ignore_warnings, override_settings, skipUnlessDBFeature,
)
from ..... |
cbd0a61c84f2552d6391844d6824ba72d72771fd0fdf827ffd482365dbe5855a | import os
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.http import HttpResponsePermanentRedirect
from django.middleware.locale import LocaleMiddleware
from django.template import Context, Template
from django.test import SimpleTestCase, override_settings
from dja... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.