[4.2.x] Refs #33476 -- Applied Black's 2023 stable style.

Black 23.1.0 is released which, as the first release of the year,
introduces the 2023 stable style. This incorporates most of last year's
preview style.

https://github.com/psf/black/releases/tag/23.1.0

Backport of 097e3a70c1 from main
This commit is contained in:
David Smith 2023-02-01 07:13:39 +00:00 committed by Mariusz Felisiak
parent 8a7b22d4a6
commit 80aae83439
240 changed files with 37 additions and 281 deletions

View File

@ -1,6 +1,6 @@
repos:
- repo: https://github.com/psf/black
rev: 22.10.0
rev: 23.1.0
hooks:
- id: black
exclude: \.py-tpl$

View File

@ -4,7 +4,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
("contenttypes", "__first__"),

View File

@ -3,7 +3,6 @@ from django.utils import timezone
class Migration(migrations.Migration):
dependencies = [
("admin", "0001_initial"),
]

View File

@ -2,7 +2,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("admin", "0002_logentry_remove_auto_add"),
]

View File

@ -982,7 +982,7 @@ class ModelAdmin(BaseModelAdmin):
base_action_names = {name for _, name, _ in base_actions}
# Gather actions from the admin site first
for (name, func) in self.admin_site.actions:
for name, func in self.admin_site.actions:
if name in base_action_names:
continue
description = self._get_action_description(func, name)
@ -1106,6 +1106,7 @@ class ModelAdmin(BaseModelAdmin):
Return a tuple containing a queryset to implement the search
and a boolean indicating if the results may contain duplicates.
"""
# Apply keyword searches.
def construct_search(field_name):
if field_name.startswith("^"):

View File

@ -17,7 +17,6 @@ class CSPMiddleware(MiddlewareMixin):
@modify_settings(MIDDLEWARE={"append": "django.contrib.admin.tests.CSPMiddleware"})
class AdminSeleniumTestCase(SeleniumTestCase, StaticLiveServerTestCase):
available_apps = [
"django.contrib.admin",
"django.contrib.auth",

View File

@ -148,7 +148,7 @@ class ViewIndexView(BaseAdminDocsView):
view_functions = extract_views_from_urlpatterns(url_resolver.url_patterns)
except ImproperlyConfigured:
view_functions = []
for (func, regex, namespace, name) in view_functions:
for func, regex, namespace, name in view_functions:
views.append(
{
"full_name": get_view_name(func),

View File

@ -5,7 +5,6 @@ from django.utils import timezone
class Migration(migrations.Migration):
dependencies = [
("contenttypes", "__first__"),
]

View File

@ -2,7 +2,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("auth", "0001_initial"),
]

View File

@ -2,7 +2,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("auth", "0002_alter_permission_name_max_length"),
]

View File

@ -3,7 +3,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("auth", "0003_alter_user_email_max_length"),
]

View File

@ -2,7 +2,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("auth", "0004_alter_user_username_opts"),
]

View File

@ -2,7 +2,6 @@ from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("auth", "0005_alter_user_last_login_null"),
("contenttypes", "0002_remove_content_type_name"),

View File

@ -3,7 +3,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("auth", "0006_require_contenttypes_0002"),
]

View File

@ -3,7 +3,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("auth", "0007_alter_validators_add_error_messages"),
]

View File

@ -2,7 +2,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("auth", "0008_alter_user_username_max_length"),
]

View File

@ -2,7 +2,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("auth", "0009_alter_user_last_name_max_length"),
]

View File

@ -2,7 +2,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("auth", "0011_update_proxy_permissions"),
]

View File

@ -3,7 +3,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = []
operations = [

View File

@ -13,7 +13,6 @@ def add_legacy_name(apps, schema_editor):
class Migration(migrations.Migration):
dependencies = [
("contenttypes", "0001_initial"),
]

View File

@ -2,7 +2,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("sites", "0001_initial"),
]

View File

@ -97,6 +97,7 @@ class OpenLayersWidget(Textarea):
def map_options(self):
"""Build the map options hash for the OpenLayers template."""
# JavaScript construction utilities for the Bounds and Projection.
def ol_bounds(extent):
return "new OpenLayers.Bounds(%s)" % extent

View File

@ -54,7 +54,6 @@ class SDORelate(SpatialOperator):
class OracleOperations(BaseSpatialOperations, DatabaseOperations):
name = "oracle"
oracle = True
disallowed_aggregates = (models.Collect, models.Extent3D, models.MakeLine)

View File

@ -20,7 +20,6 @@ from django.utils.encoding import force_bytes, force_str
class GEOSGeometryBase(GEOSBase):
_GEOS_CLASSES = None
ptr_type = GEOM_PTR

View File

@ -2,7 +2,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("sites", "0001_initial"),
]

View File

@ -2,7 +2,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("redirects", "0001_initial"),
]

View File

@ -3,7 +3,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = []
operations = [

View File

@ -58,7 +58,6 @@ def index(
content_type="application/xml",
sitemap_url_name="django.contrib.sitemaps.views.sitemap",
):
req_protocol = request.scheme
req_site = get_current_site(request)
@ -108,7 +107,6 @@ def sitemap(
template_name="sitemap.xml",
content_type="application/xml",
):
req_protocol = request.scheme
req_site = get_current_site(request)

View File

@ -4,7 +4,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = []
operations = [

View File

@ -3,7 +3,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("sites", "0001_initial"),
]

View File

@ -77,7 +77,6 @@ class SiteManager(models.Manager):
class Site(models.Model):
domain = models.CharField(
_("domain name"),
max_length=100,

View File

@ -40,7 +40,6 @@ class BaseDatabaseCache(BaseCache):
class DatabaseCache(BaseDatabaseCache):
# This class uses cursors provided by the database connection. This means
# it reads expiration values as aware or naive datetimes, depending on the
# value of USE_TZ and whether the database supports time zones. The ORM's

View File

@ -193,7 +193,7 @@ class Command(BaseCommand):
# There is no need to sort dependencies when natural foreign
# keys are not used.
models = []
for (app_config, model_list) in app_list.items():
for app_config, model_list in app_list.items():
if model_list is None:
models.extend(app_config.get_models())
else:

View File

@ -60,7 +60,6 @@ class Command(BaseCommand):
)
def handle(self, **options):
self.verbosity = options["verbosity"]
self.interactive = options["interactive"]
app_label = options["app_label"]

View File

@ -158,7 +158,6 @@ class TemplateCommand(BaseCommand):
prefix_length = len(template_dir) + 1
for root, dirs, files in os.walk(template_dir):
path_rest = root[prefix_length:]
relative_dir = path_rest.replace(base_name, name)
if relative_dir:

View File

@ -128,8 +128,7 @@ def Deserializer(
field_names = field_names_cache[Model]
# Handle each field
for (field_name, field_value) in d["fields"].items():
for field_name, field_value in d["fields"].items():
if ignorenonexistent and field_name not in field_names:
# skip fields no longer on model
continue

View File

@ -116,6 +116,7 @@ class BaseDatabaseCreation:
Designed only for test runner usage; will not handle large
amounts of data.
"""
# Iteratively return every object for all models to serialize.
def get_objects():
from django.db.migrations.loader import MigrationLoader

