hash
stringlengths
64
64
content
stringlengths
0
1.51M
af3f2d9ef5c9958e15ea5896c58b21bb1404fae4cdb8a481a200b3fc6b57a1a6
from django.db.backends.mysql.base import ( DatabaseWrapper as MySQLDatabaseWrapper, ) from .features import DatabaseFeatures from .introspection import MySQLIntrospection from .operations import MySQLOperations from .schema import MySQLGISSchemaEditor class DatabaseWrapper(MySQLDatabaseWrapper): SchemaEdito...
7eb3fafc481458d0d84c7521d0085029677d837f6eac5c603aecefb781abfe97
from django.contrib.gis.db.backends.base.adapter import WKTAdapter from django.contrib.gis.db.backends.base.operations import ( BaseSpatialOperations, ) from django.contrib.gis.db.backends.utils import SpatialOperator from django.contrib.gis.db.models import aggregates from django.contrib.gis.geos.geometry import G...
23c78970a5ea8b2bf5e404c72ece6a56c1df583134ee57f4ffe89a35d1afd1ec
import logging from django.contrib.gis.db.models.fields import GeometryField from django.db.backends.mysql.schema import DatabaseSchemaEditor from django.db.utils import OperationalError logger = logging.getLogger('django.contrib.gis') class MySQLGISSchemaEditor(DatabaseSchemaEditor): sql_add_spatial_index = 'C...
1de796143446c6481f4d0febcb310acd1c493e77f904956cd227d8b3c4842175
from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures from django.db.backends.sqlite3.features import ( DatabaseFeatures as SQLiteDatabaseFeatures, ) from django.utils.functional import cached_property class DatabaseFeatures(BaseSpatialFeatures, SQLiteDatabaseFeatures): supports_3d_stor...
0af41f2aa57ea4e47b4b6d5760a2cabe7579a72b371795f64b123484fa54aa24
from django.contrib.gis.gdal import OGRGeomType from django.db.backends.sqlite3.introspection import ( DatabaseIntrospection, FlexibleFieldLookupDict, ) class GeoFlexibleFieldLookupDict(FlexibleFieldLookupDict): """ Sublcass that includes updates the `base_data_types_reverse` dict for geometry field t...
226f8d49b0db50c8ef660669001ace32e2aa9b281b70ac5366fd24d5865fd601
""" The GeometryColumns and SpatialRefSys models for the SpatiaLite backend. """ from django.contrib.gis.db.backends.base.models import SpatialRefSysMixin from django.db import models class SpatialiteGeometryColumns(models.Model): """ The 'geometry_columns' table from SpatiaLite. """ f_table_name = m...
a60ee6d1aaef9a7c0eb03268f8c8fd36e74272544c4e11214330c18d05902cd2
from ctypes.util import find_library from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.db.backends.sqlite3.base import ( DatabaseWrapper as SQLiteDatabaseWrapper, ) from .client import SpatiaLiteClient from .features import DatabaseFeatures from .introspection im...
fe7850c3dd1911eec06d907849c9f052d90cdfa5fa8f92146aeeed6739368278
""" SQL functions reference lists: https://www.gaia-gis.it/gaia-sins/spatialite-sql-4.2.1.html """ from django.contrib.gis.db.backends.base.operations import ( BaseSpatialOperations, ) from django.contrib.gis.db.backends.spatialite.adapter import SpatiaLiteAdapter from django.contrib.gis.db.backends.utils import Sp...
58bbc27023aa7537019ac8da04db75e58c15cc4d39bd7cd056f7c6bdaeaad57a
from django.db.backends.sqlite3.schema import DatabaseSchemaEditor from django.db.utils import DatabaseError class SpatialiteSchemaEditor(DatabaseSchemaEditor): sql_add_geometry_column = ( "SELECT AddGeometryColumn(%(table)s, %(column)s, %(srid)s, " "%(geom_type)s, %(dim)s, %(null)s)" ) sq...
36ca83daf0277e3aa7fc56d09c241e02a6c6c997fda1aea097b10fb0c4cf7fc7
from django.db.backends.sqlite3.client import DatabaseClient class SpatiaLiteClient(DatabaseClient): executable_name = 'spatialite'
cbbe29fd41202eda188cd6448bbda6c1c24e87f6fe33327bb1977af162570626
from django.contrib.gis.db.backends.base.adapter import WKTAdapter from django.db.backends.sqlite3.base import Database class SpatiaLiteAdapter(WKTAdapter): "SQLite adapter for geometry objects." def __conform__(self, protocol): if protocol is Database.PrepareProtocol: return str(self)
88166a5faa35601ae6c39a5251879fb7e81ae8519ad3927ef400c536c46d2e09
from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures from django.db.backends.postgresql.features import ( DatabaseFeatures as Psycopg2DatabaseFeatures, ) class DatabaseFeatures(BaseSpatialFeatures, Psycopg2DatabaseFeatures): supports_3d_storage = True supports_3d_functions = True ...
23929fd789d929ec3e3561403e8fab46427ce5083f343344130072107f71adc0
from django.contrib.gis.gdal import OGRGeomType from django.db.backends.postgresql.introspection import DatabaseIntrospection class GeoIntrospectionError(Exception): pass class PostGISIntrospection(DatabaseIntrospection): # Reverse dictionary for PostGIS geometry types not populated until # introspectio...
fd728d7e77056c43e07a21c27e466642ff2b8e708d374afdd296b80d948e5b4d
import struct from django.forms import ValidationError from .const import ( GDAL_TO_POSTGIS, GDAL_TO_STRUCT, POSTGIS_HEADER_STRUCTURE, POSTGIS_TO_GDAL, STRUCT_SIZE, ) def pack(structure, data): """ Pack data into hex string with little endian format. """ return struct.pack('<' + structure, *...
104dd12e1f32c1c27b3406213c041b3910a1c2c827b6cb2f0ea5e42f10c64760
""" The GeometryColumns and SpatialRefSys models for the PostGIS backend. """ from django.contrib.gis.db.backends.base.models import SpatialRefSysMixin from django.db import models class PostGISGeometryColumns(models.Model): """ The 'geometry_columns' view from PostGIS. See the PostGIS documentation at C...
6b9dfaf3ae99dc43d6b5c8d85177b039ed108f27c5221c514e4fed16646ed4d0
""" PostGIS to GDAL conversion constant definitions """ # Lookup to convert pixel type values from GDAL to PostGIS GDAL_TO_POSTGIS = [None, 4, 6, 5, 8, 7, 10, 11, None, None, None, None] # Lookup to convert pixel type values from PostGIS to GDAL POSTGIS_TO_GDAL = [1, 1, 1, 3, 1, 3, 2, 5, 4, None, 6, 7, None, None] # ...
b0508da0c1d1cddf9afcc45cf61bfeb7254710e0e61af7b2228a5b3fa0933c28
from django.db.backends.base.base import NO_DB_ALIAS from django.db.backends.postgresql.base import ( DatabaseWrapper as Psycopg2DatabaseWrapper, ) from .features import DatabaseFeatures from .introspection import PostGISIntrospection from .operations import PostGISOperations from .schema import PostGISSchemaEdito...
f0464655cd60fb7675e813867c9e9508643af7683a665dbe20096240f418ce2a
import re from django.conf import settings from django.contrib.gis.db.backends.base.operations import ( BaseSpatialOperations, ) from django.contrib.gis.db.backends.utils import SpatialOperator from django.contrib.gis.db.models import GeometryField, RasterField from django.contrib.gis.gdal import GDALRaster from d...
f0e2efa065919e6f163615737ddff8864e7c23f204acf31dbecc0bd83e031b62
from django.db.backends.postgresql.schema import DatabaseSchemaEditor class PostGISSchemaEditor(DatabaseSchemaEditor): geom_index_type = 'GIST' geom_index_ops_nd = 'GIST_GEOMETRY_OPS_ND' rast_index_wrapper = 'ST_ConvexHull(%s)' sql_alter_column_to_3d = "ALTER COLUMN %(column)s TYPE %(type)s USING ST_...
8c36b95f6b888faa91a6027c0d47c49160591133227f2c6a0ed9e403bde452ef
""" This object provides quoting for GEOS geometries into PostgreSQL/PostGIS. """ from psycopg2 import Binary from psycopg2.extensions import ISQLQuote from django.contrib.gis.db.backends.postgis.pgraster import to_pgraster from django.contrib.gis.geos import GEOSGeometry class PostGISAdapter: def __init__(self...
56ff8c01f134b8d89e245e96f604384cef881c2090bcbd6a014ee5c842b88b39
import argparse from django.contrib.gis import gdal from django.core.management.base import BaseCommand, CommandError from django.utils.inspect import get_func_args class LayerOptionAction(argparse.Action): """ Custom argparse action for the `ogrinspect` `layer_key` keyword option which may be an integer...
6760e8e7a98cdad06f9ee8e70a4e42ec9848df3fcb4160782f433adba866ba69
from django.core.management.commands.inspectdb import ( Command as InspectDBCommand, ) class Command(InspectDBCommand): db_module = 'django.contrib.gis.db' def get_field_type(self, connection, table_name, row): field_type, field_params, field_notes = super().get_field_type(connection, table_name,...
feb3801467aec649b4abdab27ceb17e8ff348a4c2d4a4bdccbcc10654fa405a2
import json import os import sys import uuid from ctypes import ( addressof, byref, c_buffer, c_char_p, c_double, c_int, c_void_p, string_at, ) from django.contrib.gis.gdal.driver import Driver from django.contrib.gis.gdal.error import GDALException from django.contrib.gis.gdal.prototypes import raster as capi fro...
0fdefa10dad61567681f57d2e43bb285c4bc8b1ef3241f1422ee3f36f109b602
""" GDAL - Constant definitions """ from ctypes import ( c_double, c_float, c_int16, c_int32, c_ubyte, c_uint16, c_uint32, ) # See http://www.gdal.org/gdal_8h.html#a22e22ce0a55036a96f652765793fb7a4 GDAL_PIXEL_TYPES = { 0: 'GDT_Unknown', # Unknown or unspecified type 1: 'GDT_Byte', # Eight bit unsigned in...
58b7593604651804fa932217cf96c184f6e9358e77226c509127952f2bf83a17
from django.contrib.gis.gdal.base import GDALBase from django.contrib.gis.gdal.prototypes import raster as capi class GDALRasterBase(GDALBase): """ Attributes that exist on both GDALRaster and GDALBand. """ @property def metadata(self): """ Return the metadata for this raster or ba...
c58dce090ccb2201d3252620843766a55ed95bb687116e30fd9e647787c8f530
from ctypes import byref, c_double, c_int, c_void_p from django.contrib.gis.gdal.error import GDALException from django.contrib.gis.gdal.prototypes import raster as capi from django.contrib.gis.gdal.raster.base import GDALRasterBase from django.contrib.gis.shortcuts import numpy from django.utils.encoding import force...
10b44eedb47c4713b71c8bb1b62b6bd3aca1b06e03c584e546c4dae8d7a74ea2
from ctypes import POINTER, c_char_p, c_double, c_int, c_void_p from django.contrib.gis.gdal.envelope import OGREnvelope from django.contrib.gis.gdal.libgdal import lgdal from django.contrib.gis.gdal.prototypes.errcheck import check_envelope from django.contrib.gis.gdal.prototypes.generation import ( const_string_...
5a61446ebc10409a5d1dde5b0596183b4edbb11ff74aff191505cd8c681f7c60
""" This module contains functions that generate ctypes prototypes for the GDAL routines. """ from ctypes import POINTER, c_char_p, c_double, c_int, c_int64, c_void_p from functools import partial from django.contrib.gis.gdal.prototypes.errcheck import ( check_arg_errcode, check_const_string, check_errcode, chec...
f353104829b796fabc2d8322eedf74d59f365fd0a1800a43d0c0ba8e1d93293e
""" This module houses the error-checking routines used by the GDAL ctypes prototypes. """ from ctypes import c_void_p, string_at from django.contrib.gis.gdal.error import ( GDALException, SRSException, check_err, ) from django.contrib.gis.gdal.libgdal import lgdal # Helper routines for retrieving pointers and...
cfb522011de75fced0b452591a4acaacc7ab7dfae373cc84528b5075cc57008d
""" This module houses the ctypes function prototypes for GDAL DataSource (raster) related data structures. """ from ctypes import POINTER, c_bool, c_char_p, c_double, c_int, c_void_p from functools import partial from django.contrib.gis.gdal.libgdal import GDAL_VERSION, std_call from django.contrib.gis.gdal.prototype...
000bbb427c22819fb70e67beb87b0ec92953d531af0184afa85d6966d6ae32da
""" This module houses the ctypes function prototypes for OGR DataSource related data structures. OGR_Dr_*, OGR_DS_*, OGR_L_*, OGR_F_*, OGR_Fld_* routines are relevant here. """ from ctypes import POINTER, c_char_p, c_double, c_int, c_long, c_void_p from django.contrib.gis.gdal.envelope import OGREnvelope from djan...
cb302a58e1633fadba2a8bf07751ce949b96713de4b8b085abf3c254d37b19ac
from ctypes import POINTER, c_char_p, c_int, c_void_p from django.contrib.gis.gdal.libgdal import lgdal, std_call from django.contrib.gis.gdal.prototypes.generation import ( const_string_output, double_output, int_output, srs_output, string_output, void_output, ) # Shortcut generation for routines with known...
2e5fd39a97c98514e6595e5d80a271fc387aedacb5a5af927651f9e7c3513f0e
import threading from django.contrib.gis.geos.base import GEOSBase from django.contrib.gis.geos.libgeos import ( CONTEXT_PTR, error_h, lgeos, notice_h, ) class GEOSContextHandle(GEOSBase): """Represent a GEOS context handle.""" ptr_type = CONTEXT_PTR destructor = lgeos.finishGEOS_r def __init__(...
16858476e31b6d66fafdb94cd8824e3ff5a460254848b92cb9739a1402fff5cf
from ctypes import POINTER, c_char_p, c_int, c_size_t, c_ubyte from django.contrib.gis.geos.libgeos import CS_PTR, GEOM_PTR, GEOSFuncFactory from django.contrib.gis.geos.prototypes.errcheck import ( check_geom, check_minus_one, check_sized_string, check_string, ) # This is the return type used by binary output (W...
d237cb6a72e6235abedcd22974866bdc41e733384f4573216c23481dfde095f2
""" This module contains all of the GEOS ctypes function prototypes. Each prototype handles the interaction between the GEOS library and Python via ctypes. """ from django.contrib.gis.geos.prototypes.coordseq import ( # NOQA create_cs, cs_clone, cs_getdims, cs_getordinate, cs_getsize, cs_getx, cs_gety, cs_...
61ad3a8abecb650052532a41d398aff60a6f668c0e48b20a6b87e10a7859b986
""" This module houses the GEOS ctypes prototype functions for the unary and binary predicate operations on geometries. """ from ctypes import c_byte, c_char_p, c_double from django.contrib.gis.geos.libgeos import GEOM_PTR, GEOSFuncFactory from django.contrib.gis.geos.prototypes.errcheck import check_predicate # #...
6135011681d4e6964e01a9813e0a20172983b3082732bd7f28be7db197c89d8a
""" Error checking functions for GEOS ctypes prototype functions. """ from ctypes import c_void_p, string_at from django.contrib.gis.geos.error import GEOSException from django.contrib.gis.geos.libgeos import GEOSFuncFactory # Getting the `free` routine used to free the memory allocated for # string pointers returne...
c1dd0ec6451088c362a035e925d45cd61f6cc2c67609e3a0a8cbc7c6a245639b
""" This module houses the GEOS ctypes prototype functions for the topological operations on geometries. """ from ctypes import c_double, c_int from django.contrib.gis.geos.libgeos import GEOM_PTR, GEOSFuncFactory from django.contrib.gis.geos.prototypes.errcheck import ( check_geom, check_minus_one, check_string...
3e759214baf0fc93dd8da7d1fce79587a2ea2602e3701545291053dc9f33d726
import threading from ctypes import POINTER, Structure, byref, c_byte, c_char_p, c_int, c_size_t from django.contrib.gis.geos.base import GEOSBase from django.contrib.gis.geos.libgeos import ( GEOM_PTR, GEOSFuncFactory, geos_version_tuple, ) from django.contrib.gis.geos.prototypes.errcheck import ( check_geom,...
ed7c24d071bffc9b4fb7ac090fe89e3240feecac699e87d8ac74a4e8d114789a
""" This module is for the miscellaneous GEOS routines, particularly the ones that return the area, distance, and length. """ from ctypes import POINTER, c_double, c_int from django.contrib.gis.geos.libgeos import GEOM_PTR, GEOSFuncFactory from django.contrib.gis.geos.prototypes.errcheck import check_dbl, check_stri...
482ee0f7fbefb16fedcbb2caaa533325f17dbf712fb095fdfa3de4a5278245f6
from ctypes import c_byte from django.contrib.gis.geos.libgeos import ( GEOM_PTR, PREPGEOM_PTR, GEOSFuncFactory, ) from django.contrib.gis.geos.prototypes.errcheck import check_predicate # Prepared geometry constructor and destructors. geos_prepare = GEOSFuncFactory('GEOSPrepare', argtypes=[GEOM_PTR], restype=PRE...
0aaec7a8c557b7c17ed02d5c39f61f91aa47634b7964dbbdbfb87bfd82c3e66a
from ctypes import POINTER, c_double, c_int, c_uint from django.contrib.gis.geos.libgeos import CS_PTR, GEOM_PTR, GEOSFuncFactory from django.contrib.gis.geos.prototypes.errcheck import ( GEOSException, last_arg_byref, ) # ## Error-checking routines specific to coordinate sequences. ## def check_cs_op(result, fu...
9ab72e9b1b1062cabea0e85250aaa704ed42eb1fd8ee11658bd62a5cdce594d9
""" Tests for django.core.servers. """ import errno import os import socket import sys from http.client import HTTPConnection, RemoteDisconnected from urllib.error import HTTPError from urllib.parse import urlencode from urllib.request import urlopen from django.test import LiveServerTestCase, override_settings from ...
955172059cd2c8af0dba0d2bc18af86b88e92a6ef2f8b3a87937f46942845ff0
from django.db import models class Person(models.Model): name = models.CharField(max_length=255)
41d9673c75e173dcb535036d949f8e3ac0efc55ec4bf61de91aafd2bf39b1d53
from django.conf.urls import url from . import views urlpatterns = [ url(r'^example_view/$', views.example_view), url(r'^model_view/$', views.model_view), url(r'^create_model_instance/$', views.create_model_instance), url(r'^environ_view/$', views.environ_view), url(r'^subview_calling_view/$', vie...
1be5acea9f13e5750321983f078f0fe958d5368d36e36102c83a3d3c2d13ade2
from io import BytesIO from django.core.handlers.wsgi import WSGIRequest from django.core.servers.basehttp import WSGIRequestHandler from django.test import SimpleTestCase from django.test.client import RequestFactory class Stub: def __init__(self, **kwargs): self.__dict__.update(kwargs) def sendall...
ed1665989f0a21e8022759a1351383f127add6b1680450a2b3a844b0305189d2
from django.db import DEFAULT_DB_ALIAS, connections from django.test import LiveServerTestCase, TestCase class LiveServerThreadTest(TestCase): def run_live_server_thread(self, connections_override=None): thread = LiveServerTestCase._create_server_thread(connections_override) thread.daemon = True ...
fe8814ad0bdfdedd328e2d5b804abc55abd46a764b5ed244cba9919e5c0b4553
from urllib.request import urlopen from django.http import HttpResponse from .models import Person def example_view(request): return HttpResponse('example view') def model_view(request): people = Person.objects.all() return HttpResponse('\n'.join(person.name for person in people)) def create_model_i...
e9cd29a62b16aa1ca377ef44c9da89fea750ff6d178e3f056534202099e77d5e
class EmptyRouter: pass class TestRouter: def allow_migrate(self, db, app_label, model_name=None, **hints): """ The Tribble model should be the only one to appear in the 'other' db. """ if model_name == 'tribble': return db == 'other' elif db == 'other': ...
eaa200f2610d513c08543f520b0b7bccbe7626465174cb20f0cd97c9a47b11ae
from django.db import migrations, models from django.db.migrations import operations from django.db.migrations.optimizer import MigrationOptimizer from django.test import SimpleTestCase from .models import EmptyManager, UnicodeModel class OptimizerTests(SimpleTestCase): """ Tests the migration autodetector. ...
37603f6da4ab7de8aefc919d5e669e58a44e2b33a7a9248fe338741bd255e761
from django.db.migrations.questioner import MigrationQuestioner from django.test import SimpleTestCase from django.test.utils import override_settings class QuestionerTests(SimpleTestCase): @override_settings( INSTALLED_APPS=['migrations'], MIGRATION_MODULES={'migrations': None}, ) def tes...
c11b547602a661857660d20450b0ae815f0b249ef8fee35b81632c59950902c0
from django.apps.registry import apps as global_apps from django.db import connection from django.db.migrations.exceptions import InvalidMigrationPlan from django.db.migrations.executor import MigrationExecutor from django.db.migrations.graph import MigrationGraph from django.db.migrations.recorder import MigrationReco...
5e838d0f27f3fcc9d5c438c81822a2ae507d0205b2ac50309280ac8d4971c609
import datetime import importlib import io import os import sys from unittest import mock from django.apps import apps from django.core.management import CommandError, call_command from django.db import ( ConnectionHandler, DatabaseError, connection, connections, models, ) from django.db.backends.base.schema impor...
1310f61d76de28a318cc0c73d6c3052000f67b812f26ae1ce5e44d38569edd82
import datetime import decimal import enum import functools import math import os import re import uuid from unittest import mock import custom_migration_operations.more_operations import custom_migration_operations.operations from django import get_version from django.conf import settings from django.core.validators...
d0a3e3d33fc14e3b029ec2b93dbfdacb00482fadd2f885d51f8ec0ff51b0815b
import compileall import os from django.db import connection, connections from django.db.migrations.exceptions import ( AmbiguityError, InconsistentMigrationHistory, NodeNotFoundError, ) from django.db.migrations.loader import MigrationLoader from django.db.migrations.recorder import MigrationRecorder from django....
130dd1acc90838534591cc8c36be38fbf89d381b0bbcd3ad4c9bbcb266a53690
from django.db.migrations.exceptions import ( CircularDependencyError, NodeNotFoundError, ) from django.db.migrations.graph import ( RECURSION_DEPTH_WARNING, DummyNode, MigrationGraph, Node, ) from django.test import SimpleTestCase class GraphTests(SimpleTestCase): """ Tests the digraph structure. ...
3dfde98392f39af538ca3033bb33fef1d2644244e008535c6dc882b7904827aa
from django.apps.registry import Apps from django.db import models class CustomModelBase(models.base.ModelBase): pass class ModelWithCustomBase(models.Model, metaclass=CustomModelBase): pass class UnicodeModel(models.Model): title = models.CharField('ÚÑÍ¢ÓÐÉ', max_length=20, default='“Ðjáñgó”') c...
f3d833436fc90994f7f9a6133ea17e0162d72d191510f6622b7f6f00269b5e18
import unittest from django.core.exceptions import FieldDoesNotExist from django.db import connection, migrations, models, transaction from django.db.migrations.migration import Migration from django.db.migrations.operations import CreateModel from django.db.migrations.state import ModelState, ProjectState from django...
483d19e9995697b97a3f26d115e4d189fcf04a847242b23922e6bab2d3eb6f37
import os import shutil import tempfile from contextlib import contextmanager from importlib import import_module from django.apps import apps from django.db import connections from django.db.migrations.recorder import MigrationRecorder from django.test import TransactionTestCase from django.test.utils import extend_s...
37e532f5231f66e1c5a9f7a030e96ab4b221991bb98123e8afcc155d2e04fa0c
from django.core.management import call_command from django.test import override_settings from .test_base import MigrationTestBase class Tests(MigrationTestBase): """ Deprecated model fields should still be usable in historic migrations. """ @override_settings(MIGRATION_MODULES={"migrations": "migrat...
7ab7945735f6f494907cdd3f280b88387328b9ef5fe56a3845703966792644ea
from django.db.migrations.exceptions import NodeNotFoundError from django.test import SimpleTestCase class ExceptionTests(SimpleTestCase): def test_node_not_found_error_repr(self): node = ('some_app_label', 'some_migration_label') error_repr = repr(NodeNotFoundError('some message', node)) ...
dbea27a994cdb565e972db55cec6fe74697a1570fc5f95dfd9f80e7f973fbf3e
import unittest from django.db import connection, migrations, models from django.db.migrations.state import ProjectState from django.test import override_settings from .test_operations import OperationTestBase try: import sqlparse except ImportError: sqlparse = None class AgnosticRouter: """ A rout...
e21320214a0a69360a0b53f6be7cdb4145019a0d6e8ac1399d290f365985ecf0
import functools import re from unittest import mock from django.apps import apps from django.conf import settings from django.contrib.auth.models import AbstractBaseUser from django.core.validators import RegexValidator, validate_slug from django.db import connection, models from django.db.migrations.autodetector imp...
905ec2616c0e57e923a68ed9d158b3f5c6a1e9d57d976992cbec6c0b3eb02cff
from django.apps.registry import Apps from django.contrib.contenttypes.fields import GenericForeignKey from django.db import models from django.db.migrations.exceptions import InvalidBasesError from django.db.migrations.operations import ( AddField, AlterField, DeleteModel, RemoveField, ) from django.db.migrations....
40e5122a3426f9e41f4909546d2d9f707cd715e5b9f7c0b0a9ab21e21a37bcfa
import re from django.forms import CharField, Form, Media from django.http import HttpRequest from django.middleware.csrf import ( CsrfViewMiddleware, _compare_salted_tokens as equivalent_tokens, get_token, ) from django.template import TemplateDoesNotExist, TemplateSyntaxError from django.template.backends.dummy ...
3f0a478932c11a1228d5884cb3a45928deb57568fdf694eb8028938d1c383c2d
from django.core.exceptions import ImproperlyConfigured from django.template import engines from django.test import SimpleTestCase, override_settings class TemplateUtilsTests(SimpleTestCase): @override_settings(TEMPLATES=[{'BACKEND': 'raise.import.error'}]) def test_backend_import_error(self): """ ...
78fa971e93a5df1576f359950c1af5d3aa267d571a19a75f8beffed95508e029
from template_tests.test_response import test_processor_name from django.template import Context, EngineHandler, RequestContext from django.template.backends.django import DjangoTemplates from django.template.library import InvalidTemplateLibrary from django.test import RequestFactory, override_settings from .test_du...
eb66cd462368abca7473f3852262327a13bf2ae37ee8babeb6fb3f8dc6366ea7
from unittest import skipIf from django.template import TemplateSyntaxError from django.test import RequestFactory from .test_dummy import TemplateStringsTests try: import jinja2 except ImportError: jinja2 = None Jinja2 = None else: from django.template.backends.jinja2 import Jinja2 @skipIf(jinja2 ...
6c72f7962329e574ea4f05c5988e36291bee9d7afcbf6bf28bc45a4f5e1e1aae
import os import sys import tempfile import unittest import warnings from io import StringIO from unittest import mock from django.apps import apps from django.contrib.sites.models import Site from django.core import management from django.core.files.temp import NamedTemporaryFile from django.core.management import Co...
8f83900408c5345f7d69971ecd300ba5690599a953f2d8728b61fdc6054797e4
""" Fixtures. Fixtures are a way of loading data into the database in bulk. Fixure data can be stored in any serializable format (including JSON and XML). Fixtures are identified by name, and are stored in either a directory named 'fixtures' in the application directory, or in one of the directories named in the ``FIX...
993bc0d747555307b1f0752c3e5971b4b10663593402aa87c7240c1245e1efab
from django import forms from django.core.exceptions import NON_FIELD_ERRORS from django.test import TestCase from django.utils.functional import lazy from . import ValidationTestCase from .models import ( Article, Author, GenericIPAddressTestModel, GenericIPAddrUnpackUniqueTest, ModelToValidate, ) class Bas...
36339aaa5a82946c3710ccb6392890be10f28fcf8fe74c77fffc2f186ddb7dc9
from django.core.exceptions import ValidationError from django.test import TestCase class ValidationTestCase(TestCase): def assertFailsValidation(self, clean, failed_fields, **kwargs): with self.assertRaises(ValidationError) as cm: clean(**kwargs) self.assertEqual(sorted(failed_fields)...
d274148f880af329732424ba90b014c35248f2c458727c62dc107d1b53cddcdd
from unittest import TestCase from django.core.exceptions import ValidationError from django.db import models class ValidationMessagesTest(TestCase): def _test_validation_messages(self, field, value, expected): with self.assertRaises(ValidationError) as cm: field.clean(value, None) s...
135779111e700d8ffe1ce9d85992d054d936d53a7479de897e6c6f6349c7a80a
from datetime import datetime from django.core.exceptions import ValidationError from django.db import models def validate_answer_to_universe(value): if value != 42: raise ValidationError('This is not the answer to life, universe and everything!', code='not42') class ModelToValidate(models.Model): ...
eae41e955b312a8ec8c7d648f65a7ffff58eda5880b64561bfb355842558c02d
import pickle from unittest import TestCase from django.core.exceptions import ValidationError class PickableValidationErrorTestCase(TestCase): def test_validationerror_is_picklable(self): original = ValidationError('a', code='something') unpickled = pickle.loads(pickle.dumps(original)) ...
cef7aa27cad4972d001ca4654abbceb3dd2eedcef41b2a3575a007e6e3ab0a02
import datetime import unittest from django.apps.registry import Apps from django.core.exceptions import ValidationError from django.db import models from django.test import TestCase from .models import ( CustomPKModel, FlexibleDatePost, ModelToValidate, Post, UniqueErrorsModel, UniqueFieldsModel, UniqueForDa...
fd7085ef026714715b16c6797fa24a9f9063b8f94196052d77027e643dac153b
from . import ValidationTestCase from .models import CustomMessagesModel class CustomMessagesTest(ValidationTestCase): def test_custom_simple_validator_message(self): cmm = CustomMessagesModel(number=12) self.assertFieldFailsValidationWithMessage(cmm.full_clean, 'number', ['AAARGH']) def test...
54b972a478ca12f76911ccce96c9a2344d88acc7f37d7b11b0699e16a27dc5c0
from . import ValidationTestCase from .models import ModelToValidate class TestModelsWithValidators(ValidationTestCase): def test_custom_validator_passes_for_correct_value(self): mtv = ModelToValidate(number=10, name='Some Name', f_with_custom_validator=42, f_with_iterable_of...
b31025da8276fc1f18d580bcc15504f91b9e06dbc450d7444cc2ee13a7980440
import os import sys import unittest from types import ModuleType from unittest import mock from django.conf import ENVIRONMENT_VARIABLE, LazySettings, Settings, settings from django.core.exceptions import ImproperlyConfigured from django.http import HttpRequest from django.test import ( SimpleTestCase, TestCase, ...
a061ec0b9fe3fd90567d980d890ee7f5e86264ff0c6582e25f0f0664017cd14d
from django.test import TestCase from .models import Person class PropertyTests(TestCase): def setUp(self): self.a = Person(first_name='John', last_name='Lennon') self.a.save() def test_getter(self): self.assertEqual(self.a.full_name, 'John Lennon') def test_setter(self): ...
46e953bc5f7bc9b8d661ba0fcfdde4df3928b4d1c4167e6fe724429e2bf91295
""" Using properties on models Use properties on models just like on any other Python object. """ from django.db import models class Person(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30) def _get_full_name(self): return "%s %s" % (self.fi...
9913e5b70e60c239540906882a47456bf96ae05cdc8b2a98c38bbfa86327969d
from unittest import mock from django.conf.urls import url from django.contrib import admin from django.contrib.auth.admin import UserAdmin from django.contrib.auth.models import User from django.db import connections from django.test import TestCase, override_settings from django.urls import reverse class Router: ...
ee3b24d17b128b01a426a1c3d5798b3338a8a015c62442cdc822607dc0322ee9
from django.apps import apps from django.contrib.auth import authenticate, signals from django.contrib.auth.models import User from django.core.exceptions import FieldDoesNotExist from django.test import TestCase, override_settings from django.test.client import RequestFactory from .models import MinimalUser, UserWith...
0b358ac7a270789f42dfc4c5b7dd28d001baeafdec1dc8c88daea3b3b931415b
import datetime import itertools import os import re from importlib import import_module from urllib.parse import quote from django.apps import apps from django.conf import settings from django.contrib.admin.models import LogEntry from django.contrib.auth import ( BACKEND_SESSION_KEY, REDIRECT_FIELD_NAME, SESSION_...
4049577ef8dd2974693d703a9ebfd1062c5ce893cf909b0bd36952895c18888d
from datetime import datetime from django.conf import settings from django.contrib.auth import authenticate from django.contrib.auth.backends import RemoteUserBackend from django.contrib.auth.middleware import RemoteUserMiddleware from django.contrib.auth.models import User from django.test import TestCase, modify_set...
529b548741813a939f04adc38a3b99f688643bf4092d69bf220109395c9506f4
# The password for the fixture data users is 'password'
9b0eb36262dccd989273584f40bf52355d05268c89962b32b6de722771594816
from unittest import mock from django.conf.global_settings import PASSWORD_HASHERS from django.contrib.auth import get_user_model from django.contrib.auth.base_user import AbstractBaseUser from django.contrib.auth.hashers import get_hasher from django.contrib.auth.models import ( AbstractUser, AnonymousUser, Group...
ce996755aa212164de0bda854c75156242c94e3e8bf8de8ce8c07fb4c25ad134
from django.contrib.auth import authenticate from django.contrib.auth.context_processors import PermLookupDict, PermWrapper from django.contrib.auth.models import Permission, User from django.contrib.contenttypes.models import ContentType from django.db.models import Q from django.test import SimpleTestCase, TestCase, ...
1c2db190b8a90d15f2c3fc0e39e22d26cdd62ec9a67d022d63f76e54a40f3d92
from unittest import mock from django.contrib.auth import models from django.contrib.auth.mixins import ( LoginRequiredMixin, PermissionRequiredMixin, UserPassesTestMixin, ) from django.contrib.auth.models import AnonymousUser from django.core.exceptions import PermissionDenied from django.http import HttpResponse...
8015b66498400679a4867fa546dd28e50ffcd8b98404086ce92c583fa9ec2cf5
from django.contrib.auth import get_user, get_user_model from django.contrib.auth.models import AnonymousUser, User from django.core.exceptions import ImproperlyConfigured from django.db import IntegrityError from django.http import HttpRequest from django.test import TestCase, override_settings from django.utils impor...
b0e75485ca0f993f076a7ccfd3c5fc1141ba1316b1add97b40169d5025b3c95a
from django.contrib.auth.handlers.modwsgi import ( check_password, groups_for_user, ) from django.contrib.auth.models import Group, User from django.test import TransactionTestCase, override_settings from .models import CustomUser # This must be a TransactionTestCase because the WSGI auth handler performs # its ...
251c6b0d9a53350f762735d01b3abecd165e6cbed8f008446a30a0df823006b9
import builtins import getpass import sys from datetime import date from io import StringIO from unittest import mock from django.apps import apps from django.contrib.auth import management from django.contrib.auth.management import ( create_permissions, get_default_username, ) from django.contrib.auth.management....
dd446135af5c3cc77c0eba232ecdbc11cb16c3918630da8c1d2dee455825ddd3
from datetime import date from unittest import mock from django.contrib.auth import ( BACKEND_SESSION_KEY, SESSION_KEY, authenticate, get_user, signals, ) from django.contrib.auth.backends import ModelBackend from django.contrib.auth.hashers import MD5PasswordHasher from django.contrib.auth.models import Anonymous...
684e34815723833284ca727afc3dbc5c949211c8a27e7ccb6f5eb372617083f4
""" Test URLs for auth admins. """ from django.conf.urls import url from django.contrib import admin from django.contrib.auth.admin import GroupAdmin, UserAdmin from django.contrib.auth.models import Group, User from django.contrib.auth.urls import urlpatterns # Create a silo'd admin site for just the user/group admi...
36a12d9615394cf0600e72d3e1af109112b46760785dbfa5b4ca5a2eb281a5b9
import re from django.contrib.auth.views import ( INTERNAL_RESET_SESSION_TOKEN, INTERNAL_RESET_URL_TOKEN, ) from django.test import Client def extract_token_from_url(url): token_search = re.search(r'/reset/.*/(.+?)/', url) if token_search: return token_search.group(1) class PasswordResetConfirm...
0f57e14954dae451758cc55527ea88edd68bc881ee38e44e1a4ed286ea3c6cb5
# For testing that auth backends can be referenced using a convenience import from .test_auth_backends import ImportedModelBackend __all__ = ['ImportedModelBackend']
f84b39bd34cb97be76c41b752d3f2088e113a45edf923dbd8304b6294e82f39f
from datetime import date, timedelta from django.conf import settings from django.contrib.auth.models import User from django.contrib.auth.tokens import PasswordResetTokenGenerator from django.test import TestCase class TokenGeneratorTest(TestCase): def test_make_token(self): user = User.objects.create_...
9ebc6f75fa2568735a7060be89ec3b8f06f54570b6f3f8f425cf4af13509e0ea
from django.conf.urls import url from django.contrib import admin from django.contrib.auth import get_user_model from django.contrib.auth.admin import UserAdmin site = admin.AdminSite(name='custom_user_admin') class CustomUserAdmin(UserAdmin): def log_change(self, request, object, message): # LogEntry.us...
d46232c9f1e9d42dea072d639ffc348d401ee86cc996ad931d7114ef91ddc467
from django.conf.urls import url from django.contrib import admin from django.contrib.auth import views from django.contrib.auth.decorators import login_required, permission_required from django.contrib.auth.forms import AuthenticationForm from django.contrib.auth.urls import urlpatterns as auth_urlpatterns from django...
887d087d32c8fcbd8821c78e7f04adc9ff0648e6cb12c94c24cf2153e01ea23b
from django.contrib.auth.checks import ( check_models_permissions, check_user_model, ) from django.contrib.auth.models import AbstractBaseUser from django.core import checks from django.db import models from django.test import ( SimpleTestCase, override_settings, override_system_checks, ) from django.test.utils...