repo
stringlengths
7
90
file_url
stringlengths
81
315
file_path
stringlengths
4
228
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 14:38:15
2026-01-05 02:33:18
truncated
bool
2 classes
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/app_loading/not_installed/__init__.py
tests/app_loading/not_installed/__init__.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/transactions/models.py
tests/transactions/models.py
""" Transactions Django handles transactions in three different ways. The default is to commit each transaction upon a write, but you can decorate a function to get commit-on-success behavior. Alternatively, you can manage the transaction manually. """ from django.db import models class Reporter(models.Model): ...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/transactions/__init__.py
tests/transactions/__init__.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/transactions/tests.py
tests/transactions/tests.py
import sys import threading import time from unittest import skipIf, skipUnless from django.db import ( DatabaseError, Error, IntegrityError, OperationalError, connection, transaction, ) from django.test import ( TestCase, TransactionTestCase, skipIfDBFeature, skipUnlessDBFeatur...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/backends/test_utils.py
tests/backends/test_utils.py
"""Tests for django.db.backends.utils""" from decimal import Decimal, Rounded from django.db import NotSupportedError, connection from django.db.backends.utils import ( format_number, split_identifier, split_tzname_delta, truncate_name, ) from django.test import ( SimpleTestCase, TransactionTe...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/backends/models.py
tests/backends/models.py
from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation from django.contrib.contenttypes.models import ContentType from django.db import models class Square(models.Model): root = models.IntegerField() square = models.PositiveIntegerField(db_default=9) def __str__(self): ...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/backends/__init__.py
tests/backends/__init__.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/backends/tests.py
tests/backends/tests.py
"""Tests related to django.db.backends that haven't been organized.""" import datetime import logging import threading import unittest import warnings from django.core.management.color import no_style from django.db import ( DEFAULT_DB_ALIAS, DatabaseError, IntegrityError, connection, connections,...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
true
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/backends/test_ddl_references.py
tests/backends/test_ddl_references.py
from django.db import connection from django.db.backends.ddl_references import ( Columns, Expressions, ForeignKeyName, IndexName, Statement, Table, ) from django.db.models import ExpressionList, F from django.db.models.functions import Upper from django.db.models.indexes import IndexExpression f...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/backends/oracle/test_operations.py
tests/backends/oracle/test_operations.py
import unittest from django.core.management.color import no_style from django.db import connection, models from django.test import TransactionTestCase from ..models import Person, Tag @unittest.skipUnless(connection.vendor == "oracle", "Oracle tests") class OperationsTests(TransactionTestCase): available_apps =...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/backends/oracle/test_creation.py
tests/backends/oracle/test_creation.py
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, "...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/backends/oracle/__init__.py
tests/backends/oracle/__init__.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/backends/oracle/tests.py
tests/backends/oracle/tests.py
import copy import unittest from unittest import mock from django.core.exceptions import ImproperlyConfigured from django.db import NotSupportedError, ProgrammingError, connection from django.db.models import BooleanField from django.test import TestCase, TransactionTestCase from ..models import VeryLongModelNameZZZZ...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/backends/oracle/test_introspection.py
tests/backends/oracle/test_introspection.py
import unittest from django.db import connection from django.test import TransactionTestCase, skipUnlessDBFeature from ..models import Person, Square @unittest.skipUnless(connection.vendor == "oracle", "Oracle tests") class DatabaseSequenceTests(TransactionTestCase): available_apps = [] def test_get_sequen...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/backends/postgresql/test_operations.py
tests/backends/postgresql/test_operations.py
import unittest from django.core.management.color import no_style from django.db import connection from django.db.models.expressions import Col from django.db.models.functions import Cast from django.test import SimpleTestCase from ..models import Author, Book, Person, Tag @unittest.skipUnless(connection.vendor == ...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/backends/postgresql/test_compilation.py
tests/backends/postgresql/test_compilation.py
import unittest from datetime import date from django.db import connection from django.db.models.expressions import RawSQL from django.db.utils import DataError from django.test import TestCase from ..models import Article, Reporter, Square @unittest.skipUnless(connection.vendor == "postgresql", "PostgreSQL tests")...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/backends/postgresql/test_creation.py
tests/backends/postgresql/test_creation.py
import unittest from contextlib import contextmanager from io import StringIO from unittest import mock from django.core.exceptions import ImproperlyConfigured from django.db import DatabaseError, connection from django.db.backends.base.creation import BaseDatabaseCreation from django.test import SimpleTestCase try: ...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/backends/postgresql/__init__.py
tests/backends/postgresql/__init__.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/backends/postgresql/tests.py
tests/backends/postgresql/tests.py
import copy import unittest from io import StringIO from unittest import mock from django.core.exceptions import ImproperlyConfigured from django.db import ( DEFAULT_DB_ALIAS, DatabaseError, NotSupportedError, ProgrammingError, connection, connections, ) from django.db.backends.base.base import...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/backends/postgresql/test_introspection.py
tests/backends/postgresql/test_introspection.py
import unittest from django.db import connection from django.test import TestCase from ..models import Person @unittest.skipUnless(connection.vendor == "postgresql", "Test only for PostgreSQL") class DatabaseSequenceTests(TestCase): def test_get_sequences(self): with connection.cursor() as cursor: ...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/backends/postgresql/test_server_side_cursors.py
tests/backends/postgresql/test_server_side_cursors.py
import operator import unittest from collections import namedtuple from contextlib import contextmanager from django.db import connection, models from django.db.utils import ProgrammingError from django.test import TestCase from django.test.utils import garbage_collect from django.utils.version import PYPY from ..mod...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/backends/base/test_operations.py
tests/backends/base/test_operations.py
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.db.models.expressions import Col from django.test import ( S...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/backends/base/test_features.py
tests/backends/base/test_features.py
from django.db import connection from django.test import SimpleTestCase class TestDatabaseFeatures(SimpleTestCase): def test_nonexistent_feature(self): self.assertFalse(hasattr(connection.features, "nonexistent"))
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/backends/base/test_base.py
tests/backends/base/test_base.py
import gc from unittest.mock import MagicMock, patch from django.db import DEFAULT_DB_ALIAS, connection, connections, transaction from django.db.backends.base.base import BaseDatabaseWrapper from django.test import ( SimpleTestCase, TestCase, TransactionTestCase, skipUnlessDBFeature, ) from django.test...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/backends/base/test_creation.py
tests/backends/base/test_creation.py
import copy import datetime import os 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 django.test.utils import override_sett...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/backends/base/__init__.py
tests/backends/base/__init__.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/backends/base/test_client.py
tests/backends/base/test_client.py
from unittest import mock from django.db import connection from django.db.backends.base.client import BaseDatabaseClient from django.test import SimpleTestCase class SimpleDatabaseClientTests(SimpleTestCase): def setUp(self): self.client = BaseDatabaseClient(connection=connection) def test_settings_...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/backends/base/test_schema.py
tests/backends/base/test_schema.py
from django.db import models from django.db.backends.base.schema import BaseDatabaseSchemaEditor from django.test import SimpleTestCase class SchemaEditorTests(SimpleTestCase): def test_effective_default_callable(self): """ SchemaEditor.effective_default() shouldn't call callable defaults. ...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/backends/base/test_introspection.py
tests/backends/base/test_introspection.py
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...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/backends/base/app_unmigrated/models.py
tests/backends/base/app_unmigrated/models.py
from django.db import models class Foo(models.Model): name = models.CharField(max_length=255) class Meta: app_label = "app_unmigrated"
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/backends/base/app_unmigrated/__init__.py
tests/backends/base/app_unmigrated/__init__.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/backends/base/app_unmigrated/migrations/0001_initial.py
tests/backends/base/app_unmigrated/migrations/0001_initial.py
from django.db import migrations, models class Migration(migrations.Migration): initial = True dependencies = [] operations = [ migrations.CreateModel( name="Foo", fields=[ ( "id", models.AutoField( ...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/backends/base/app_unmigrated/migrations/__init__.py
tests/backends/base/app_unmigrated/migrations/__init__.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/backends/sqlite/test_operations.py
tests/backends/sqlite/test_operations.py
import sqlite3 import unittest from django.core.management.color import no_style from django.db import connection, models from django.test import TestCase from ..models import Person, Tag @unittest.skipUnless(connection.vendor == "sqlite", "SQLite tests.") class SQLiteOperationsTests(TestCase): def test_sql_flu...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/backends/sqlite/test_features.py
tests/backends/sqlite/test_features.py
import copy import sqlite3 from unittest import mock, skipUnless from django.db import OperationalError, connection from django.test import TestCase @skipUnless(connection.vendor == "sqlite", "SQLite tests.") class FeaturesTests(TestCase): def test_supports_json_field_operational_error(self): if hasattr(...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/backends/sqlite/test_functions.py
tests/backends/sqlite/test_functions.py
from django.db.backends.sqlite3._functions import ( _sqlite_date_trunc, _sqlite_datetime_trunc, _sqlite_time_trunc, ) from django.test import SimpleTestCase class FunctionTests(SimpleTestCase): def test_sqlite_date_trunc(self): msg = "Unsupported lookup type: 'unknown-lookup'" with sel...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/backends/sqlite/test_creation.py
tests/backends/sqlite/test_creation.py
import copy import multiprocessing import unittest from unittest import mock from django.db import DEFAULT_DB_ALIAS, NotSupportedError, connection, connections from django.test import SimpleTestCase @unittest.skipUnless(connection.vendor == "sqlite", "SQLite tests") class TestDbSignatureTests(SimpleTestCase): de...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/backends/sqlite/__init__.py
tests/backends/sqlite/__init__.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/backends/sqlite/tests.py
tests/backends/sqlite/tests.py
import os import re import sqlite3 import tempfile import threading import unittest from contextlib import contextmanager from pathlib import Path from unittest import mock from django.core.exceptions import ImproperlyConfigured from django.db import ( DEFAULT_DB_ALIAS, NotSupportedError, connection, c...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/backends/sqlite/test_introspection.py
tests/backends/sqlite/test_introspection.py
import unittest import sqlparse from django.db import connection from django.test import TestCase @unittest.skipUnless(connection.vendor == "sqlite", "SQLite tests") class IntrospectionTests(TestCase): def test_get_primary_key_column(self): """ Get the primary key column regardless of whether or...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/backends/mysql/test_operations.py
tests/backends/mysql/test_operations.py
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): ...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/backends/mysql/test_features.py
tests/backends/mysql/test_features.py
from unittest import mock, skipUnless from django.db import connection from django.db.backends.mysql.features import DatabaseFeatures from django.test import TestCase @skipUnless(connection.vendor == "mysql", "MySQL tests") class TestFeatures(TestCase): def test_supports_transactions(self): """ A...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/backends/mysql/test_creation.py
tests/backends/mysql/test_creation.py
import subprocess import unittest from io import BytesIO, 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 from djang...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/backends/mysql/__init__.py
tests/backends/mysql/__init__.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/backends/mysql/tests.py
tests/backends/mysql/tests.py
import unittest from contextlib import contextmanager from unittest import mock from django.core.exceptions import ImproperlyConfigured from django.db import NotSupportedError, connection from django.test import TestCase, override_settings @contextmanager def get_connection(): new_connection = connection.copy() ...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/backends/mysql/test_schema.py
tests/backends/mysql/test_schema.py
import unittest from django.db import connection from django.test import TestCase @unittest.skipUnless(connection.vendor == "mysql", "MySQL tests") class SchemaEditorTests(TestCase): def test_quote_value(self): import MySQLdb editor = connection.schema_editor() tested_values = [ ...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/backends/mysql/test_introspection.py
tests/backends/mysql/test_introspection.py
from unittest import skipUnless from django.db import connection, connections 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_constr...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/servers/test_basehttp.py
tests/servers/test_basehttp.py
from io import BytesIO from socketserver import ThreadingMixIn from django.core.handlers.wsgi import WSGIRequest from django.core.servers.basehttp import WSGIRequestHandler, WSGIServer from django.test import SimpleTestCase from django.test.client import RequestFactory from django.test.utils import captured_stderr c...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/servers/views.py
tests/servers/views.py
from urllib.request import urlopen from django.http import HttpResponse, StreamingHttpResponse from django.views.decorators.csrf import csrf_exempt from .models import Person def example_view(request): return HttpResponse("example view") def streaming_example_view(request): return StreamingHttpResponse((b...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/servers/models.py
tests/servers/models.py
from django.db import models class Person(models.Model): name = models.CharField(max_length=255)
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/servers/__init__.py
tests/servers/__init__.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/servers/tests.py
tests/servers/tests.py
""" Tests for django.core.servers. """ import errno import os import socket import threading import unittest from http.client import HTTPConnection from urllib.error import HTTPError from urllib.parse import urlencode from urllib.request import urlopen from django.conf import settings from django.core.servers.basehtt...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/servers/test_liveserverthread.py
tests/servers/test_liveserverthread.py
from django.db import DEFAULT_DB_ALIAS, connections from django.test import LiveServerTestCase, TransactionTestCase from django.test.testcases import LiveServerThread # Use TransactionTestCase instead of TestCase to run outside of a transaction, # otherwise closing the connection would implicitly rollback and not set...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/servers/urls.py
tests/servers/urls.py
from django.urls import path from . import views urlpatterns = [ path("example_view/", views.example_view), path("streaming_example_view/", views.streaming_example_view), path("model_view/", views.model_view), path("create_model_instance/", views.create_model_instance), path("environ_view/", views...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/servers/another_app/__init__.py
tests/servers/another_app/__init__.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/inline_formsets/models.py
tests/inline_formsets/models.py
from django.db import models class School(models.Model): name = models.CharField(max_length=100) class Parent(models.Model): name = models.CharField(max_length=100) class Child(models.Model): mother = models.ForeignKey(Parent, models.CASCADE, related_name="mothers_children") father = models.Foreig...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/inline_formsets/__init__.py
tests/inline_formsets/__init__.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/inline_formsets/tests.py
tests/inline_formsets/tests.py
from django.forms.models import ModelForm, inlineformset_factory from django.test import TestCase, skipUnlessDBFeature from .models import Child, Parent, Poem, Poet, School class DeletionTests(TestCase): def test_deletion(self): PoemFormSet = inlineformset_factory( Poet, Poem, can_delete=True...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/view_tests/views.py
tests/view_tests/views.py
import datetime import decimal import logging import sys from pathlib import Path from django.core.exceptions import BadRequest, PermissionDenied, SuspiciousOperation from django.http import Http404, HttpResponse, JsonResponse from django.shortcuts import render from django.template import Context, Template, TemplateD...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/view_tests/generic_urls.py
tests/view_tests/generic_urls.py
from django.contrib.auth import views as auth_views from django.urls import path from django.views.generic import RedirectView from . import views from .models import Article, DateArticle date_based_info_dict = { "queryset": Article.objects.all(), "date_field": "date_created", "month_format": "%m", } obj...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/view_tests/models.py
tests/view_tests/models.py
""" Regression tests for Django built-in views. """ from django.db import models class Author(models.Model): name = models.CharField(max_length=100) def get_absolute_url(self): return "/authors/%s/" % self.id class BaseArticle(models.Model): """ An abstract article Model so that we can cre...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/view_tests/default_urls.py
tests/view_tests/default_urls.py
from django.contrib import admin from django.urls import path urlpatterns = [ # This is the same as in the default project template path("admin/", admin.site.urls), ]
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/view_tests/__init__.py
tests/view_tests/__init__.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/view_tests/regression_21530_urls.py
tests/view_tests/regression_21530_urls.py
from django.urls import path from . import views urlpatterns = [ path("index/", views.index_page, name="index"), ]
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/view_tests/urls.py
tests/view_tests/urls.py
import os from functools import partial from django.conf.urls.i18n import i18n_patterns from django.urls import include, path, re_path from django.utils.translation import gettext_lazy as _ from django.views import defaults, i18n, static from . import views base_dir = os.path.dirname(os.path.abspath(__file__)) media...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/view_tests/app3/__init__.py
tests/view_tests/app3/__init__.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/view_tests/templatetags/__init__.py
tests/view_tests/templatetags/__init__.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/view_tests/templatetags/debugtags.py
tests/view_tests/templatetags/debugtags.py
from django import template register = template.Library() @register.simple_tag def go_boom(): raise Exception("boom")
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/view_tests/tests/test_i18n.py
tests/view_tests/tests/test_i18n.py
import gettext import json from os import path from unittest import mock from django.conf import settings from django.test import ( RequestFactory, SimpleTestCase, TestCase, modify_settings, override_settings, ) from django.test.selenium import SeleniumTestCase from django.urls import reverse from ...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/view_tests/tests/test_specials.py
tests/view_tests/tests/test_specials.py
from django.test import SimpleTestCase, override_settings @override_settings(ROOT_URLCONF="view_tests.generic_urls") class URLHandling(SimpleTestCase): """ Tests for URL handling in views and responses. """ redirect_target = "/%E4%B8%AD%E6%96%87/target/" def test_nonascii_redirect(self): ...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/view_tests/tests/test_json.py
tests/view_tests/tests/test_json.py
import json from django.test import SimpleTestCase, override_settings @override_settings(ROOT_URLCONF="view_tests.generic_urls") class JsonResponseTests(SimpleTestCase): def test_json_response(self): response = self.client.get("/json/response/") self.assertEqual(response.status_code, 200) ...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/view_tests/tests/test_defaults.py
tests/view_tests/tests/test_defaults.py
import datetime from django.contrib.sites.models import Site from django.http import Http404 from django.template import TemplateDoesNotExist from django.test import RequestFactory, TestCase from django.test.utils import override_settings from django.views.defaults import ( bad_request, page_not_found, per...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/view_tests/tests/test_csrf.py
tests/view_tests/tests/test_csrf.py
from unittest import mock 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...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/view_tests/tests/test_static.py
tests/view_tests/tests/test_static.py
import mimetypes import unittest from os import path from unittest import mock from urllib.parse import quote from django.conf.urls.static import static from django.core.exceptions import ImproperlyConfigured from django.http import FileResponse, HttpResponseNotModified from django.test import SimpleTestCase, override...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/view_tests/tests/__init__.py
tests/view_tests/tests/__init__.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/view_tests/tests/test_debug.py
tests/view_tests/tests/test_debug.py
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, skipIf from asgiref.sync import async_to_sync, iscoroutinefunction from django.core import mail from django.core.files.uploadedfile import SimpleU...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
true
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/view_tests/app0/__init__.py
tests/view_tests/app0/__init__.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/view_tests/app5/__init__.py
tests/view_tests/app5/__init__.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/view_tests/app4/__init__.py
tests/view_tests/app4/__init__.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/view_tests/app2/__init__.py
tests/view_tests/app2/__init__.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/view_tests/app1/__init__.py
tests/view_tests/app1/__init__.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/expressions_case/models.py
tests/expressions_case/models.py
from django.db import models try: from PIL import Image except ImportError: Image = None class CaseTestModel(models.Model): integer = models.IntegerField() integer2 = models.IntegerField(null=True) string = models.CharField(max_length=100, default="") big_integer = models.BigIntegerField(nul...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/expressions_case/__init__.py
tests/expressions_case/__init__.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/expressions_case/tests.py
tests/expressions_case/tests.py
import unittest from datetime import date, datetime, time, timedelta from decimal import Decimal from operator import attrgetter, itemgetter from uuid import UUID from django.core.exceptions import FieldError from django.db import connection from django.db.models import ( BinaryField, BooleanField, Case, ...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
true
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/multiple_database/models.py
tests/multiple_database/models.py
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 = models.Fore...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/multiple_database/__init__.py
tests/multiple_database/__init__.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/multiple_database/tests.py
tests/multiple_database/tests.py
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...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
true
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/multiple_database/routers.py
tests/multiple_database/routers.py
from django.db import DEFAULT_DB_ALIAS class TestRouter: """ Vaguely behave like primary/replica, but the databases aren't assumed to propagate changes. """ def db_for_read(self, model, instance=None, **hints): if instance: return instance._state.db or "other" return "...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/many_to_many/models.py
tests/many_to_many/models.py
""" Many-to-many relationships To define a many-to-many relationship, use ``ManyToManyField()``. In this example, an ``Article`` can be published in multiple ``Publication`` objects, and a ``Publication`` has multiple ``Article`` objects. """ from django.db import models class Publication(models.Model): title ...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/many_to_many/__init__.py
tests/many_to_many/__init__.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/many_to_many/tests.py
tests/many_to_many/tests.py
from unittest import mock from django.db import connection, transaction from django.db.models import FETCH_PEERS from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature from .models import ( Article, InheritedArticleA, InheritedArticleB, NullablePublicationThrough, NullableTargetArt...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/m2m_and_m2o/models.py
tests/m2m_and_m2o/models.py
""" Many-to-many and many-to-one relationships to the same table Make sure to set ``related_name`` if you use relationships to the same table. """ from django.db import models class User(models.Model): username = models.CharField(max_length=20) class Issue(models.Model): num = models.IntegerField() cc...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/m2m_and_m2o/__init__.py
tests/m2m_and_m2o/__init__.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/m2m_and_m2o/tests.py
tests/m2m_and_m2o/tests.py
from django.db.models import Q from django.test import TestCase from .models import Issue, StringReferenceModel, User class RelatedObjectTests(TestCase): def test_related_objects_have_name_attribute(self): for field_name in ("test_issue_client", "test_issue_cc"): obj = User._meta.get_field(fi...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/template_loader/__init__.py
tests/template_loader/__init__.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/template_loader/tests.py
tests/template_loader/tests.py
from django.template import TemplateDoesNotExist from django.template.loader import get_template, render_to_string, select_template from django.test import SimpleTestCase, override_settings from django.test.client import RequestFactory @override_settings( TEMPLATES=[ { "BACKEND": "django.templ...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/get_object_or_404/models.py
tests/get_object_or_404/models.py
""" DB-API Shortcuts ``get_object_or_404()`` is a shortcut function to be used in view functions for performing a ``get()`` lookup and raising a ``Http404`` exception if a ``DoesNotExist`` exception was raised during the ``get()`` call. ``get_list_or_404()`` is a shortcut function to be used in view functions for per...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/get_object_or_404/__init__.py
tests/get_object_or_404/__init__.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/get_object_or_404/tests.py
tests/get_object_or_404/tests.py
from django.db.models import Q from django.http import Http404 from django.shortcuts import get_list_or_404, get_object_or_404 from django.test import TestCase from .models import Article, Author class GetObjectOr404Tests(TestCase): def test_get_object_or_404(self): a1 = Author.objects.create(name="Brave...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/empty_models/models.py
tests/empty_models/models.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false