View File

@ -269,6 +269,7 @@ class BaseDatabaseOperations:
exists for database backends to provide a better implementation
according to their own quoting schemes.
"""
# Convert params to contain string values.
def to_string(s):
return force_str(s, strings_only=True, errors="replace")

View File

@ -4,7 +4,6 @@ from django.db.models.constants import LOOKUP_SEP
class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
sql_rename_table = "RENAME TABLE %(old_table)s TO %(new_table)s"
sql_alter_column_null = "MODIFY %(column)s %(type)s NULL"

View File

@ -11,7 +11,6 @@ from django.utils.duration import duration_iso_string
class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
sql_create_column = "ALTER TABLE %(table)s ADD %(column)s %(definition)s"
sql_alter_column_type = "MODIFY %(column)s %(type)s%(collation)s"
sql_alter_column_null = "MODIFY %(column)s NULL"

View File

@ -476,7 +476,6 @@ if is_psycopg3:
return self.cursor.copy(statement)
else:
Cursor = psycopg2.extensions.cursor
class CursorDebugWrapper(BaseCursorDebugWrapper):

View File

@ -5,7 +5,6 @@ from django.db.backends.utils import strip_quotes
class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
# Setting all constraints to IMMEDIATE to allow changing data in the same
# transaction.
sql_update_with_default = (

View File

@ -11,7 +11,6 @@ from django.db.transaction import atomic
class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
sql_delete_table = "DROP TABLE %(table)s"
sql_create_fk = None
sql_create_inline_fk = (
@ -191,6 +190,7 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
4. Rename the "new__app_model" table to "app_model"
5. Restore any index of the previous "app_model" table.
"""
# Self-referential fields must be recreated rather than copied from
# the old model to ensure their remote_field.field_name doesn't refer
# to an altered field.

