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
This commit is contained in:
David Smith 2023-02-01 07:13:39 +00:00 committed by Mariusz Felisiak
parent 8c660fb592
commit 097e3a70c1
238 changed files with 36 additions and 280 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -54,7 +54,6 @@ class SDORelate(SpatialOperator):
class OracleOperations(BaseSpatialOperations, DatabaseOperations): class OracleOperations(BaseSpatialOperations, DatabaseOperations):
name = "oracle" name = "oracle"
oracle = True oracle = True
disallowed_aggregates = (models.Collect, models.Extent3D, models.MakeLine) 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): class GEOSGeometryBase(GEOSBase):
_GEOS_CLASSES = None _GEOS_CLASSES = None
ptr_type = GEOM_PTR ptr_type = GEOM_PTR

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -40,7 +40,6 @@ class BaseDatabaseCache(BaseCache):
class DatabaseCache(BaseDatabaseCache): class DatabaseCache(BaseDatabaseCache):
# This class uses cursors provided by the database connection. This means # This class uses cursors provided by the database connection. This means
# it reads expiration values as aware or naive datetimes, depending on the # 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 # 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 # There is no need to sort dependencies when natural foreign
# keys are not used. # keys are not used.
models = [] models = []
for (app_config, model_list) in app_list.items(): for app_config, model_list in app_list.items():
if model_list is None: if model_list is None:
models.extend(app_config.get_models()) models.extend(app_config.get_models())
else: else:

View File

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

View File

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

View File

