hash stringlengths 64 64 | content stringlengths 0 1.51M |
|---|---|
172c3b409b661841ee451ffcc14b384ed4729aca768bf722cd9314293dac776c | 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
from django.utils.functional import cached_property
class Author(models.Model... |
0e19eec3a303c05b09439dc9cf3bb378f8bdb6e8d1883e6ff6aeb5a616ab99e7 | """
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... |
707fa1cab7f9563a529a3220766c274d52fab65b028bdf72db8f1df326401466 | from unittest import mock, skipUnless
from django.db import DatabaseError, connection
from django.db.models import Index
from django.test import TransactionTestCase, skipUnlessDBFeature
from .models import (
Article, ArticleReporter, CheckConstraintModel, City, Comment, Country,
District, Reporter,
)
class ... |
d144b40bfb4e207930bcebdd27572b052a27dac468f6c96e1bf247735f68c18b | from django.db import models
class City(models.Model):
id = models.BigAutoField(primary_key=True)
name = models.CharField(max_length=50)
class Country(models.Model):
id = models.SmallAutoField(primary_key=True)
name = models.CharField(max_length=50)
class District(models.Model):
city = models.... |
07a4820740c884231122455c0bdf3ebbe327548e8cbac0ed1d0d560c4e751e0c | import os
import re
import shutil
import tempfile
import time
import warnings
from io import StringIO
from pathlib import Path
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_li... |
62635123eef7a256a221e339a4b029d6227aa55855d8691e7580ee8b1d5699ac | 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... |
cc3d7cc41974a5b933f302de61b201dbb63b6769584c49f62911ebe3829ea145 | 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... |
40dbfda3858dc963c86cf5300b0dbb32443c299add1270c3260b5b0b36ea9f12 | """
Regression tests for defer() / only() behavior.
"""
from django.db import models
class Item(models.Model):
name = models.CharField(max_length=15)
text = models.TextField(default="xyzzy")
value = models.IntegerField()
other_value = models.IntegerField(default=0)
class RelatedItem(models.Model):
... |
5e034a9b12b4eb3f76af904982540e81730d76863b934903c547afab22be1f59 | from django.db import models
class Author(models.Model):
name = models.CharField(max_length=20)
age = models.IntegerField(null=True)
birthdate = models.DateField(null=True)
average_rating = models.FloatField(null=True)
def __str__(self):
return self.name
class Article(models.Model):
... |
aab44b4188a3bbfd2e5a4a999cc82b0825ba759268167a9c13b4059d9178e56e | import collections.abc
from datetime import datetime
from math import ceil
from operator import attrgetter
from django.core.exceptions import FieldError
from django.db import connection, models
from django.db.models import Exists, Max, OuterRef
from django.db.models.functions import Substr
from django.test import Test... |
ecc3e9dfb2ad2e8e11c4212ef2df52ff80b5a68a3f300aff46ad5fea3444004e | """
The lookup API
This demonstrates features of the database API.
"""
from django.db import models
from django.db.models.lookups import IsNull
class Alarm(models.Model):
desc = models.CharField(max_length=100)
time = models.TimeField()
def __str__(self):
return '%s (%s)' % (self.time, self.des... |
4860c72a87f7c192b5c97af66e81353573ba3e9a6c909995e5806863fa5e3fdb | from datetime import datetime
from django.db.models import DateTimeField, Value
from django.db.models.lookups import YearLookup
from django.test import SimpleTestCase
class YearLookupTests(SimpleTestCase):
def test_get_bound_params(self):
look_up = YearLookup(
lhs=Value(datetime(2010, 1, 1, 0... |
888b32495d954cb1afedb865fe6370f70f09944a4e37ece754c0510bca6f27a3 | from django.db.models import F, Sum
from django.test import TestCase
from .models import Product, Stock
class DecimalFieldLookupTests(TestCase):
@classmethod
def setUpTestData(cls):
cls.p1 = Product.objects.create(name='Product1', qty_target=10)
Stock.objects.create(product=cls.p1, qty_availa... |
6809b58e9e7cf137347f1598086255b8a1aabaf309e3ad9ec7a2389b8507ba67 | 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... |
127c6e09b10e909005c4e3ce91281a3cd78538c6c6651c3af7542542a5f1ecf9 | import os
import sys
from unittest import mock, skipIf
from asgiref.sync import async_to_sync
from django.core.cache import DEFAULT_CACHE_ALIAS, caches
from django.core.exceptions import SynchronousOnlyOperation
from django.test import SimpleTestCase
from django.utils.asyncio import async_unsafe
from .models import ... |
7280e61951b0507c86db88c787902ca80f0696ab5ef6cb4fbc75d973880659ad | from operator import attrgetter
from unittest import skipUnless
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 django.utils.version import PY3... |
10bf0fdc3a84171f5dfde7503294954a9c42621b79ab85c72a055faa0a46fdfc | """
XX. Model inheritance
Model inheritance exists in two varieties:
- abstract base classes which are a way of specifying common
information inherited by the subclasses. They don't exist as a separate
model.
- non-abstract base classes (the default), which are models in their own
right with ... |
f551e1a21354ce4e1ea0ce1bf376f23114d97c9a3bf63e17ab67c7cc75d08adc | 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
... |
7006fb77a4a02b00dc7aaea7699089162dd988d92cd255c6606ee2f060404c4d | """
Testing signals before/after saving and deleting.
"""
from django.db import models
class Person(models.Model):
first_name = models.CharField(max_length=20)
last_name = models.CharField(max_length=20)
def __str__(self):
return "%s %s" % (self.first_name, self.last_name)
class Car(models.Mode... |
5550bb5e773572ad639f3fa57e16dc05e82324a96913db7475b76087ee72d053 | import warnings
from django.dispatch import Signal
from django.test import SimpleTestCase
from django.utils.deprecation import RemovedInDjango40Warning
class SignalDeprecationTests(SimpleTestCase):
def test_providing_args_warning(self):
msg = (
'The providing_args argument is deprecated. As i... |
d7c0430f844f0df5b91c7ad7beaca28a511404891995b0e47f10ae6e28e47899 | 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, router, transaction
from... |
75f3eccfdf276210685ede1b8fc75d20310e0146590fd2119e141e473f43acf8 | 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... |
62336e42c37f9dd4688f9b8c78d3ecf39c28b03f1b066b579e755fe3b16b0171 | from django.db import models
class Thing(models.Model):
num = models.IntegerField()
|
cbd1b32fc246850be9125cae36817d563a7d2d2b3a20e148a0b6aae18b22b9ac | 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... |
a439e6a64ba34d87a6103da7dfd05ae650c8c250157e71ad20c830463c8b309d | from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User
from django.core.paginator import Paginator
from .models import Child, Event, Parent, Swallow
site = admin.AdminSite(name="admin")
site.register(User, UserAdmin)
class CustomPaginator(Pagina... |
42db945ea06992472241fe8042e810e7faad70a5f2ab8a29702641479ae45343 | 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... |
072d037d99a583862fd383fc3ba4f0ad0bf2996761005fba92bf89b570c8de4c | from unittest import mock
from django.core.management import call_command
from django.core.management.base import CommandError
from django.db import connection
from django.test import SimpleTestCase
class DbshellCommandTestCase(SimpleTestCase):
def test_command_missing(self):
msg = (
'You app... |
12a60e2aa3ae6c9cf454fb1864baae1516bcd68ba1ce2846dca9f30d3bfbd4b8 | 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, parameters=None):
"""
That function invokes... |
d9d56afe779156c89a2f4d1938fbda48e53860978fbe4c323a47fd926e2a6e8c | from django.db.backends.mysql.client import DatabaseClient
from django.test import SimpleTestCase
class MySqlDbshellCommandTestCase(SimpleTestCase):
def test_fails_with_keyerror_on_incomplete_config(self):
with self.assertRaises(KeyError):
self.get_command_line_arguments({})
def test_bas... |
54de4da4bda12303c3538393e8ec1c9b62a082c3a24514bd26cd718c6001a8a6 | from pathlib import Path
from subprocess import CompletedProcess
from unittest import mock, skipUnless
from django.db import connection
from django.db.backends.sqlite3.client import DatabaseClient
from django.test import SimpleTestCase
@skipUnless(connection.vendor == 'sqlite', 'SQLite tests.')
class SqliteDbshellCo... |
e042a4c041d6065875259894cc153043a21ec491c07344b5a4c3ece05d74a3a0 | from django.contrib.contenttypes.fields import (
GenericForeignKey, GenericRelation,
)
from django.contrib.contenttypes.models import ContentType
from django.db import models
class Author(models.Model):
name = models.CharField(max_length=50, unique=True)
favorite_books = models.ManyToManyField(
'B... |
19e1e6df9c7ea8776f826dc8d44f617ce966f2e3c5c6942696b3e211d727be54 | 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... |
da0adb8b40121401d75dbf09f7f624ba2e2007e5b948d5315cff956a5992517f | 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
... |
40ac684a6a8b252837552fcfdb5d7bfda439fbb8187432ecb6f84f8491617a89 | from django.core.management.base import BaseCommand, CommandError
class Command(BaseCommand):
help = "Dance around like a madman."
args = ''
requires_system_checks = True
def add_arguments(self, parser):
parser.add_argument("integer", nargs='?', type=int, default=0)
parser.add_argumen... |
6070097bd599abe5b39ca1a4450ce99638d02bbca245c89e595c8480e4e35858 | 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... |
d8411895f66a1c78fd4a3c2fe76b733238b9c1324b27927477ae7c0b0579c5a0 | from unittest import mock
from django.db import connection, migrations
try:
from django.contrib.postgres.operations import (
BloomExtension, BtreeGinExtension, BtreeGistExtension, CITextExtension,
CreateExtension, CryptoExtension, HStoreExtension, TrigramExtension,
UnaccentExtension,
)... |
60f1b062e39c41a6183fecc373f5327c444c8d52b90282c1b9695e6455dc7640 | from django.db import migrations, models
from ..fields import (
ArrayField, BigIntegerRangeField, CICharField, CIEmailField, CITextField,
DateRangeField, DateTimeRangeField, DecimalRangeField, EnumField,
HStoreField, IntegerRangeField, SearchVectorField,
)
from ..models import TagField
class Migration(mi... |
b3f7c00b6e10469cd47a8e85ab2c67a0c66c46ff2a9685a98d739ae0cfee3ba8 | 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 =... |
c455f707618266b3aa78e645ba80fbaef77175ab40fdd0d88de1cf3247d9afea | import copy
from datetime import datetime
from django.forms import (
CharField, FileInput, MultipleChoiceField, MultiValueField, MultiWidget,
RadioSelect, SelectMultiple, SplitDateTimeField, SplitDateTimeWidget,
TextInput,
)
from .base import WidgetTest
class MyMultiWidget(MultiWidget):
def decompre... |
1a42ba57ed1ca34dd108cf324e86e6358a3f4e82f13876f9a787f39d82da5d6d | from django.core.exceptions import ValidationError
from django.forms import IntegerField, Textarea
from django.test import SimpleTestCase
from . import FormFieldAssertionsMixin
class IntegerFieldTest(FormFieldAssertionsMixin, SimpleTestCase):
def test_integerfield_1(self):
f = IntegerField()
sel... |
7291700fadf1ae409e54b375d2cd87bad06c70a6f85210f3e5e3347b37be1160 | from datetime import date, datetime
from django.core.exceptions import ValidationError
from django.forms import DateField, Form, HiddenInput, SelectDateWidget
from django.test import SimpleTestCase, override_settings
from django.utils import translation
class GetDate(Form):
mydate = DateField(widget=SelectDateWi... |
1427ecf76e3b31d69e3b75503920e92059ab52cd348317de16a7c2164a5041c0 | import datetime
from django.core.exceptions import ValidationError
from django.forms import TimeField
from django.test import SimpleTestCase
from . import FormFieldAssertionsMixin
class TimeFieldTest(FormFieldAssertionsMixin, SimpleTestCase):
def test_timefield_1(self):
f = TimeField()
self.ass... |
8e3d6087553b181138d734f195b97bcc0469cf94bfa41f61d78ffbff9724b3c4 | import datetime
from django.core.exceptions import ValidationError
from django.forms import DurationField
from django.test import SimpleTestCase
from django.utils import translation
from django.utils.duration import duration_string
from . import FormFieldAssertionsMixin
class DurationFieldTest(FormFieldAssertionsMi... |
bc4deca1df2be80a6d1bf926c47f0ff4536599301a5ec23a7b083756401c8274 | import datetime
from django.core.exceptions import ValidationError
from django.forms import SplitDateTimeField
from django.forms.widgets import SplitDateTimeWidget
from django.test import SimpleTestCase
class SplitDateTimeFieldTest(SimpleTestCase):
def test_splitdatetimefield_1(self):
f = SplitDateTimeF... |
4495dd050ca2990b4b45fe791a796b76cfc3cceba140f7c8d4ca215a050ad615 | import json
import uuid
from django.core.serializers.json import DjangoJSONEncoder
from django.forms import (
CharField, Form, JSONField, Textarea, TextInput, ValidationError,
)
from django.test import SimpleTestCase
class JSONFieldTest(SimpleTestCase):
def test_valid(self):
field = JSONField()
... |
170c8d3f4555e128d2594701021cbd9e1a010a0c265abb46a9ff0022919209d9 | import pickle
from django.core.exceptions import ValidationError
from django.core.files.uploadedfile import SimpleUploadedFile
from django.forms import FileField
from django.test import SimpleTestCase
class FileFieldTest(SimpleTestCase):
def test_filefield_1(self):
f = FileField()
with self.asse... |
7f942b62caa8fe603351a724f72774953e807d7c61dc6125f6a88cca0781e0de | import uuid
from django.core.exceptions import ValidationError
from django.forms import UUIDField
from django.test import SimpleTestCase
class UUIDFieldTest(SimpleTestCase):
def test_uuidfield_1(self):
field = UUIDField()
value = field.clean('550e8400e29b41d4a716446655440000')
self.asser... |
dfb4d269ce6195b54ff360a57c3cd22d4faf7c9b32517fc8676ade395f2736fb | from datetime import datetime
from django.core.exceptions import ValidationError
from django.forms import (
CharField, Form, MultipleChoiceField, MultiValueField, MultiWidget,
SelectMultiple, SplitDateTimeField, SplitDateTimeWidget, TextInput,
)
from django.test import SimpleTestCase
beatles = (('J', 'John'),... |
127f84d93717a69063cf6f644112dc2d0009a448cf7836e87daed694c575c9e1 | import decimal
from django.core.exceptions import ValidationError
from django.forms import TypedMultipleChoiceField
from django.test import SimpleTestCase
class TypedMultipleChoiceFieldTest(SimpleTestCase):
def test_typedmultiplechoicefield_1(self):
f = TypedMultipleChoiceField(choices=[(1, "+1"), (-1, ... |
f9dd05082a7d734617928533c5e5bd50acd54f8de37ecfc50f4e1604d849040c | from django.core.exceptions import ValidationError
from django.forms import ChoiceField, Form
from django.test import SimpleTestCase
from . import FormFieldAssertionsMixin
class ChoiceFieldTest(FormFieldAssertionsMixin, SimpleTestCase):
def test_choicefield_1(self):
f = ChoiceField(choices=[('1', 'One')... |
c0bc9fed4222e6773e7c7a4bc78039b924cfc2ad4992b94b0658bae3abe3931f | from django.core.exceptions import ValidationError
from django.forms import URLField
from django.test import SimpleTestCase
from . import FormFieldAssertionsMixin
class URLFieldTest(FormFieldAssertionsMixin, SimpleTestCase):
def test_urlfield_1(self):
f = URLField()
self.assertWidgetRendersTo(f,... |
b08963e376fa28481ab4b55607f25c765b98fbb7ef284a71476b5c92b0618dea | from django.core.exceptions import ValidationError
from django.forms import MultipleChoiceField
from django.test import SimpleTestCase
class MultipleChoiceFieldTest(SimpleTestCase):
def test_multiplechoicefield_1(self):
f = MultipleChoiceField(choices=[('1', 'One'), ('2', 'Two')])
with self.asser... |
8a16b23c093d4abc1b3bb0d0d3e8178c882fef72fb970e4142a94f1857ba6ee4 | from django.core.exceptions import ValidationError
from django.forms import CharField, ComboField, EmailField
from django.test import SimpleTestCase
class ComboFieldTest(SimpleTestCase):
def test_combofield_1(self):
f = ComboField(fields=[CharField(max_length=20), EmailField()])
self.assertEqual(... |
a661eb7f323d355b74364ddd8abefed5a77e7ababb941aa8f91ae179f6cad2fa | from django.core.exceptions import ValidationError
from django.forms import EmailField
from django.test import SimpleTestCase
from . import FormFieldAssertionsMixin
class EmailFieldTest(FormFieldAssertionsMixin, SimpleTestCase):
def test_emailfield_1(self):
f = EmailField()
self.assertWidgetRend... |
43bfb47fe40cb601d76a76eecccaad54bf130e20c6f6d30a9f76b51636fe8505 | from datetime import date, datetime
from django.core.exceptions import ValidationError
from django.forms import DateTimeField
from django.test import SimpleTestCase
from django.utils.timezone import get_fixed_timezone, utc
class DateTimeFieldTest(SimpleTestCase):
def test_datetimefield_clean(self):
test... |
61c9dcc88028dd784319621e0888d5b0b60c4ab097ee13e989d01ab0456ff3d6 | import decimal
from django.core.exceptions import ValidationError
from django.forms import DecimalField, NumberInput, Widget
from django.test import SimpleTestCase, override_settings
from django.utils import formats, translation
from . import FormFieldAssertionsMixin
class DecimalFieldTest(FormFieldAssertionsMixin,... |
6cddb1c70b3c4922b404e4041ad1cc2e3ab35d457f92e54d2eecb2618d053490 | import os
import unittest
from django.core.exceptions import ValidationError
from django.core.files.uploadedfile import (
SimpleUploadedFile, TemporaryUploadedFile,
)
from django.forms import ClearableFileInput, FileInput, ImageField, Widget
from django.test import SimpleTestCase
from . import FormFieldAssertions... |
0b377b184fb9c5b64d0e1c7285bbff857bd4a7684aa096e5366420dc352cdf63 | import pickle
from django.core.exceptions import ValidationError
from django.forms import BooleanField
from django.test import SimpleTestCase
class BooleanFieldTest(SimpleTestCase):
def test_booleanfield_clean_1(self):
f = BooleanField()
with self.assertRaisesMessage(ValidationError, "'This fiel... |
ed4425eb3824e4ce119c5eaad38054cb696f735a7537715abbaffea8425fc5e7 | import decimal
from django.core.exceptions import ValidationError
from django.forms import TypedChoiceField
from django.test import SimpleTestCase
class TypedChoiceFieldTest(SimpleTestCase):
def test_typedchoicefield_1(self):
f = TypedChoiceField(choices=[(1, "+1"), (-1, "-1")], coerce=int)
self... |
33e321d3fa1f5fadaf9f3e9da32696e49c503f9acd9737ed09ff50d2644f0177 | from django.core.exceptions import ValidationError
from django.forms import (
CharField, HiddenInput, PasswordInput, Textarea, TextInput,
)
from django.test import SimpleTestCase
from . import FormFieldAssertionsMixin
class CharFieldTest(FormFieldAssertionsMixin, SimpleTestCase):
def test_charfield_1(self):... |
71cba14c9de6e3dd355f0e64cc68b184f2b635490c8b076f9dae72acb83ab13b | import re
from django.core.exceptions import ValidationError
from django.forms import RegexField
from django.test import SimpleTestCase
class RegexFieldTest(SimpleTestCase):
def test_regexfield_1(self):
f = RegexField('^[0-9][A-F][0-9]$')
self.assertEqual('2A2', f.clean('2A2'))
self.asse... |
d793abc2ac53b3b2caf2ae0719b66c109dda4c6d5e8c0822d18dbd85f01a5723 | from django.core.exceptions import ValidationError
from django.forms import GenericIPAddressField
from django.test import SimpleTestCase
class GenericIPAddressFieldTest(SimpleTestCase):
def test_generic_ipaddress_invalid_arguments(self):
with self.assertRaises(ValueError):
GenericIPAddressFie... |
f0d54e9f435bf0c12bcd144222e1ca5f2818a0f03d151ea8c23ac6bad1632900 | from django.core.exceptions import ValidationError
from django.forms import FloatField, NumberInput
from django.test import SimpleTestCase
from django.test.utils import override_settings
from django.utils import formats, translation
from . import FormFieldAssertionsMixin
class FloatFieldTest(FormFieldAssertionsMixin... |
426124ef667c14988baa6cd5631fa6a1a11655d9d3ba44c0c53787f7b97fd3a8 | import os.path
from django.core.exceptions import ValidationError
from django.forms import FilePathField
from django.test import SimpleTestCase
PATH = os.path.dirname(os.path.abspath(__file__))
def fix_os_paths(x):
if isinstance(x, str):
if x.startswith(PATH):
x = x[len(PATH):]
retur... |
079753d8213710a1baa0bacbfc96c2672bcd7fbe53e48532c824c306e89f892f | import datetime
from collections import Counter
from unittest import mock
from django.core.exceptions import ValidationError
from django.forms import (
BaseForm, CharField, DateField, FileField, Form, IntegerField,
SplitDateTimeField, formsets,
)
from django.forms.formsets import BaseFormSet, all_valid, formse... |
784da7bbe7837caccd67f9c6a69e829df46b43bb3cef2dc165b35d195db87355 | import copy
from django.core.exceptions import ValidationError
from django.forms.utils import ErrorDict, ErrorList, flatatt
from django.test import SimpleTestCase
from django.utils.safestring import mark_safe
from django.utils.translation import gettext_lazy
class FormsUtilsTestCase(SimpleTestCase):
# Tests for ... |
93b06d9375adddbec3817a3f331adda11eaa96f9cc85c7c473169e7ab587c587 | import datetime
from django.core.files.uploadedfile import SimpleUploadedFile
from django.db import models
from django.forms import CharField, FileField, Form, ModelForm
from django.forms.models import ModelFormMetaclass
from django.test import SimpleTestCase, TestCase
from ..models import (
BoundaryModel, Choice... |
94cf1fefa7d58ecd76e4f80d18a24f43b055bdca82d01d8b35c5a7fa0d69b0c2 | from django.core.exceptions import ValidationError
from django.core.files.uploadedfile import SimpleUploadedFile
from django.forms import (
BooleanField, CharField, ChoiceField, DateField, DateTimeField,
DecimalField, EmailField, FileField, FloatField, Form,
GenericIPAddressField, IntegerField, ModelChoiceF... |
a0a24fc5a764b273c2ca6cd1a431c9f33faa794c64d3ef984cdd89262033d0e8 | from datetime import date, datetime, time
from django import forms
from django.core.exceptions import ValidationError
from django.test import SimpleTestCase, override_settings
from django.utils.translation import activate, deactivate
@override_settings(TIME_INPUT_FORMATS=["%I:%M:%S %p", "%I:%M %p"], USE_L10N=True)
c... |
17dba8035f447f04899d8ee27999c5686148f355394b19ad65fceba550ea30e8 | 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... |
8473eae45d3c4e900746557c1fe269164c1fc14dfd6b882328482dc6282f3cce | import gettext
import json
from os import path
from django.conf import settings
from django.test import (
RequestFactory, SimpleTestCase, TestCase, ignore_warnings, modify_settings,
override_settings,
)
from django.test.selenium import SeleniumTestCase
from django.urls import reverse
from django.utils.deprecat... |
a6532549440c9985c03cb173fa6a3fc2949e6efa635b92eb226a97357a6ae3aa | 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... |
e7c31287ed17314a8120909b766026f8b1a5154124d28b60a58dbbdfab0fa8e6 | """Models for test_natural.py"""
import uuid
from django.db import models
class NaturalKeyAnchorManager(models.Manager):
def get_by_natural_key(self, data):
return self.get(data=data)
class NaturalKeyAnchor(models.Model):
data = models.CharField(max_length=100, unique=True)
title = models.CharF... |
85963014a2094fdbd807857b26dac7d99b0d435074a65da25b2d803edf96aa92 | """
Serialization
``django.core.serializers`` provides interfaces to converting Django
``QuerySet`` objects to and from "flat" data (i.e. strings).
"""
from decimal import Decimal
from django.db import models
class CategoryMetaDataManager(models.Manager):
def get_by_natural_key(self, kind, name):
retur... |
7ce20485cda17637e0cfe211b1afc4e3afae4ed589498f3f53ab150909d6b85a | from django.template import (
Context, Engine, TemplateDoesNotExist, TemplateSyntaxError, loader,
)
from django.test import SimpleTestCase
from ..utils import setup
from .test_basic import basic_templates
include_fail_templates = {
'include-fail1': '{% load bad_tag %}{% badtag %}',
'include-fail2': '{% lo... |
47849e428f6e05a0ee3a4186dba766e42ed97f30562acf27de82c86cab40ac5d | from django.template import TemplateSyntaxError
from django.test import SimpleTestCase
from django.utils.safestring import mark_safe
from ..utils import SafeClass, UnsafeClass, setup
class AutoescapeTagTests(SimpleTestCase):
@setup({'autoescape-tag01': '{% autoescape off %}hello{% endautoescape %}'})
def te... |
b06b21857ba1d3020b0c6ecff115d1dc126bd789f235da1ebf8ca23e720e82fb | import operator
from django import template
from django.template.defaultfilters import stringfilter
from django.utils.html import escape, format_html
from django.utils.safestring import mark_safe
register = template.Library()
@register.filter
@stringfilter
def trim(value, num):
return value[:num]
@register.fi... |
ce5feeb75d64adc7b4bd59fc4d5eeeb6f053929467f63bc11a410cba5940f28b | import unittest
from django.db import DatabaseError, connection
from django.db.models import BooleanField, NullBooleanField
from django.test import TransactionTestCase
from ..models import Square
@unittest.skipUnless(connection.vendor == 'oracle', 'Oracle tests')
class Tests(unittest.TestCase):
def test_quote_... |
7b352e0b095c32f4b301b041a8733332643cdc2356ccf502550ffd222605da4a | import unittest
from django.core.management.color import no_style
from django.db import connection
from django.test import TransactionTestCase
from ..models import Person, Tag
@unittest.skipUnless(connection.vendor == 'oracle', 'Oracle tests')
class OperationsTests(TransactionTestCase):
available_apps = ['backe... |
7ad8f763efd72b6cd1046bd261395c5bfd01536d2f788757057631bcf17be4a2 | import unittest
from django.db import connection
from django.test import TransactionTestCase
from ..models import Square
@unittest.skipUnless(connection.vendor == 'oracle', 'Oracle tests')
class DatabaseSequenceTests(TransactionTestCase):
available_apps = []
def test_get_sequences(self):
with conne... |
2cd315820c06ec654de4299b1917eb6e3e95eb7a789e53e79cdcf6c149af2359 | import unittest
from io import StringIO
from unittest import mock
from django.db import DatabaseError, connection
from django.db.backends.oracle.creation import DatabaseCreation
from django.test import TestCase
@unittest.skipUnless(connection.vendor == 'oracle', 'Oracle tests')
@mock.patch.object(DatabaseCreation, '... |
eaa9be710525e0c438113a6bb94619463995aea471b8f713875eed4eab8b7477 | import os
import re
import tempfile
import threading
import unittest
from pathlib import Path
from sqlite3 import dbapi2
from unittest import mock
from django.core.exceptions import ImproperlyConfigured
from django.db import NotSupportedError, connection, transaction
from django.db.models import Aggregate, Avg, CharFi... |
e5517667ead2db42a08ab5bd46a4f255c2bdbaae2ed67abb23dfd6823788aa2f | import unittest
from django.core.management.color import no_style
from django.db import connection
from django.test import TestCase
from ..models import Person, Tag
@unittest.skipUnless(connection.vendor == 'sqlite', 'SQLite tests.')
class SQLiteOperationsTests(TestCase):
def test_sql_flush(self):
self.... |
6392dfea508c362bd9a8904adc062c067265b62042ce992faadd4f18bb184766 | import decimal
from django.core.management.color import no_style
from django.db import NotSupportedError, connection, transaction
from django.db.backends.base.operations import BaseDatabaseOperations
from django.db.models import DurationField
from django.test import (
SimpleTestCase, TestCase, TransactionTestCase,... |
579c74ef370a04d0c61c29fe137327c60425d9f0c8a0b57986756c04e63ad2e9 | from django.db import connection
from django.db.backends.base.introspection import BaseDatabaseIntrospection
from django.test import SimpleTestCase
class SimpleDatabaseIntrospectionTests(SimpleTestCase):
may_require_msg = (
'subclasses of BaseDatabaseIntrospection may require a %s() method'
)
def... |
597126b042472c7184d2e2f3ad77aeee9cbe0c6749a6969c4a96dd8df5263562 | import copy
from unittest import mock
from django.db import DEFAULT_DB_ALIAS, connection, connections
from django.db.backends.base.creation import (
TEST_DATABASE_PREFIX, BaseDatabaseCreation,
)
from django.test import SimpleTestCase, TransactionTestCase
from ..models import (
CircularA, CircularB, Object, Ob... |
bfe1af6b02a760d296461927e03c6b082dc5b2bd405a64935a1296a578c2ae26 | import unittest
from django.core.management.color import no_style
from django.db import connection
from django.test import SimpleTestCase
from ..models import Person, Tag
@unittest.skipUnless(connection.vendor == 'mysql', 'MySQL tests.')
class MySQLOperationsTests(SimpleTestCase):
def test_sql_flush(self):
... |
30603052d96bf78f5cb283ee0bff85e00ed7e40941e3118d6ed5d7fa0206e154 | import subprocess
import unittest
from io import StringIO
from unittest import mock
from django.db import DatabaseError, connection
from django.db.backends.base.creation import BaseDatabaseCreation
from django.db.backends.mysql.creation import DatabaseCreation
from django.test import SimpleTestCase
@unittest.skipUnl... |
cecba8dc75fd51747de57875632675c55a881048fe76fa3a099f459991ebaf0c | import unittest
from io import StringIO
from unittest import mock
from django.core.exceptions import ImproperlyConfigured
from django.db import DatabaseError, connection, connections
from django.db.backends.base.base import BaseDatabaseWrapper
from django.test import TestCase, override_settings
@unittest.skipUnless(... |
e350cc656deea60013f3f02f6c7aaa3ae143040c757bf4869ac16a3d992c0cdd | import unittest
from django.core.management.color import no_style
from django.db import connection
from django.test import SimpleTestCase
from ..models import Person, Tag
@unittest.skipUnless(connection.vendor == 'postgresql', 'PostgreSQL tests.')
class PostgreSQLOperationsTests(SimpleTestCase):
def test_sql_fl... |
e7e0296b2728d586b16f87eaa0696c9ddebd3530caa59018872706d85daaf427 | import unittest
from contextlib import contextmanager
from io import StringIO
from unittest import mock
from django.db import DatabaseError, connection
from django.db.backends.base.creation import BaseDatabaseCreation
from django.test import SimpleTestCase
try:
import psycopg2 # NOQA
except ImportError:
pass... |
8d01059e2f916189516b9ca0be88a58ebe24f34fcfe7c10f2c55504d5223c39e | from django.urls import path
urlpatterns = [
path(r'(?P<named_group>\d+)', lambda x: x),
]
|
6c9e38f8d962303e845e71ec91d05f7e1212fee8873440be6f8a32e27a32bbe8 | 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... |
c33c8f7760e62e5d2bac6a4a7e76a4d5152bfdf24016c7b6df4fdb4e9f548390 | import json
from django.contrib.gis.db.models.fields import BaseSpatialField
from django.contrib.gis.db.models.functions import Distance
from django.contrib.gis.db.models.lookups import DistanceLookupBase, GISLookup
from django.contrib.gis.gdal import GDALRaster
from django.contrib.gis.geos import GEOSGeometry
from dj... |
9ffc21f05ddf266299e4d65eb840fd467a6ddce5fd97ec02b79e44fde5a2220d | import json
import math
import re
from decimal import Decimal
from django.contrib.gis.db.models import GeometryField, PolygonField, functions
from django.contrib.gis.geos import (
GEOSGeometry, LineString, Point, Polygon, fromstr,
)
from django.contrib.gis.measure import Area
from django.db import NotSupportedErro... |
8134ece30dd076c5daaab989b021ed385e849cc79f847021e35f796b7ca3e9e5 | import tempfile
import unittest
from io import StringIO
from django.contrib.gis import gdal
from django.contrib.gis.db.models import Extent, MakeLine, Union, functions
from django.contrib.gis.geos import (
GeometryCollection, GEOSGeometry, LinearRing, LineString, MultiLineString,
MultiPoint, MultiPolygon, Poin... |
296ee1501211aa0092100deaa27cf4b5928087edef5311d9632766cfc1dd7106 | from unittest import skipUnless
from django.db import connection
from django.db.models import Index
from django.test import TransactionTestCase
from ..utils import mysql, oracle, postgis
from .models import City
class SchemaIndexesTests(TransactionTestCase):
available_apps = []
models = [City]
def get_... |
8ab1da7ea0e26b72d78e239ffcb2ae702c218d43f234a857a3bf68e7cc6824d2 | from django.contrib.gis import views as gis_views
from django.contrib.gis.sitemaps import views as gis_sitemap_views
from django.contrib.sitemaps import views as sitemap_views
from django.urls import path
from .feeds import feed_dict
from .sitemaps import sitemaps
urlpatterns = [
path('feeds/<path:url>/', gis_vie... |
79f1e9885a964aea5b77fd2443994d329ea1397c13fd311eba2815349ee5baa5 | from django.core.management import call_command
from django.db import connection
from django.test import TransactionTestCase
class MigrateTests(TransactionTestCase):
"""
Tests running the migrate command in Geodjango.
"""
available_apps = ["gis_tests.gis_migrations"]
def get_table_description(sel... |
96b419282a4a7d0417c7d37576cff1716e37517c15bf7c6101cff5769fcd8a50 | from unittest import skipIf, skipUnless
from django.contrib.gis.db.models import fields
from django.contrib.gis.geos import MultiPolygon, Polygon
from django.core.exceptions import ImproperlyConfigured
from django.db import connection, migrations, models
from django.db.migrations.migration import Migration
from django... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.