View File

@ -95,7 +95,6 @@ class CursorWrapper:
class CursorDebugWrapper(CursorWrapper):
# XXX callproc isn't instrumented at this time.
def execute(self, sql, params=None):

View File

@ -400,7 +400,7 @@ class RenameModel(ModelOperation):
fields = zip(
old_model._meta.local_many_to_many, new_model._meta.local_many_to_many
)
for (old_field, new_field) in fields:
for old_field, new_field in fields:
# Skip self-referential fields as these are renamed above.
if (
new_field.model == new_field.related_model
@ -505,7 +505,7 @@ class AlterModelTable(ModelOptionOperation):
new_model._meta.db_table,
)
# Rename M2M fields whose name is based on this model's db_table
for (old_field, new_field) in zip(
for old_field, new_field in zip(
old_model._meta.local_many_to_many, new_model._meta.local_many_to_many
):
if new_field.remote_field.through._meta.auto_created:

View File

@ -1108,7 +1108,6 @@ class Star(Expression):
class Col(Expression):
contains_column_references = True
possibly_multivalued = False

View File

@ -222,7 +222,6 @@ class FileDescriptor(DeferredAttribute):
class FileField(Field):
# The class to wrap instance attributes in. Accessing the file object off
# the instance will always return an instance of attr_class.
attr_class = FieldFile

View File

@ -344,7 +344,6 @@ class RelatedField(FieldCacheMixin, Field):
return None
def contribute_to_class(self, cls, name, private_only=False, **kwargs):
super().contribute_to_class(cls, name, private_only=private_only, **kwargs)
self.opts = cls._meta
@ -541,7 +540,6 @@ class ForeignObject(RelatedField):
swappable=True,
**kwargs,
):
if rel is None:
rel = self.rel_class(
self,
@ -1616,7 +1614,6 @@ class ManyToManyField(RelatedField):
(source_field_name, source),
(target_field_name, target),
):
possible_field_names = []
for f in through._meta.fields:
if (

View File

@ -360,7 +360,6 @@ class TruncBase(TimezoneMixin, Transform):
class Trunc(TruncBase):
# RemovedInDjango50Warning: when the deprecation ends, remove is_dst
# argument.
def __init__(

View File

@ -528,6 +528,7 @@ class Options:
combined with filtering of field properties is the public API for
obtaining this field list.
"""
# For legacy reasons, the fields property should only contain forward
# fields that are not private or with a m2m cardinality. Therefore we
# pass these three filters as filters to the generator.

View File

@ -2123,7 +2123,7 @@ class RawQuerySet:
"""
columns = self.query.get_columns()
# Adjust any column names which don't match field names
for (query_name, model_name) in self.translations.items():
for query_name, model_name in self.translations.items():
# Ignore translations for nonexistent column names
try:
index = columns.index(query_name)

View File

@ -489,7 +489,6 @@ class ClearableFileInput(FileInput):
if not self.is_required and CheckboxInput().value_from_datadict(
data, files, self.clear_checkbox_name(name)
):
if upload:
# If the user contradicts themselves (uploads a new file AND
# checks the "clear" checkbox), we return a unique marker

View File

@ -5,7 +5,6 @@ from django.utils.functional import cached_property
class BaseEngine:
# Core methods: engines have to provide their own implementation
# (except for from_string which is optional).

View File

@ -12,7 +12,6 @@ from .base import BaseEngine
class DjangoTemplates(BaseEngine):
app_dirname = "templates"
def __init__(self, params):

View File

@ -9,7 +9,6 @@ from .utils import csrf_input_lazy, csrf_token_lazy
class TemplateStrings(BaseEngine):
app_dirname = "template_strings"
def __init__(self, params):

View File

@ -12,7 +12,6 @@ from .utils import csrf_input_lazy, csrf_token_lazy
class Jinja2(BaseEngine):
app_dirname = "jinja2"
def __init__(self, params):

View File

@ -309,7 +309,6 @@ class IfNode(Node):
def render(self, context):
for condition, nodelist in self.conditions_nodelists:
if condition is not None: # if / elif clause
try:
match = condition.eval(context)

View File

@ -270,7 +270,7 @@ def encode_multipart(boundary, data):
# Each bit of the multipart form data could be either a form value or a
# file, or a *list* of form values and/or files. Remember that HTTP field
# names can be duplicated!
for (key, value) in data.items():
for key, value in data.items():
if value is None:
raise TypeError(
"Cannot encode None for key '%s' as POST data. Did you mean "

View File

@ -659,7 +659,6 @@ class DiscoverRunner:
logger=None,
**kwargs,
):
self.pattern = pattern
self.top_level = top_level
self.verbosity = verbosity

View File

@ -290,7 +290,6 @@ class _AssertFormErrorDeprecationHelper:
class SimpleTestCase(unittest.TestCase):
# The class we'll use for the test client self.client.
# Can be overridden in derived classes.
client_class = Client
@ -800,7 +799,6 @@ class SimpleTestCase(unittest.TestCase):
)
def _get_template_used(self, response, template_name, msg_prefix, method_name):
if response is None and template_name is None:
raise TypeError("response and/or template_name argument must be provided")
@ -1157,7 +1155,6 @@ class SimpleTestCase(unittest.TestCase):
class TransactionTestCase(SimpleTestCase):
# Subclasses can ask for resetting of auto increment sequence before each
# test case
reset_sequences = False

View File

@ -78,7 +78,7 @@ def patch_cache_control(response, **kwargs):
elif "public" in cc and "private" in kwargs:
del cc["public"]
for (k, v) in kwargs.items():
for k, v in kwargs.items():
directive = k.replace("_", "-")
if directive == "no-cache":
# no-cache supports multiple field names.

View File

@ -57,6 +57,7 @@ def method_decorator(decorator, name=""):
"""
Convert a function decorator into a method decorator
"""
# 'obj' can be a class or a function. If 'obj' is a function at the time it
# is passed to _dec, it will eventually be a method of the class it is
# defined on. If 'obj' is a class, the 'name' is required to be the name

View File

@ -41,7 +41,6 @@ def format(
if isinstance(number, float) and "e" in str(number).lower():
number = Decimal(str(number))
if isinstance(number, Decimal):
if decimal_pos is not None:
# If the provided number is too small to affect any of the visible
# decimal places, consider it equal to '0'.

View File

@ -6,6 +6,7 @@ def no_append_slash(view_func):
Mark a view function as excluded from CommonMiddleware's APPEND_SLASH
redirection.
"""
# view_func.should_append_slash = False would also work, but decorators are
# nicer if they don't have side effects, so return a new function.
@wraps(view_func)

View File

@ -48,6 +48,7 @@ uses the csrf_token template tag, or the CsrfViewMiddleware is used.
def csrf_exempt(view_func):
"""Mark a view function as being exempt from the CSRF view protection."""
# view_func.csrf_exempt = True would also work, but decorators are nicer
# if they don't have side effects, so return a new function.
@wraps(view_func)

View File

@ -1642,7 +1642,6 @@ class GetAdminLogTests(TestCase):
@override_settings(ROOT_URLCONF="admin_changelist.urls")
class SeleniumTests(AdminSeleniumTestCase):
available_apps = ["admin_changelist"] + AdminSeleniumTestCase.available_apps
def setUp(self):

View File

@ -1492,7 +1492,6 @@ class TestVerboseNameInlineForms(TestDataMixin, TestCase):
@override_settings(ROOT_URLCONF="admin_inlines.urls")
class SeleniumTests(AdminSeleniumTestCase):
available_apps = ["admin_inlines"] + AdminSeleniumTestCase.available_apps
def setUp(self):

View File

@ -2,7 +2,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = []

View File

@ -2,7 +2,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = []

View File

@ -2,7 +2,6 @@ from django.core.management import BaseCommand
class Command(BaseCommand):
help = "Test suppress base options command."
requires_system_checks = []
suppressed_base_arguments = {

View File

@ -2378,7 +2378,6 @@ class ExecuteFromCommandLine(SimpleTestCase):
@override_settings(ROOT_URLCONF="admin_scripts.urls")
class StartProject(LiveServerTestCase, AdminScriptTestCase):
available_apps = [
"admin_scripts",
"django.contrib.auth",

View File

@ -99,7 +99,6 @@ class NestedObjectsTests(TestCase):
class UtilsTests(SimpleTestCase):
empty_value = "-empty-"
def test_values_from_lookup_field(self):

View File

@ -5548,7 +5548,6 @@ class PrePopulatedTest(TestCase):
@override_settings(ROOT_URLCONF="admin_views.urls")
class SeleniumTests(AdminSeleniumTestCase):
available_apps = ["admin_views"] + AdminSeleniumTestCase.available_apps
def setUp(self):

View File

@ -75,6 +75,7 @@ class AdminFormfieldForDBFieldTests(SimpleTestCase):
Helper to call formfield_for_dbfield for a given model and field name
and verify that the returned formfield is appropriate.
"""
# Override any settings on the model admin
class MyModelAdmin(admin.ModelAdmin):
pass
@ -339,7 +340,6 @@ class AdminForeignKeyRawIdWidget(TestDataMixin, TestCase):
)
def test_invalid_target_id(self):
for test_str in ("Iñtërnâtiônàlizætiøn", "1234'", -1234):
# This should result in an error message, not a server exception.
response = self.client.post(
@ -908,7 +908,6 @@ class RelatedFieldWidgetWrapperTests(SimpleTestCase):
@override_settings(ROOT_URLCONF="admin_widgets.urls")
class AdminWidgetSeleniumTestCase(AdminSeleniumTestCase):
available_apps = ["admin_widgets"] + AdminSeleniumTestCase.available_apps
def setUp(self):
@ -1108,7 +1107,6 @@ class DateTimePickerSeleniumTests(AdminWidgetSeleniumTestCase):
# Test with every locale
with override_settings(LANGUAGE_CODE=language_code):
# Open a page that has a date picker widget
url = reverse("admin:admin_widgets_member_change", args=(member.pk,))
self.selenium.get(self.live_server_url + url)

View File

@ -51,7 +51,6 @@ class StackedMixinsView2(
class AccessMixinTests(TestCase):
factory = RequestFactory()
def test_stacked_mixins_success(self):
@ -134,7 +133,6 @@ class AccessMixinTests(TestCase):
class UserPassesTestTests(SimpleTestCase):
factory = RequestFactory()
def _test_redirect(self, view=None, url="/accounts/login/?next=/rand"):
@ -213,7 +211,6 @@ class UserPassesTestTests(SimpleTestCase):
class LoginRequiredMixinTests(TestCase):
factory = RequestFactory()
@classmethod
@ -243,7 +240,6 @@ class LoginRequiredMixinTests(TestCase):
class PermissionsRequiredMixinTests(TestCase):
factory = RequestFactory()
@classmethod

View File

@ -18,7 +18,6 @@ from django.utils.deprecation import RemovedInDjango50Warning
@override_settings(ROOT_URLCONF="auth_tests.urls")
class RemoteUserTest(TestCase):
middleware = "django.contrib.auth.middleware.RemoteUserMiddleware"
backend = "django.contrib.auth.backends.RemoteUserBackend"
header = "REMOTE_USER"

View File

@ -17,7 +17,6 @@ def get_connection():
@override_settings(DEBUG=True)
@unittest.skipUnless(connection.vendor == "mysql", "MySQL tests")
class IsolationLevelTests(TestCase):
read_committed = "read committed"
repeatable_read = "repeatable read"
isolation_values = {

View File

@ -117,7 +117,6 @@ class Tests(TestCase):
@unittest.skipUnless(connection.vendor == "sqlite", "SQLite tests")
@isolate_apps("backends")
class SchemaTests(TransactionTestCase):
available_apps = ["backends"]
def test_autoincrement(self):

View File

@ -247,7 +247,6 @@ class SequenceResetTest(TestCase):
# This test needs to run outside of a transaction, otherwise closing the
# connection would implicitly rollback and cause problems during teardown.
class ConnectionCreatedSignalTest(TransactionTestCase):
available_apps = []
# Unfortunately with sqlite3 the in-memory test database cannot be closed,
@ -297,7 +296,6 @@ class EscapingChecksDebug(EscapingChecks):
class BackendTestCase(TransactionTestCase):
available_apps = ["backends"]
def create_squares_with_executemany(self, args):
@ -597,7 +595,6 @@ class BackendTestCase(TransactionTestCase):
# These tests aren't conditional because it would require differentiating
# between MySQL+InnoDB and MySQL+MYISAM (something we currently can't do).
class FkConstraintsTests(TransactionTestCase):
available_apps = ["backends"]
def setUp(self):
@ -753,7 +750,6 @@ class FkConstraintsTests(TransactionTestCase):
class ThreadTests(TransactionTestCase):
available_apps = ["backends"]
def test_default_connection_thread_local(self):

View File

@ -628,7 +628,6 @@ class ModelLookupTest(TestCase):
class ConcurrentSaveTests(TransactionTestCase):
available_apps = ["basic"]
@skipUnlessDBFeature("test_db_allows_multiple_connections")

14
tests/cache/tests.py vendored
View File

@ -209,7 +209,7 @@ class DummyCacheTests(SimpleTestCase):
"Iñtërnâtiônàlizætiøn": "Iñtërnâtiônàlizætiøn2",
"ascii2": {"x": 1},
}
for (key, value) in stuff.items():
for key, value in stuff.items():
with self.subTest(key=key):
cache.set(key, value)
self.assertIsNone(cache.get(key))
@ -514,23 +514,23 @@ class BaseCacheTests:
"ascii2": {"x": 1},
}
# Test `set`
for (key, value) in stuff.items():
for key, value in stuff.items():
with self.subTest(key=key):
cache.set(key, value)
self.assertEqual(cache.get(key), value)
# Test `add`
for (key, value) in stuff.items():
for key, value in stuff.items():
with self.subTest(key=key):
self.assertIs(cache.delete(key), True)
self.assertIs(cache.add(key, value), True)
self.assertEqual(cache.get(key), value)
# Test `set_many`
for (key, value) in stuff.items():
for key, value in stuff.items():
self.assertIs(cache.delete(key), True)
cache.set_many(stuff)
for (key, value) in stuff.items():
for key, value in stuff.items():
with self.subTest(key=key):
self.assertEqual(cache.get(key), value)
@ -704,6 +704,7 @@ class BaseCacheTests:
portable caching code without making it too difficult to use production
backends with more liberal key rules. Refs #6447.
"""
# mimic custom ``make_key`` method being defined since the default will
# never show the below warnings
def func(key, *args):
@ -802,7 +803,6 @@ class BaseCacheTests:
self.assertIsNone(caches["v2"].get("answer4", version=2))
def test_cache_versioning_add(self):
# add, default version = 1, but manually override version = 2
self.assertIs(cache.add("answer1", 42, version=2), True)
self.assertIsNone(cache.get("answer1", version=1))
@ -1149,7 +1149,6 @@ class BaseCacheTests:
)
)
class DBCacheTests(BaseCacheTests, TransactionTestCase):
available_apps = ["cache"]
def setUp(self):
@ -1468,7 +1467,6 @@ redis_excluded_caches = {"cull", "zero_cull"}
class BaseMemcachedTests(BaseCacheTests):
# By default it's assumed that the client doesn't clean up connections
# properly, in which case the backend must do so after each request.
should_disconnect_on_close = True

View File

@ -2,7 +2,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
operations = [
migrations.CreateModel(
"Foo",

View File

@ -24,7 +24,6 @@ def assert_foo_contenttype_not_cached(apps, schema_editor):
class Migration(migrations.Migration):
dependencies = [
("contenttypes_tests", "0001_initial"),
]

View File

@ -45,7 +45,6 @@ MASKED_TEST_SECRET2 = "2JgchWvM1tpxT2lfz9aydoXW9yT1DN3NdLiejYxOOlzzV4nhBbYqmqZYb
class CsrfFunctionTestMixin:
# This method depends on _unmask_cipher_token() being correct.
def assertMaskedSecretCorrect(self, masked_secret, secret):
"""Test that a string is a valid masked version of a secret."""

View File

@ -2,7 +2,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("db_functions", "0001_setup_extensions"),
]

View File

@ -45,7 +45,6 @@ from .models import (
# get two connections to an in-memory database.
@skipUnlessDBFeature("test_db_allows_multiple_connections")
class DeleteLockingTest(TransactionTestCase):
available_apps = ["delete_regress"]
def setUp(self):
@ -126,7 +125,6 @@ class DeleteCascadeTests(TestCase):
class DeleteCascadeTransactionTests(TransactionTestCase):
available_apps = ["delete_regress"]
def test_inheritance(self):

View File

@ -1167,7 +1167,6 @@ class NonexistentFixtureTests(TestCase):
class FixtureTransactionTests(DumpDataAssertMixin, TransactionTestCase):
available_apps = [
"fixtures",
"django.contrib.sites",

View File

@ -935,7 +935,6 @@ class M2MNaturalKeyFixtureTests(TestCase):
class TestTicket11101(TransactionTestCase):
available_apps = ["fixtures_regress"]
@skipUnlessDBFeature("supports_transactions")

View File

@ -93,7 +93,6 @@ class MultiColumnFKTests(TestCase):
self.assertIs(membership.person, self.bob)
def test_query_filters_correctly(self):
# Creating a to valid memberships
Membership.objects.create(
membership_country_id=self.usa.id,
@ -120,7 +119,6 @@ class MultiColumnFKTests(TestCase):
)
def test_reverse_query_filters_correctly(self):
timemark = datetime.datetime.now(tz=datetime.timezone.utc).replace(tzinfo=None)
timedelta = datetime.timedelta(days=1)

View File

@ -143,7 +143,6 @@ class FloatFieldTest(FormFieldAssertionsMixin, SimpleTestCase):
@override_settings(ROOT_URLCONF="forms_tests.urls")
class FloatFieldHTMLTest(SeleniumTestCase):
available_apps = ["forms_tests"]
def test_float_field_rendering_passes_client_side_validation(self):

View File

@ -7,7 +7,6 @@ from ..models import Article
@override_settings(ROOT_URLCONF="forms_tests.urls")
class LiveWidgetTests(AdminSeleniumTestCase):
available_apps = ["forms_tests"] + AdminSeleniumTestCase.available_apps
def test_textarea_trailing_newlines(self):

View File

@ -300,7 +300,6 @@ class ViewTest(SimpleTestCase):
@override_settings(ROOT_URLCONF="generic_views.urls")
class TemplateViewTest(SimpleTestCase):
rf = RequestFactory()
def _assert_about(self, response):
@ -427,7 +426,6 @@ class TemplateViewTest(SimpleTestCase):
@override_settings(ROOT_URLCONF="generic_views.urls")
class RedirectViewTest(SimpleTestCase):
rf = RequestFactory()
def test_no_url(self):

View File

@ -330,7 +330,6 @@ class NonModel:
class NonModelDetail(generic.DetailView):
template_name = "generic_views/detail.html"
model = NonModel

View File

@ -262,7 +262,6 @@ class GetOrCreateTestsWithManualPKs(TestCase):
class GetOrCreateTransactionTests(TransactionTestCase):
available_apps = ["get_or_create"]
def test_get_or_create_integrityerror(self):

View File

@ -651,7 +651,7 @@ class GeoQuerySetTest(TestCase):
self.assertEqual(len(line), ref_points.count())
# Compare pairs of manually sorted points, as the default ordering is
# flaky.
for (point, ref_city) in zip(sorted(line), sorted(ref_points)):
for point, ref_city in zip(sorted(line), sorted(ref_points)):
point_x, point_y = point
self.assertAlmostEqual(point_x, ref_city.x, 5),
self.assertAlmostEqual(point_y, ref_city.y, 5),

View File

@ -1292,6 +1292,7 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
def test_pickle(self):
"Testing pickling and unpickling support."
# Creating a list of test geometries for pickling,
# and setting the SRID on some of them.
def get_geoms(lst, srid=None):

View File

@ -2,7 +2,6 @@ from django.contrib.gis.db import models
class AllOGRFields(models.Model):
f_decimal = models.FloatField()
f_float = models.FloatField()
f_int = models.IntegerField()

View File

@ -233,6 +233,7 @@ class LayerMapTest(TestCase):
def test_test_fid_range_step(self):
"Tests the `fid_range` keyword and the `step` keyword of .save()."
# Function for clearing out all the counties before testing.
def clear_counties():
County.objects.all().delete()

View File

@ -4,7 +4,6 @@ from django.db.models import deletion
class Migration(migrations.Migration):
dependencies = [
("rasterapp", "0001_setup_extensions"),
]

View File

@ -95,7 +95,6 @@ class HandlerTests(SimpleTestCase):
@override_settings(ROOT_URLCONF="handlers.urls", MIDDLEWARE=[])
class TransactionsPerRequestTests(TransactionTestCase):
available_apps = []
def test_no_transaction(self):

Some files were not shown because too many files have changed in this diff Show More