@ -128,8 +128,7 @@ def Deserializer(
field_names = field_names_cache[Model] field_names = field_names_cache[Model]
# Handle each field # 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: if ignorenonexistent and field_name not in field_names:
# skip fields no longer on model # skip fields no longer on model
continue continue

View File

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

View File

@ -269,6 +269,7 @@ class BaseDatabaseOperations:
exists for database backends to provide a better implementation exists for database backends to provide a better implementation
according to their own quoting schemes. according to their own quoting schemes.
""" """
# Convert params to contain string values. # Convert params to contain string values.
def to_string(s): def to_string(s):
return force_str(s, strings_only=True, errors="replace") 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): class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
sql_rename_table = "RENAME TABLE %(old_table)s TO %(new_table)s" sql_rename_table = "RENAME TABLE %(old_table)s TO %(new_table)s"
sql_alter_column_null = "MODIFY %(column)s %(type)s NULL" 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): class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
sql_create_column = "ALTER TABLE %(table)s ADD %(column)s %(definition)s" 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_type = "MODIFY %(column)s %(type)s%(collation)s"
sql_alter_column_null = "MODIFY %(column)s NULL" sql_alter_column_null = "MODIFY %(column)s NULL"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2110,7 +2110,7 @@ class RawQuerySet:
""" """
columns = self.query.get_columns() columns = self.query.get_columns()
# Adjust any column names which don't match field names # 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 # Ignore translations for nonexistent column names
try: try:
index = columns.index(query_name) index = columns.index(query_name)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -309,7 +309,6 @@ class IfNode(Node):
def render(self, context): def render(self, context):
for condition, nodelist in self.conditions_nodelists: for condition, nodelist in self.conditions_nodelists:
if condition is not None: # if / elif clause if condition is not None: # if / elif clause
try: try:
match = condition.eval(context) 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 # 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 # file, or a *list* of form values and/or files. Remember that HTTP field
# names can be duplicated! # names can be duplicated!
for (key, value) in data.items(): for key, value in data.items():
if value is None: if value is None:
raise TypeError( raise TypeError(
"Cannot encode None for key '%s' as POST data. Did you mean " "Cannot encode None for key '%s' as POST data. Did you mean "

View File

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

View File

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

View File

@ -78,7 +78,7 @@ def patch_cache_control(response, **kwargs):
elif "public" in cc and "private" in kwargs: elif "public" in cc and "private" in kwargs:
del cc["public"] del cc["public"]
for (k, v) in kwargs.items(): for k, v in kwargs.items():
directive = k.replace("_", "-") directive = k.replace("_", "-")
if directive == "no-cache": if directive == "no-cache":
# no-cache supports multiple field names. # 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 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 # '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 # 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 # 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(): if isinstance(number, float) and "e" in str(number).lower():
number = Decimal(str(number)) number = Decimal(str(number))
if isinstance(number, Decimal): if isinstance(number, Decimal):
if decimal_pos is not None: if decimal_pos is not None:
# If the provided number is too small to affect any of the visible # If the provided number is too small to affect any of the visible
# decimal places, consider it equal to '0'. # 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 Mark a view function as excluded from CommonMiddleware's APPEND_SLASH
redirection. redirection.
""" """
# view_func.should_append_slash = False would also work, but decorators are # 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. # nicer if they don't have side effects, so return a new function.
@wraps(view_func) @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): def csrf_exempt(view_func):
"""Mark a view function as being exempt from the CSRF view protection.""" """Mark a view function as being exempt from the CSRF view protection."""
# view_func.csrf_exempt = True would also work, but decorators are nicer # view_func.csrf_exempt = True would also work, but decorators are nicer
# if they don't have side effects, so return a new function. # if they don't have side effects, so return a new function.
@wraps(view_func) @wraps(view_func)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -11,7 +11,6 @@ from django.test import Client, TestCase, modify_settings, override_settings
@override_settings(ROOT_URLCONF="auth_tests.urls") @override_settings(ROOT_URLCONF="auth_tests.urls")
class RemoteUserTest(TestCase): class RemoteUserTest(TestCase):
middleware = "django.contrib.auth.middleware.RemoteUserMiddleware" middleware = "django.contrib.auth.middleware.RemoteUserMiddleware"
backend = "django.contrib.auth.backends.RemoteUserBackend" backend = "django.contrib.auth.backends.RemoteUserBackend"
header = "REMOTE_USER" header = "REMOTE_USER"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -43,7 +43,6 @@ MASKED_TEST_SECRET2 = "2JgchWvM1tpxT2lfz9aydoXW9yT1DN3NdLiejYxOOlzzV4nhBbYqmqZYb
class CsrfFunctionTestMixin: class CsrfFunctionTestMixin:
# This method depends on _unmask_cipher_token() being correct. # This method depends on _unmask_cipher_token() being correct.
def assertMaskedSecretCorrect(self, masked_secret, secret): def assertMaskedSecretCorrect(self, masked_secret, secret):
"""Test that a string is a valid masked version of a 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): class Migration(migrations.Migration):
dependencies = [ dependencies = [
("db_functions", "0001_setup_extensions"), ("db_functions", "0001_setup_extensions"),
] ]

View File

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

View File

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

View File

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

View File

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

View File

@ -133,7 +133,6 @@ class FloatFieldTest(FormFieldAssertionsMixin, SimpleTestCase):
@override_settings(ROOT_URLCONF="forms_tests.urls") @override_settings(ROOT_URLCONF="forms_tests.urls")
class FloatFieldHTMLTest(SeleniumTestCase): class FloatFieldHTMLTest(SeleniumTestCase):
available_apps = ["forms_tests"] available_apps = ["forms_tests"]
def test_float_field_rendering_passes_client_side_validation(self): 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") @override_settings(ROOT_URLCONF="forms_tests.urls")
class LiveWidgetTests(AdminSeleniumTestCase): class LiveWidgetTests(AdminSeleniumTestCase):
available_apps = ["forms_tests"] + AdminSeleniumTestCase.available_apps available_apps = ["forms_tests"] + AdminSeleniumTestCase.available_apps
def test_textarea_trailing_newlines(self): def test_textarea_trailing_newlines(self):

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -22,12 +22,10 @@ has_msgfmt = find_command("msgfmt")
@unittest.skipUnless(has_msgfmt, "msgfmt is mandatory for compilation tests") @unittest.skipUnless(has_msgfmt, "msgfmt is mandatory for compilation tests")
class MessageCompilationTests(RunInTmpDirMixin, SimpleTestCase): class MessageCompilationTests(RunInTmpDirMixin, SimpleTestCase):
work_subdir = "commands" work_subdir = "commands"
class PoFileTests(MessageCompilationTests): class PoFileTests(MessageCompilationTests):
LOCALE = "es_AR" LOCALE = "es_AR"
MO_FILE = "locale/%s/LC_MESSAGES/django.mo" % LOCALE MO_FILE = "locale/%s/LC_MESSAGES/django.mo" % LOCALE
MO_FILE_EN = "locale/en/LC_MESSAGES/django.mo" MO_FILE_EN = "locale/en/LC_MESSAGES/django.mo"
@ -83,7 +81,6 @@ class PoFileContentsTests(MessageCompilationTests):
class MultipleLocaleCompilationTests(MessageCompilationTests): class MultipleLocaleCompilationTests(MessageCompilationTests):
MO_FILE_HR = None MO_FILE_HR = None
MO_FILE_FR = None MO_FILE_FR = None
@ -108,7 +105,6 @@ class MultipleLocaleCompilationTests(MessageCompilationTests):
class ExcludedLocaleCompilationTests(MessageCompilationTests): class ExcludedLocaleCompilationTests(MessageCompilationTests):
work_subdir = "exclude" work_subdir = "exclude"
MO_FILE = "locale/%s/LC_MESSAGES/django.mo" MO_FILE = "locale/%s/LC_MESSAGES/django.mo"

View File

@ -33,7 +33,6 @@ requires_gettext_019 = skipIf(
@skipUnless(has_xgettext, "xgettext is mandatory for extraction tests") @skipUnless(has_xgettext, "xgettext is mandatory for extraction tests")
class ExtractorTests(POFileAssertionMixin, RunInTmpDirMixin, SimpleTestCase): class ExtractorTests(POFileAssertionMixin, RunInTmpDirMixin, SimpleTestCase):
work_subdir = "commands" work_subdir = "commands"
PO_FILE = "locale/%s/LC_MESSAGES/django.po" % LOCALE PO_FILE = "locale/%s/LC_MESSAGES/django.po" % LOCALE
@ -593,7 +592,6 @@ class BasicExtractorTests(ExtractorTests):
class JavaScriptExtractorTests(ExtractorTests): class JavaScriptExtractorTests(ExtractorTests):
PO_FILE = "locale/%s/LC_MESSAGES/djangojs.po" % LOCALE PO_FILE = "locale/%s/LC_MESSAGES/djangojs.po" % LOCALE
def test_javascript_literals(self): def test_javascript_literals(self):
@ -706,7 +704,6 @@ class SymlinkExtractorTests(ExtractorTests):
class CopyPluralFormsExtractorTests(ExtractorTests): class CopyPluralFormsExtractorTests(ExtractorTests):
PO_FILE_ES = "locale/es/LC_MESSAGES/django.po" PO_FILE_ES = "locale/es/LC_MESSAGES/django.po"
def test_copy_plural_forms(self): def test_copy_plural_forms(self):
@ -872,7 +869,6 @@ class LocationCommentsTests(ExtractorTests):
class KeepPotFileExtractorTests(ExtractorTests): class KeepPotFileExtractorTests(ExtractorTests):
POT_FILE = "locale/django.pot" POT_FILE = "locale/django.pot"
def test_keep_pot_disabled_by_default(self): def test_keep_pot_disabled_by_default(self):
@ -917,7 +913,6 @@ class MultipleLocaleExtractionTests(ExtractorTests):
class ExcludedLocaleExtractionTests(ExtractorTests): class ExcludedLocaleExtractionTests(ExtractorTests):
work_subdir = "exclude" work_subdir = "exclude"
LOCALES = ["en", "fr", "it"] LOCALES = ["en", "fr", "it"]
@ -972,7 +967,6 @@ class ExcludedLocaleExtractionTests(ExtractorTests):
class CustomLayoutExtractionTests(ExtractorTests): class CustomLayoutExtractionTests(ExtractorTests):
work_subdir = "project_dir" work_subdir = "project_dir"
def test_no_locale_raises(self): def test_no_locale_raises(self):

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