summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2026-01-18 21:26:56 +0100
committerNatalia <124304+nessita@users.noreply.github.com>2026-02-24 20:36:09 -0300
commit090f1da56e663e9f840e307e73b5cf011cb7b061 (patch)
tree2283f72766c60c9462aa718fbe039ffdd3478ad3
parent5f8b8e96a7a43d9e95c2deda3cf0c2855d976c64 (diff)
[6.0.x] Applied Black's 2026 stable style.
https://github.com/psf/black/releases/tag/26.1.0 Backport of 6cff02078799b7c683a0d39630d49ab4fe532e7c from main.
-rw-r--r--.pre-commit-config.yaml4
-rw-r--r--django/contrib/gis/gdal/envelope.py2
-rw-r--r--django/contrib/gis/geos/mutable_list.py1
-rw-r--r--django/contrib/gis/measure.py1
-rw-r--r--django/contrib/gis/utils/layermapping.py1
-rw-r--r--django/core/checks/__init__.py1
-rw-r--r--django/core/management/commands/flush.py7
-rw-r--r--django/db/backends/mysql/base.py6
-rw-r--r--django/db/backends/mysql/introspection.py6
-rw-r--r--django/db/backends/oracle/introspection.py6
-rw-r--r--django/db/backends/postgresql/introspection.py6
-rw-r--r--django/db/backends/sqlite3/introspection.py6
-rw-r--r--django/db/models/__init__.py1
-rw-r--r--django/template/__init__.py1
-rw-r--r--django/test/runner.py24
-rw-r--r--docs/_ext/djangodocs.py11
-rw-r--r--docs/howto/custom-template-tags.txt1
-rw-r--r--docs/ref/contrib/gis/gdal.txt6
-rw-r--r--docs/ref/contrib/postgres/constraints.txt1
-rw-r--r--docs/topics/db/sql.txt7
-rw-r--r--docs/topics/tasks.txt2
-rw-r--r--tests/auth_tests/test_forms.py10
-rw-r--r--tests/backends/mysql/test_introspection.py12
-rw-r--r--tests/csrf_tests/views.py6
-rw-r--r--tests/forms_tests/tests/test_forms.py3
-rw-r--r--tests/forms_tests/tests/tests.py3
-rw-r--r--tests/forms_tests/widget_tests/test_clearablefileinput.py24
-rw-r--r--tests/forms_tests/widget_tests/test_multiwidget.py6
-rw-r--r--tests/forms_tests/widget_tests/test_nullbooleanselect.py60
-rw-r--r--tests/forms_tests/widget_tests/test_select.py78
-rw-r--r--tests/forms_tests/widget_tests/test_selectdatewidget.py30
-rw-r--r--tests/forms_tests/widget_tests/test_selectmultiple.py60
-rw-r--r--tests/forms_tests/widget_tests/test_splithiddendatetimewidget.py6
-rw-r--r--tests/generic_relations/test_forms.py3
-rw-r--r--tests/i18n/patterns/tests.py24
-rw-r--r--tests/m2m_through_regress/tests.py3
-rw-r--r--tests/mail/tests.py6
-rw-r--r--tests/migrations/test_multidb.py4
-rw-r--r--tests/model_forms/test_modelchoicefield.py3
-rw-r--r--tests/model_forms/tests.py10
-rw-r--r--tests/postgres_tests/test_array.py6
-rw-r--r--tests/requirements/py3.txt2
-rw-r--r--tests/sitemaps_tests/test_http.py16
-rw-r--r--tests/sphinx/test_github_links.py6
-rw-r--r--tests/test_runner/test_parallel.py2
-rw-r--r--tests/test_utils/tests.py22
46 files changed, 169 insertions, 337 deletions
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 5b559a3160..0f22df80ad 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/psf/black-pre-commit-mirror
- rev: 25.1.0
+ rev: 26.1.0
hooks:
- id: black
exclude: \.py-tpl$
@@ -9,7 +9,7 @@ repos:
hooks:
- id: blacken-docs
additional_dependencies:
- - black==25.1.0
+ - black==26.1.0
files: 'docs/.*\.txt$'
args: ["--rst-literal-block"]
- repo: https://github.com/PyCQA/isort
diff --git a/django/contrib/gis/gdal/envelope.py b/django/contrib/gis/gdal/envelope.py
index f33f9b4df6..b1ed69ca07 100644
--- a/django/contrib/gis/gdal/envelope.py
+++ b/django/contrib/gis/gdal/envelope.py
@@ -128,7 +128,7 @@ class Envelope:
(args[0][0], args[0][1], args[0][0], args[0][1])
)
elif len(args[0]) == 4:
- (minx, miny, maxx, maxy) = args[0]
+ minx, miny, maxx, maxy = args[0]
if minx < self._envelope.MinX:
self._envelope.MinX = minx
if miny < self._envelope.MinY:
diff --git a/django/contrib/gis/geos/mutable_list.py b/django/contrib/gis/geos/mutable_list.py
index 36131fe9ce..0a74bc59e2 100644
--- a/django/contrib/gis/geos/mutable_list.py
+++ b/django/contrib/gis/geos/mutable_list.py
@@ -8,6 +8,7 @@ See also http://static.aryehleib.com/oldsite/MutableLists.html
Author: Aryeh Leib Taurog.
"""
+
from functools import total_ordering
diff --git a/django/contrib/gis/measure.py b/django/contrib/gis/measure.py
index 71dc130ac4..d04fcbcb1e 100644
--- a/django/contrib/gis/measure.py
+++ b/django/contrib/gis/measure.py
@@ -36,6 +36,7 @@ Authors: Robert Coup, Justin Bronn, Riccardo Di Virgilio
Inspired by GeoPy (https://github.com/geopy/geopy)
and Geoff Biggs' PhD work on dimensioned units for robotics.
"""
+
from decimal import Decimal
from functools import total_ordering
diff --git a/django/contrib/gis/utils/layermapping.py b/django/contrib/gis/utils/layermapping.py
index a4cd04dc05..e557378859 100644
--- a/django/contrib/gis/utils/layermapping.py
+++ b/django/contrib/gis/utils/layermapping.py
@@ -6,6 +6,7 @@ vector files (e.g. SHP files) to Geographic-enabled Django models.
For more information, please consult the GeoDjango documentation:
https://docs.djangoproject.com/en/dev/ref/contrib/gis/layermapping/
"""
+
import sys
from decimal import Decimal
from decimal import InvalidOperation as DecimalInvalidOperation
diff --git a/django/core/checks/__init__.py b/django/core/checks/__init__.py
index 2502450cdf..faca2a337d 100644
--- a/django/core/checks/__init__.py
+++ b/django/core/checks/__init__.py
@@ -28,7 +28,6 @@ import django.core.checks.templates # NOQA isort:skip
import django.core.checks.translation # NOQA isort:skip
import django.core.checks.urls # NOQA isort:skip
-
__all__ = [
"CheckMessage",
"Debug",
diff --git a/django/core/management/commands/flush.py b/django/core/management/commands/flush.py
index ff7ee45557..7eb6a4b157 100644
--- a/django/core/management/commands/flush.py
+++ b/django/core/management/commands/flush.py
@@ -57,15 +57,12 @@ class Command(BaseCommand):
)
if interactive:
- confirm = input(
- """You have requested a flush of the database.
+ confirm = input("""You have requested a flush of the database.
This will IRREVERSIBLY DESTROY all data currently in the "%s" database,
and return each table to an empty state.
Are you sure you want to do this?
- Type 'yes' to continue, or 'no' to cancel: """
- % connection.settings_dict["NAME"]
- )
+ Type 'yes' to continue, or 'no' to cancel: """ % connection.settings_dict["NAME"])
else:
confirm = "yes"
diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py
index e83dc106f7..45530c8877 100644
--- a/django/db/backends/mysql/base.py
+++ b/django/db/backends/mysql/base.py
@@ -401,16 +401,14 @@ class DatabaseWrapper(BaseDatabaseWrapper):
# Select some server variables and test if the time zone
# definitions are installed. CONVERT_TZ returns NULL if 'UTC'
# timezone isn't loaded into the mysql.time_zone table.
- cursor.execute(
- """
+ cursor.execute("""
SELECT VERSION(),
@@sql_mode,
@@default_storage_engine,
@@sql_auto_is_null,
@@lower_case_table_names,
CONVERT_TZ('2001-01-01 01:00:00', 'UTC', 'UTC') IS NOT NULL
- """
- )
+ """)
row = cursor.fetchone()
return {
"version": row[0],
diff --git a/django/db/backends/mysql/introspection.py b/django/db/backends/mysql/introspection.py
index 24f773f009..d094601c37 100644
--- a/django/db/backends/mysql/introspection.py
+++ b/django/db/backends/mysql/introspection.py
@@ -79,16 +79,14 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
def get_table_list(self, cursor):
"""Return a list of table and view names in the current database."""
- cursor.execute(
- """
+ cursor.execute("""
SELECT
table_name,
table_type,
table_comment
FROM information_schema.tables
WHERE table_schema = DATABASE()
- """
- )
+ """)
return [
TableInfo(row[0], {"BASE TABLE": "t", "VIEW": "v"}.get(row[1]), row[2])
for row in cursor.fetchall()
diff --git a/django/db/backends/oracle/introspection.py b/django/db/backends/oracle/introspection.py
index 12b9b9a097..27f8be0a1f 100644
--- a/django/db/backends/oracle/introspection.py
+++ b/django/db/backends/oracle/introspection.py
@@ -59,8 +59,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
def get_table_list(self, cursor):
"""Return a list of table and view names in the current database."""
- cursor.execute(
- """
+ cursor.execute("""
SELECT
user_tables.table_name,
't',
@@ -79,8 +78,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
SELECT view_name, 'v', NULL FROM user_views
UNION ALL
SELECT mview_name, 'v', NULL FROM user_mviews
- """
- )
+ """)
return [
TableInfo(self.identifier_converter(row[0]), row[1], row[2])
for row in cursor.fetchall()
diff --git a/django/db/backends/postgresql/introspection.py b/django/db/backends/postgresql/introspection.py
index 82013eb191..e0257f0106 100644
--- a/django/db/backends/postgresql/introspection.py
+++ b/django/db/backends/postgresql/introspection.py
@@ -55,8 +55,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
def get_table_list(self, cursor):
"""Return a list of table and view names in the current database."""
- cursor.execute(
- """
+ cursor.execute("""
SELECT
c.relname,
CASE
@@ -70,8 +69,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
WHERE c.relkind IN ('f', 'm', 'p', 'r', 'v')
AND n.nspname NOT IN ('pg_catalog', 'pg_toast')
AND pg_catalog.pg_table_is_visible(c.oid)
- """
- )
+ """)
return [
TableInfo(*row)
for row in cursor.fetchall()
diff --git a/django/db/backends/sqlite3/introspection.py b/django/db/backends/sqlite3/introspection.py
index 0bbd6f4c59..bb2ccd1054 100644
--- a/django/db/backends/sqlite3/introspection.py
+++ b/django/db/backends/sqlite3/introspection.py
@@ -77,12 +77,10 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
"""Return a list of table and view names in the current database."""
# Skip the sqlite_sequence system table used for autoincrement key
# generation.
- cursor.execute(
- """
+ cursor.execute("""
SELECT name, type FROM sqlite_master
WHERE type in ('table', 'view') AND NOT name='sqlite_sequence'
- ORDER BY name"""
- )
+ ORDER BY name""")
return [TableInfo(row[0], row[1][0]) for row in cursor.fetchall()]
def get_table_description(self, cursor, table_name):
diff --git a/django/db/models/__init__.py b/django/db/models/__init__.py
index ec54b65240..65315933dd 100644
--- a/django/db/models/__init__.py
+++ b/django/db/models/__init__.py
@@ -68,7 +68,6 @@ from django.db.models.fields.related import ( # isort:skip
OneToOneRel,
)
-
__all__ = aggregates_all + constraints_all + enums_all + fields_all + indexes_all
__all__ += [
"ObjectDoesNotExist",
diff --git a/django/template/__init__.py b/django/template/__init__.py
index 92568da793..34f6e105bb 100644
--- a/django/template/__init__.py
+++ b/django/template/__init__.py
@@ -72,5 +72,4 @@ from .library import Library # NOQA isort:skip
# Import the .autoreload module to trigger the registrations of signals.
from . import autoreload # NOQA isort:skip
-
__all__ += ("Template", "Context", "RequestContext")
diff --git a/django/test/runner.py b/django/test/runner.py
index ecae164d7f..d5ca13bdf7 100644
--- a/django/test/runner.py
+++ b/django/test/runner.py
@@ -207,8 +207,7 @@ class RemoteTestResult(unittest.TestResult):
pickle.loads(pickle.dumps(obj))
def _print_unpicklable_subtest(self, test, subtest, pickle_exc):
- print(
- """
+ print("""
Subtest failed:
test: {}
@@ -221,10 +220,7 @@ test runner cannot handle it cleanly. Here is the pickling error:
You should re-run this test with --parallel=1 to reproduce the failure
with a cleaner failure message.
-""".format(
- test, subtest, pickle_exc
- )
- )
+""".format(test, subtest, pickle_exc))
def check_picklable(self, test, err):
# Ensure that sys.exc_info() tuples are picklable. This displays a
@@ -245,8 +241,7 @@ with a cleaner failure message.
pickle_exc_txt, 75, initial_indent=" ", subsequent_indent=" "
)
if tblib is None:
- print(
- """
+ print("""
{} failed:
@@ -258,13 +253,9 @@ parallel test runner to handle this exception cleanly.
In order to see the traceback, you should install tblib:
python -m pip install tblib
-""".format(
- test, original_exc_txt
- )
- )
+""".format(test, original_exc_txt))
else:
- print(
- """
+ print("""
{} failed:
@@ -279,10 +270,7 @@ Here's the error encountered while trying to pickle the exception:
You should re-run this test with the --parallel=1 option to reproduce the
failure and get a correct traceback.
-""".format(
- test, original_exc_txt, pickle_exc_txt
- )
- )
+""".format(test, original_exc_txt, pickle_exc_txt))
raise
def check_subtest_picklable(self, test, subtest):
diff --git a/docs/_ext/djangodocs.py b/docs/_ext/djangodocs.py
index 77e24ff0eb..a979a8e30a 100644
--- a/docs/_ext/djangodocs.py
+++ b/docs/_ext/djangodocs.py
@@ -83,9 +83,7 @@ class VersionDirective(Directive):
if len(self.arguments) > 1:
msg = """Only one argument accepted for directive '{directive_name}::'.
Comments should be provided as content,
- not as an extra argument.""".format(
- directive_name=self.name
- )
+ not as an extra argument.""".format(directive_name=self.name)
raise self.error(msg)
env = self.state.document.settings.env
@@ -255,17 +253,14 @@ def visit_console_html(self, node):
# has been used on it.
self.document._console_directive_used_flag = True
uid = node["uid"]
- self.body.append(
- """\
+ self.body.append("""\
<div class="console-block" id="console-block-%(id)s">
<input class="c-tab-unix" id="c-tab-%(id)s-unix" type="radio" name="console-%(id)s" \
checked>
<label for="c-tab-%(id)s-unix" title="Linux/macOS">&#xf17c/&#xf179</label>
<input class="c-tab-win" id="c-tab-%(id)s-win" type="radio" name="console-%(id)s">
<label for="c-tab-%(id)s-win" title="Windows">&#xf17a</label>
-<section class="c-content-unix" id="c-content-%(id)s-unix">\n"""
- % {"id": uid}
- )
+<section class="c-content-unix" id="c-content-%(id)s-unix">\n""" % {"id": uid})
try:
self.visit_literal_block(node)
except nodes.SkipNode:
diff --git a/docs/howto/custom-template-tags.txt b/docs/howto/custom-template-tags.txt
index b0f59ef981..7deb33ec69 100644
--- a/docs/howto/custom-template-tags.txt
+++ b/docs/howto/custom-template-tags.txt
@@ -601,7 +601,6 @@ implemented using a ``simple_block_tag`` as follows:
from django import template
from django.utils.html import format_html
-
register = template.Library()
diff --git a/docs/ref/contrib/gis/gdal.txt b/docs/ref/contrib/gis/gdal.txt
index f0bb719ca0..cff7b3bedb 100644
--- a/docs/ref/contrib/gis/gdal.txt
+++ b/docs/ref/contrib/gis/gdal.txt
@@ -1078,8 +1078,7 @@ Coordinate System Objects
>>> wgs84 = SpatialReference("EPSG:4326") # EPSG string
>>> proj = "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs "
>>> wgs84 = SpatialReference(proj) # PROJ string
- >>> wgs84 = SpatialReference(
- ... """GEOGCS["WGS 84",
+ >>> wgs84 = SpatialReference("""GEOGCS["WGS 84",
... DATUM["WGS_1984",
... SPHEROID["WGS 84",6378137,298.257223563,
... AUTHORITY["EPSG","7030"]],
@@ -1088,8 +1087,7 @@ Coordinate System Objects
... AUTHORITY["EPSG","8901"]],
... UNIT["degree",0.01745329251994328,
... AUTHORITY["EPSG","9122"]],
- ... AUTHORITY["EPSG","4326"]]"""
- ... ) # OGC WKT
+ ... AUTHORITY["EPSG","4326"]]""") # OGC WKT
.. method:: __getitem__(target)
diff --git a/docs/ref/contrib/postgres/constraints.txt b/docs/ref/contrib/postgres/constraints.txt
index 4d13eddd24..aa8a1a5aed 100644
--- a/docs/ref/contrib/postgres/constraints.txt
+++ b/docs/ref/contrib/postgres/constraints.txt
@@ -101,7 +101,6 @@ are ``Deferrable.DEFERRED`` or ``Deferrable.IMMEDIATE``. For example::
from django.contrib.postgres.fields import RangeOperators
from django.db.models import Deferrable
-
ExclusionConstraint(
name="exclude_overlapping_deferred",
expressions=[
diff --git a/docs/topics/db/sql.txt b/docs/topics/db/sql.txt
index 6aafa2c3b5..bd34df8bb7 100644
--- a/docs/topics/db/sql.txt
+++ b/docs/topics/db/sql.txt
@@ -121,15 +121,14 @@ had ``Person`` data in it, you could easily map it into ``Person`` instances:
.. code-block:: pycon
- >>> Person.objects.raw(
- ... """
+ >>> Person.objects.raw("""
... SELECT first AS first_name,
... last AS last_name,
... bd AS birth_date,
... pk AS id,
... FROM some_other_table
- ... """
- ... )
+ ... """)
+ ...
As long as the names match, the model instances will be created correctly.
diff --git a/docs/topics/tasks.txt b/docs/topics/tasks.txt
index 96deac6dc3..06e83af0bc 100644
--- a/docs/topics/tasks.txt
+++ b/docs/topics/tasks.txt
@@ -207,7 +207,6 @@ To receive the Task context as an argument to your Task function, pass
from django.core.mail import send_mail
from django.tasks import task
-
logger = logging.getLogger(__name__)
@@ -328,7 +327,6 @@ committed to the database, use :func:`transaction.on_commit()
from django.db import transaction
-
with transaction.atomic():
Thing.objects.create(num=1)
transaction.on_commit(partial(my_task.enqueue, thing_num=1))
diff --git a/tests/auth_tests/test_forms.py b/tests/auth_tests/test_forms.py
index 73065adddf..983fe8c39e 100644
--- a/tests/auth_tests/test_forms.py
+++ b/tests/auth_tests/test_forms.py
@@ -1234,7 +1234,7 @@ class PasswordResetFormTest(TestDataMixin, TestCase):
self.assertEqual(len(mail.outbox), 0)
def test_cleaned_data(self):
- (user, username, email) = self.create_dummy_user()
+ user, username, email = self.create_dummy_user()
data = {"email": email}
form = PasswordResetForm(data)
self.assertTrue(form.is_valid())
@@ -1303,7 +1303,7 @@ class PasswordResetFormTest(TestDataMixin, TestCase):
"""
Inactive user cannot receive password reset email.
"""
- (user, username, email) = self.create_dummy_user()
+ user, username, email = self.create_dummy_user()
user.is_active = False
user.save()
form = PasswordResetForm({"email": email})
@@ -1330,7 +1330,7 @@ class PasswordResetFormTest(TestDataMixin, TestCase):
html_email_template_name parameter passed in. Test to ensure original
behavior is unchanged after the parameter was added.
"""
- (user, username, email) = self.create_dummy_user()
+ user, username, email = self.create_dummy_user()
form = PasswordResetForm({"email": email})
self.assertTrue(form.is_valid())
form.save()
@@ -1352,7 +1352,7 @@ class PasswordResetFormTest(TestDataMixin, TestCase):
Test to ensure that a multipart email is sent with both text/plain
and text/html parts.
"""
- (user, username, email) = self.create_dummy_user()
+ user, username, email = self.create_dummy_user()
form = PasswordResetForm({"email": email})
self.assertTrue(form.is_valid())
form.save(
@@ -1382,7 +1382,7 @@ class PasswordResetFormTest(TestDataMixin, TestCase):
@override_settings(EMAIL_BACKEND="mail.custombackend.FailingEmailBackend")
def test_save_send_email_exceptions_are_catched_and_logged(self):
- (user, username, email) = self.create_dummy_user()
+ user, username, email = self.create_dummy_user()
form = PasswordResetForm({"email": email})
self.assertTrue(form.is_valid())
diff --git a/tests/backends/mysql/test_introspection.py b/tests/backends/mysql/test_introspection.py
index a2e2938451..55272989d2 100644
--- a/tests/backends/mysql/test_introspection.py
+++ b/tests/backends/mysql/test_introspection.py
@@ -81,19 +81,16 @@ class TestCrossDatabaseRelations(TestCase):
rel_column_quoted = other_connection.ops.quote_name(rel_column)
try:
with other_connection.cursor() as other_cursor:
- other_cursor.execute(
- f"""
+ other_cursor.execute(f"""
CREATE TABLE {rel_table_quoted} (
id integer AUTO_INCREMENT,
PRIMARY KEY (id)
)
- """
- )
+ """)
with default_connection.cursor() as default_cursor:
# Create table in the default schema with a cross-database
# relation.
- default_cursor.execute(
- f"""
+ default_cursor.execute(f"""
CREATE TABLE {main_table_quoted} (
id integer AUTO_INCREMENT,
{rel_column_quoted} integer NOT NULL,
@@ -101,8 +98,7 @@ class TestCrossDatabaseRelations(TestCase):
FOREIGN KEY ({rel_column_quoted})
REFERENCES {other_schema_quoted}.{rel_table_quoted}(id)
)
- """
- )
+ """)
relations = default_connection.introspection.get_relations(
default_cursor, main_table
)
diff --git a/tests/csrf_tests/views.py b/tests/csrf_tests/views.py
index 2e8f0fcb0f..3949aeaea1 100644
--- a/tests/csrf_tests/views.py
+++ b/tests/csrf_tests/views.py
@@ -62,13 +62,11 @@ def sandwiched_rotate_token_view(request):
def post_form_view(request):
"""Return a POST form (without a token)."""
- return HttpResponse(
- content="""
+ return HttpResponse(content="""
<html>
<body><h1>\u00a1Unicode!<form method="post"><input type="text"></form></body>
</html>
-"""
- )
+""")
def token_view(request):
diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py
index 5b0c4b9a04..04867cdf8e 100644
--- a/tests/forms_tests/tests/test_forms.py
+++ b/tests/forms_tests/tests/test_forms.py
@@ -3664,7 +3664,8 @@ Options: <select multiple name="options" aria-invalid="true" required>
self.assertTrue(f.is_valid())
file1 = SimpleUploadedFile(
- "我隻氣墊船裝滿晒鱔.txt", "मेरी मँडराने वाली नाव सर्पमीनों से भरी ह".encode()
+ "我隻氣墊船裝滿晒鱔.txt",
+ "मेरी मँडराने वाली नाव सर्पमीनों से भरी ह".encode(),
)
f = FileForm(data={}, files={"file1": file1}, auto_id=False)
self.assertHTMLEqual(
diff --git a/tests/forms_tests/tests/tests.py b/tests/forms_tests/tests/tests.py
index 866faaac4d..253e34976a 100644
--- a/tests/forms_tests/tests/tests.py
+++ b/tests/forms_tests/tests/tests.py
@@ -250,7 +250,8 @@ class FormsModelTestCase(TestCase):
def test_unicode_filename(self):
# FileModel with Unicode filename and data.
file1 = SimpleUploadedFile(
- "我隻氣墊船裝滿晒鱔.txt", "मेरी मँडराने वाली नाव सर्पमीनों से भरी ह".encode()
+ "我隻氣墊船裝滿晒鱔.txt",
+ "मेरी मँडराने वाली नाव सर्पमीनों से भरी ह".encode(),
)
f = FileForm(data={}, files={"file1": file1}, auto_id=False)
self.assertTrue(f.is_valid())
diff --git a/tests/forms_tests/widget_tests/test_clearablefileinput.py b/tests/forms_tests/widget_tests/test_clearablefileinput.py
index ae54cc4b5d..31ff1af624 100644
--- a/tests/forms_tests/widget_tests/test_clearablefileinput.py
+++ b/tests/forms_tests/widget_tests/test_clearablefileinput.py
@@ -29,14 +29,12 @@ class ClearableFileInputTest(WidgetTest):
self.widget,
"myfile",
FakeFieldFile(),
- html=(
- """
+ html=("""
Currently: <a href="something">something</a>
<input type="checkbox" name="myfile-clear" id="myfile-clear_id">
<label for="myfile-clear_id">Clear</label><br>
Change: <input type="file" name="myfile">
- """
- ),
+ """),
)
def test_html_escaped(self):
@@ -55,8 +53,7 @@ class ClearableFileInputTest(WidgetTest):
ClearableFileInput(),
"my<div>file",
StrangeFieldFile(),
- html=(
- """
+ html=("""
Currently:
<a href="something?chapter=1&amp;sect=2&amp;copy=3&amp;lang=en">
something&lt;div onclick=&quot;alert(&#x27;oops&#x27;)&quot;&gt;.jpg</a>
@@ -64,8 +61,7 @@ class ClearableFileInputTest(WidgetTest):
id="my&lt;div&gt;file-clear_id">
<label for="my&lt;div&gt;file-clear_id">Clear</label><br>
Change: <input type="file" name="my&lt;div&gt;file">
- """
- ),
+ """),
)
def test_clear_input_renders_only_if_not_required(self):
@@ -79,12 +75,10 @@ class ClearableFileInputTest(WidgetTest):
widget,
"myfile",
FakeFieldFile(),
- html=(
- """
+ html=("""
Currently: <a href="something">something</a> <br>
Change: <input type="file" name="myfile">
- """
- ),
+ """),
)
def test_clear_input_renders_only_if_initial(self):
@@ -143,14 +137,12 @@ class ClearableFileInputTest(WidgetTest):
widget,
"myfile",
[FakeFieldFile()],
- html=(
- """
+ html=("""
Currently: <a href="something">something</a>
<input type="checkbox" name="myfile_0-clear" id="myfile_0-clear_id">
<label for="myfile_0-clear_id">Clear</label><br>
Change: <input type="file" name="myfile_0">
- """
- ),
+ """),
)
def test_clear_input_checked_returns_false(self):
diff --git a/tests/forms_tests/widget_tests/test_multiwidget.py b/tests/forms_tests/widget_tests/test_multiwidget.py
index 40f099e625..5e360e3e92 100644
--- a/tests/forms_tests/widget_tests/test_multiwidget.py
+++ b/tests/forms_tests/widget_tests/test_multiwidget.py
@@ -273,8 +273,7 @@ class MultiWidgetTest(WidgetTest):
widget,
"name",
"some text,JP,2007-04-25 06:24:00",
- html=(
- """
+ html=("""
<input type="text" name="name_0" value="some text">
<select multiple name="name_1">
<option value="J" selected>John</option>
@@ -284,8 +283,7 @@ class MultiWidgetTest(WidgetTest):
</select>
<input type="text" name="name_2_0" value="2007-04-25">
<input type="text" name="name_2_1" value="06:24:00">
- """
- ),
+ """),
)
def test_no_whitespace_between_widgets(self):
diff --git a/tests/forms_tests/widget_tests/test_nullbooleanselect.py b/tests/forms_tests/widget_tests/test_nullbooleanselect.py
index 307ae56579..705ec6ce06 100644
--- a/tests/forms_tests/widget_tests/test_nullbooleanselect.py
+++ b/tests/forms_tests/widget_tests/test_nullbooleanselect.py
@@ -12,13 +12,11 @@ class NullBooleanSelectTest(WidgetTest):
self.widget,
"is_cool",
True,
- html=(
- """<select name="is_cool">
+ html=("""<select name="is_cool">
<option value="unknown">Unknown</option>
<option value="true" selected>Yes</option>
<option value="false">No</option>
- </select>"""
- ),
+ </select>"""),
)
def test_render_false(self):
@@ -26,13 +24,11 @@ class NullBooleanSelectTest(WidgetTest):
self.widget,
"is_cool",
False,
- html=(
- """<select name="is_cool">
+ html=("""<select name="is_cool">
<option value="unknown">Unknown</option>
<option value="true">Yes</option>
<option value="false" selected>No</option>
- </select>"""
- ),
+ </select>"""),
)
def test_render_none(self):
@@ -40,13 +36,11 @@ class NullBooleanSelectTest(WidgetTest):
self.widget,
"is_cool",
None,
- html=(
- """<select name="is_cool">
+ html=("""<select name="is_cool">
<option value="unknown" selected>Unknown</option>
<option value="true">Yes</option>
<option value="false">No</option>
- </select>"""
- ),
+ </select>"""),
)
def test_render_value_unknown(self):
@@ -54,13 +48,11 @@ class NullBooleanSelectTest(WidgetTest):
self.widget,
"is_cool",
"unknown",
- html=(
- """<select name="is_cool">
+ html=("""<select name="is_cool">
<option value="unknown" selected>Unknown</option>
<option value="true">Yes</option>
<option value="false">No</option>
- </select>"""
- ),
+ </select>"""),
)
def test_render_value_true(self):
@@ -68,13 +60,11 @@ class NullBooleanSelectTest(WidgetTest):
self.widget,
"is_cool",
"true",
- html=(
- """<select name="is_cool">
+ html=("""<select name="is_cool">
<option value="unknown">Unknown</option>
<option value="true" selected>Yes</option>
<option value="false">No</option>
- </select>"""
- ),
+ </select>"""),
)
def test_render_value_false(self):
@@ -82,13 +72,11 @@ class NullBooleanSelectTest(WidgetTest):
self.widget,
"is_cool",
"false",
- html=(
- """<select name="is_cool">
+ html=("""<select name="is_cool">
<option value="unknown">Unknown</option>
<option value="true">Yes</option>
<option value="false" selected>No</option>
- </select>"""
- ),
+ </select>"""),
)
def test_render_value_1(self):
@@ -96,13 +84,11 @@ class NullBooleanSelectTest(WidgetTest):
self.widget,
"is_cool",
"1",
- html=(
- """<select name="is_cool">
+ html=("""<select name="is_cool">
<option value="unknown" selected>Unknown</option>
<option value="true">Yes</option>
<option value="false">No</option>
- </select>"""
- ),
+ </select>"""),
)
def test_render_value_2(self):
@@ -110,13 +96,11 @@ class NullBooleanSelectTest(WidgetTest):
self.widget,
"is_cool",
"2",
- html=(
- """<select name="is_cool">
+ html=("""<select name="is_cool">
<option value="unknown">Unknown</option>
<option value="true" selected>Yes</option>
<option value="false">No</option>
- </select>"""
- ),
+ </select>"""),
)
def test_render_value_3(self):
@@ -124,13 +108,11 @@ class NullBooleanSelectTest(WidgetTest):
self.widget,
"is_cool",
"3",
- html=(
- """<select name="is_cool">
+ html=("""<select name="is_cool">
<option value="unknown">Unknown</option>
<option value="true">Yes</option>
<option value="false" selected>No</option>
- </select>"""
- ),
+ </select>"""),
)
def test_l10n(self):
@@ -144,15 +126,13 @@ class NullBooleanSelectTest(WidgetTest):
widget,
"id_bool",
True,
- html=(
- """
+ html=("""
<select name="id_bool">
<option value="unknown">Unbekannt</option>
<option value="true" selected>Ja</option>
<option value="false">Nein</option>
</select>
- """
- ),
+ """),
)
def test_fieldset(self):
diff --git a/tests/forms_tests/widget_tests/test_select.py b/tests/forms_tests/widget_tests/test_select.py
index 6164d0b6b3..884b768086 100644
--- a/tests/forms_tests/widget_tests/test_select.py
+++ b/tests/forms_tests/widget_tests/test_select.py
@@ -31,14 +31,12 @@ class SelectTest(ChoiceWidgetTest):
self.widget(choices=self.beatles),
"beatle",
None,
- html=(
- """<select name="beatle">
+ html=("""<select name="beatle">
<option value="J">John</option>
<option value="P">Paul</option>
<option value="G">George</option>
<option value="R">Ringo</option>
- </select>"""
- ),
+ </select>"""),
)
def test_render_label_value(self):
@@ -50,14 +48,12 @@ class SelectTest(ChoiceWidgetTest):
self.widget(choices=self.beatles),
"beatle",
"John",
- html=(
- """<select name="beatle">
+ html=("""<select name="beatle">
<option value="J">John</option>
<option value="P">Paul</option>
<option value="G">George</option>
<option value="R">Ringo</option>
- </select>"""
- ),
+ </select>"""),
)
def test_render_selected(self):
@@ -70,15 +66,13 @@ class SelectTest(ChoiceWidgetTest):
self.widget(choices=choices),
"choices",
"0",
- html=(
- """<select name="choices">
+ html=("""<select name="choices">
<option value="0" selected>0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="0">extra</option>
- </select>"""
- ),
+ </select>"""),
)
def test_constructor_attrs(self):
@@ -93,13 +87,11 @@ class SelectTest(ChoiceWidgetTest):
widget,
"num",
2,
- html=(
- """<select name="num" class="super" id="super">
+ html=("""<select name="num" class="super" id="super">
<option value="1">1</option>
<option value="2" selected>2</option>
<option value="3">3</option>
- </select>"""
- ),
+ </select>"""),
)
def test_compare_to_str(self):
@@ -110,37 +102,31 @@ class SelectTest(ChoiceWidgetTest):
self.widget(choices=[("1", "1"), ("2", "2"), ("3", "3")]),
"num",
2,
- html=(
- """<select name="num">
+ html=("""<select name="num">
<option value="1">1</option>
<option value="2" selected>2</option>
<option value="3">3</option>
- </select>"""
- ),
+ </select>"""),
)
self.check_html(
self.widget(choices=[(1, 1), (2, 2), (3, 3)]),
"num",
"2",
- html=(
- """<select name="num">
+ html=("""<select name="num">
<option value="1">1</option>
<option value="2" selected>2</option>
<option value="3">3</option>
- </select>"""
- ),
+ </select>"""),
)
self.check_html(
self.widget(choices=[(1, 1), (2, 2), (3, 3)]),
"num",
2,
- html=(
- """<select name="num">
+ html=("""<select name="num">
<option value="1">1</option>
<option value="2" selected>2</option>
<option value="3">3</option>
- </select>"""
- ),
+ </select>"""),
)
def test_choices_constructor(self):
@@ -149,13 +135,11 @@ class SelectTest(ChoiceWidgetTest):
widget,
"num",
2,
- html=(
- """<select name="num">
+ html=("""<select name="num">
<option value="1">1</option>
<option value="2" selected>2</option>
<option value="3">3</option>
- </select>"""
- ),
+ </select>"""),
)
def test_choices_constructor_generator(self):
@@ -173,29 +157,25 @@ class SelectTest(ChoiceWidgetTest):
widget,
"num",
2,
- html=(
- """<select name="num">
+ html=("""<select name="num">
<option value="0">0</option>
<option value="1">1</option>
<option value="2" selected>2</option>
<option value="3">3</option>
<option value="4">4</option>
- </select>"""
- ),
+ </select>"""),
)
self.check_html(
widget,
"num",
3,
- html=(
- """<select name="num">
+ html=("""<select name="num">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3" selected>3</option>
<option value="4">4</option>
- </select>"""
- ),
+ </select>"""),
)
def test_choices_escaping(self):
@@ -204,12 +184,10 @@ class SelectTest(ChoiceWidgetTest):
self.widget(choices=choices),
"escape",
None,
- html=(
- """<select name="escape">
+ html=("""<select name="escape">
<option value="bad">you &amp; me</option>
<option value="good">you &gt; me</option>
- </select>"""
- ),
+ </select>"""),
)
def test_choices_unicode(self):
@@ -217,8 +195,7 @@ class SelectTest(ChoiceWidgetTest):
self.widget(choices=[("ŠĐĆŽćžšđ", "ŠĐabcĆŽćžšđ"), ("ćžšđ", "abcćžšđ")]),
"email",
"ŠĐĆŽćžšđ",
- html=(
- """
+ html=("""
<select name="email">
<option value="\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111"
selected>
@@ -227,8 +204,7 @@ class SelectTest(ChoiceWidgetTest):
<option value="\u0107\u017e\u0161\u0111">abc\u0107\u017e\u0161\u0111
</option>
</select>
- """
- ),
+ """),
)
def test_choices_optgroup(self):
@@ -429,8 +405,7 @@ class SelectTest(ChoiceWidgetTest):
MultiWidget([self.widget(choices=choices), TextInput()]),
"beatle",
["J", "Some text"],
- html=(
- """
+ html=("""
<select name="beatle_0">
<option value="">------</option>
<option value="J" selected>John</option>
@@ -439,8 +414,7 @@ class SelectTest(ChoiceWidgetTest):
<option value="R">Ringo</option>
</select>
<input name="beatle_1" type="text" value="Some text">
- """
- ),
+ """),
)
def test_fieldset(self):
diff --git a/tests/forms_tests/widget_tests/test_selectdatewidget.py b/tests/forms_tests/widget_tests/test_selectdatewidget.py
index 017e90f5f6..b4bbd23c2a 100644
--- a/tests/forms_tests/widget_tests/test_selectdatewidget.py
+++ b/tests/forms_tests/widget_tests/test_selectdatewidget.py
@@ -32,8 +32,7 @@ class SelectDateWidgetTest(WidgetTest):
self.widget,
"mydate",
"",
- html=(
- """
+ html=("""
<select name="mydate_month" id="id_mydate_month">
<option selected value="">---</option>
<option value="1">January</option>
@@ -98,8 +97,7 @@ class SelectDateWidgetTest(WidgetTest):
<option value="2015">2015</option>
<option value="2016">2016</option>
</select>
- """
- ),
+ """),
)
def test_render_none(self):
@@ -116,8 +114,7 @@ class SelectDateWidgetTest(WidgetTest):
self.widget,
"mydate",
"2010-04-15",
- html=(
- """
+ html=("""
<select name="mydate_month" id="id_mydate_month">
<option value="">---</option>
<option value="1">January</option>
@@ -182,8 +179,7 @@ class SelectDateWidgetTest(WidgetTest):
<option value="2015">2015</option>
<option value="2016">2016</option>
</select>
- """
- ),
+ """),
)
def test_render_datetime(self):
@@ -200,8 +196,7 @@ class SelectDateWidgetTest(WidgetTest):
self.widget,
"mydate",
"2010-02-31",
- html=(
- """
+ html=("""
<select name="mydate_month" id="id_mydate_month">
<option value="">---</option>
<option value="1">January</option>
@@ -266,8 +261,7 @@ class SelectDateWidgetTest(WidgetTest):
<option value="2015">2015</option>
<option value="2016">2016</option>
</select>
- """
- ),
+ """),
)
def test_custom_months(self):
@@ -276,8 +270,7 @@ class SelectDateWidgetTest(WidgetTest):
widget,
"mydate",
"",
- html=(
- """
+ html=("""
<select name="mydate_month" id="id_mydate_month">
<option selected value="">---</option>
<option value="1">Jan.</option>
@@ -333,8 +326,7 @@ class SelectDateWidgetTest(WidgetTest):
<option selected value="">---</option>
<option value="2013">2013</option>
</select>
- """
- ),
+ """),
)
def test_selectdate_required(self):
@@ -651,8 +643,7 @@ class SelectDateWidgetTest(WidgetTest):
widget,
"mydate",
"",
- html=(
- """
+ html=("""
<select name="mydate_month" id="id_mydate_month">
<option selected value="">---</option>
<option value="1">January</option>
@@ -706,8 +697,7 @@ class SelectDateWidgetTest(WidgetTest):
<option selected value="">---</option>
<option value="2007">2007</option>
</select>
- """
- ),
+ """),
)
def test_fieldset(self):
diff --git a/tests/forms_tests/widget_tests/test_selectmultiple.py b/tests/forms_tests/widget_tests/test_selectmultiple.py
index c4fbea4490..e3dfee426d 100644
--- a/tests/forms_tests/widget_tests/test_selectmultiple.py
+++ b/tests/forms_tests/widget_tests/test_selectmultiple.py
@@ -18,14 +18,12 @@ class SelectMultipleTest(WidgetTest):
self.widget(choices=self.beatles),
"beatles",
["J"],
- html=(
- """<select multiple name="beatles">
+ html=("""<select multiple name="beatles">
<option value="J" selected>John</option>
<option value="P">Paul</option>
<option value="G">George</option>
<option value="R">Ringo</option>
- </select>"""
- ),
+ </select>"""),
)
def test_render_multiple_selected(self):
@@ -33,14 +31,12 @@ class SelectMultipleTest(WidgetTest):
self.widget(choices=self.beatles),
"beatles",
["J", "P"],
- html=(
- """<select multiple name="beatles">
+ html=("""<select multiple name="beatles">
<option value="J" selected>John</option>
<option value="P" selected>Paul</option>
<option value="G">George</option>
<option value="R">Ringo</option>
- </select>"""
- ),
+ </select>"""),
)
def test_render_none(self):
@@ -52,15 +48,13 @@ class SelectMultipleTest(WidgetTest):
self.widget(choices=(("", "Unknown"),) + self.beatles),
"beatles",
None,
- html=(
- """<select multiple name="beatles">
+ html=("""<select multiple name="beatles">
<option value="">Unknown</option>
<option value="J">John</option>
<option value="P">Paul</option>
<option value="G">George</option>
<option value="R">Ringo</option>
- </select>"""
- ),
+ </select>"""),
)
def test_render_value_label(self):
@@ -72,14 +66,12 @@ class SelectMultipleTest(WidgetTest):
self.widget(choices=self.beatles),
"beatles",
["John"],
- html=(
- """<select multiple name="beatles">
+ html=("""<select multiple name="beatles">
<option value="J">John</option>
<option value="P">Paul</option>
<option value="G">George</option>
<option value="R">Ringo</option>
- </select>"""
- ),
+ </select>"""),
)
def test_multiple_options_same_value(self):
@@ -90,15 +82,13 @@ class SelectMultipleTest(WidgetTest):
self.widget(choices=self.numeric_choices),
"choices",
["0"],
- html=(
- """<select multiple name="choices">
+ html=("""<select multiple name="choices">
<option value="0" selected>0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="0" selected>extra</option>
- </select>"""
- ),
+ </select>"""),
)
def test_multiple_values_invalid(self):
@@ -110,14 +100,12 @@ class SelectMultipleTest(WidgetTest):
self.widget(choices=self.beatles),
"beatles",
["J", "G", "foo"],
- html=(
- """<select multiple name="beatles">
+ html=("""<select multiple name="beatles">
<option value="J" selected>John</option>
<option value="P">Paul</option>
<option value="G" selected>George</option>
<option value="R">Ringo</option>
- </select>"""
- ),
+ </select>"""),
)
def test_compare_string(self):
@@ -127,39 +115,33 @@ class SelectMultipleTest(WidgetTest):
self.widget(choices=choices),
"nums",
[2],
- html=(
- """<select multiple name="nums">
+ html=("""<select multiple name="nums">
<option value="1">1</option>
<option value="2" selected>2</option>
<option value="3">3</option>
- </select>"""
- ),
+ </select>"""),
)
self.check_html(
self.widget(choices=choices),
"nums",
["2"],
- html=(
- """<select multiple name="nums">
+ html=("""<select multiple name="nums">
<option value="1">1</option>
<option value="2" selected>2</option>
<option value="3">3</option>
- </select>"""
- ),
+ </select>"""),
)
self.check_html(
self.widget(choices=choices),
"nums",
[2],
- html=(
- """<select multiple name="nums">
+ html=("""<select multiple name="nums">
<option value="1">1</option>
<option value="2" selected>2</option>
<option value="3">3</option>
- </select>"""
- ),
+ </select>"""),
)
def test_optgroup_select_multiple(self):
@@ -173,15 +155,13 @@ class SelectMultipleTest(WidgetTest):
widget,
"nestchoice",
["outer1", "inner2"],
- html=(
- """<select multiple name="nestchoice">
+ html=("""<select multiple name="nestchoice">
<option value="outer1" selected>Outer 1</option>
<optgroup label="Group &quot;1&quot;">
<option value="inner1">Inner 1</option>
<option value="inner2" selected>Inner 2</option>
</optgroup>
- </select>"""
- ),
+ </select>"""),
)
def test_value_omitted_from_data(self):
diff --git a/tests/forms_tests/widget_tests/test_splithiddendatetimewidget.py b/tests/forms_tests/widget_tests/test_splithiddendatetimewidget.py
index 93ded6ac6d..1083ccc4ec 100644
--- a/tests/forms_tests/widget_tests/test_splithiddendatetimewidget.py
+++ b/tests/forms_tests/widget_tests/test_splithiddendatetimewidget.py
@@ -56,12 +56,10 @@ class SplitHiddenDateTimeWidgetTest(WidgetTest):
self.widget,
"date",
d,
- html=(
- """
+ html=("""
<input type="hidden" name="date_0" value="17.09.2007">
<input type="hidden" name="date_1" value="12:51:00">
- """
- ),
+ """),
)
def test_constructor_different_attrs(self):
diff --git a/tests/generic_relations/test_forms.py b/tests/generic_relations/test_forms.py
index 00df254745..48fe895210 100644
--- a/tests/generic_relations/test_forms.py
+++ b/tests/generic_relations/test_forms.py
@@ -117,8 +117,7 @@ class GenericInlineFormsetTests(TestCase):
<input type="hidden"
name="generic_relations-taggeditem-content_type-object_id-1-id"
id="id_generic_relations-taggeditem-content_type-object_id-1-id"></p>
- """
- % tagged_item_id,
+ """ % tagged_item_id,
)
lion = Animal.objects.create(common_name="Lion", latin_name="Panthera leo")
formset = GenericFormSet(instance=lion, prefix="x")
diff --git a/tests/i18n/patterns/tests.py b/tests/i18n/patterns/tests.py
index bd329e69f8..1eb6d3d60f 100644
--- a/tests/i18n/patterns/tests.py
+++ b/tests/i18n/patterns/tests.py
@@ -484,51 +484,43 @@ class URLTagTests(URLTestCaseBase):
"""
def test_strings_only(self):
- t = Template(
- """{% load i18n %}
+ t = Template("""{% load i18n %}
{% language 'nl' %}{% url 'no-prefix-translated' %}{% endlanguage %}
- {% language 'pt-br' %}{% url 'no-prefix-translated' %}{% endlanguage %}"""
- )
+ {% language 'pt-br' %}{% url 'no-prefix-translated' %}{% endlanguage %}""")
self.assertEqual(
t.render(Context({})).strip().split(), ["/vertaald/", "/traduzidos/"]
)
def test_context(self):
ctx = Context({"lang1": "nl", "lang2": "pt-br"})
- tpl = Template(
- """{% load i18n %}
+ tpl = Template("""{% load i18n %}
{% language lang1 %}{% url 'no-prefix-translated' %}{% endlanguage %}
- {% language lang2 %}{% url 'no-prefix-translated' %}{% endlanguage %}"""
- )
+ {% language lang2 %}{% url 'no-prefix-translated' %}{% endlanguage %}""")
self.assertEqual(
tpl.render(ctx).strip().split(), ["/vertaald/", "/traduzidos/"]
)
def test_args(self):
- tpl = Template(
- """
+ tpl = Template("""
{% load i18n %}
{% language 'nl' %}
{% url 'no-prefix-translated-slug' 'apo' %}{% endlanguage %}
{% language 'pt-br' %}
{% url 'no-prefix-translated-slug' 'apo' %}{% endlanguage %}
- """
- )
+ """)
self.assertEqual(
tpl.render(Context({})).strip().split(),
["/vertaald/apo/", "/traduzidos/apo/"],
)
def test_kwargs(self):
- tpl = Template(
- """
+ tpl = Template("""
{% load i18n %}
{% language 'nl' %}
{% url 'no-prefix-translated-slug' slug='apo' %}{% endlanguage %}
{% language 'pt-br' %}
{% url 'no-prefix-translated-slug' slug='apo' %}{% endlanguage %}
- """
- )
+ """)
self.assertEqual(
tpl.render(Context({})).strip().split(),
["/vertaald/apo/", "/traduzidos/apo/"],
diff --git a/tests/m2m_through_regress/tests.py b/tests/m2m_through_regress/tests.py
index eae151546b..77a15a574b 100644
--- a/tests/m2m_through_regress/tests.py
+++ b/tests/m2m_through_regress/tests.py
@@ -113,8 +113,7 @@ class M2MThroughSerializationTestCase(TestCase):
<field type="CharField" name="name">Roll</field>
</object>
</django-objects>
- """.strip()
- % pks,
+ """.strip() % pks,
)
diff --git a/tests/mail/tests.py b/tests/mail/tests.py
index 1dba83eb8e..851d1c371c 100644
--- a/tests/mail/tests.py
+++ b/tests/mail/tests.py
@@ -1087,15 +1087,13 @@ class MailTests(MailTestsMixin, SimpleTestCase):
Attaching a message that uses 8bit content transfer encoding for
non-ASCII characters should not raise a UnicodeEncodeError (#36119).
"""
- attachment = dedent(
- """\
+ attachment = dedent("""\
Subject: A message using 8bit CTE
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
¡8-bit content!
- """
- ).encode()
+ """).encode()
email = EmailMessage()
email.attach("attachment.eml", attachment, "message/rfc822")
attachments = self.get_raw_attachments(email)
diff --git a/tests/migrations/test_multidb.py b/tests/migrations/test_multidb.py
index 7bf5d51454..14667bbdc3 100644
--- a/tests/migrations/test_multidb.py
+++ b/tests/migrations/test_multidb.py
@@ -112,9 +112,7 @@ class MultiDBOperationTests(OperationTestBase):
sql = """
INSERT INTO {0}_pony (pink, weight) VALUES (1, 3.55);
INSERT INTO {0}_pony (pink, weight) VALUES (3, 5.0);
- """.format(
- app_label
- )
+ """.format(app_label)
operation = migrations.RunSQL(sql, hints=hints or {})
# Test the state alteration does nothing
diff --git a/tests/model_forms/test_modelchoicefield.py b/tests/model_forms/test_modelchoicefield.py
index 8765f1a6d0..7b086fb182 100644
--- a/tests/model_forms/test_modelchoicefield.py
+++ b/tests/model_forms/test_modelchoicefield.py
@@ -402,8 +402,7 @@ class ModelChoiceFieldTests(TestCase):
<div><label>
<input type="checkbox" name="name" value="%d" data-slug="third-test">Third
</label></div></div>
- """
- % (self.c1.pk, self.c2.pk, self.c3.pk),
+ """ % (self.c1.pk, self.c2.pk, self.c3.pk),
)
def test_choice_value_hash(self):
diff --git a/tests/model_forms/tests.py b/tests/model_forms/tests.py
index 129ce56c7a..7fb91be2f9 100644
--- a/tests/model_forms/tests.py
+++ b/tests/model_forms/tests.py
@@ -1653,8 +1653,7 @@ class ModelFormBasicTests(TestCase):
<option value="%d" selected>Entertainment</option>
<option value="%d" selected>It&#x27;s a test</option>
<option value="%d">Third test</option>
-</select></li>"""
- % (self.c1.pk, self.c2.pk, self.c3.pk),
+</select></li>""" % (self.c1.pk, self.c2.pk, self.c3.pk),
)
def test_basic_creation(self):
@@ -3119,8 +3118,7 @@ class OtherModelFormTests(TestCase):
<select multiple name="colors" id="id_colors" required>
<option value="%(blue_pk)s">Blue</option>
</select></p>
- """
- % {"blue_pk": color.pk},
+ """ % {"blue_pk": color.pk},
)
def test_callable_field_default(self):
@@ -3157,9 +3155,7 @@ class OtherModelFormTests(TestCase):
<option value="3" selected>Novel</option></select>
<input id="initial-id_category" name="initial-category" type="hidden"
value="3">
- """.format(
- today_str
- ),
+ """.format(today_str),
)
empty_data = {
"title": "",
diff --git a/tests/postgres_tests/test_array.py b/tests/postgres_tests/test_array.py
index 392b8f946c..41fda970ae 100644
--- a/tests/postgres_tests/test_array.py
+++ b/tests/postgres_tests/test_array.py
@@ -1518,12 +1518,10 @@ class TestSplitFormWidget(PostgreSQLWidgetTestCase):
"array",
["val1", "val2"],
attrs={"id": "foo"},
- html=(
- """
+ html=("""
<input id="foo_0" name="array_0" type="text" value="val1">
<input id="foo_1" name="array_1" type="text" value="val2">
- """
- ),
+ """),
)
def test_value_omitted_from_data(self):
diff --git a/tests/requirements/py3.txt b/tests/requirements/py3.txt
index 28a8ae772e..cc73e0cd85 100644
--- a/tests/requirements/py3.txt
+++ b/tests/requirements/py3.txt
@@ -2,7 +2,7 @@ aiosmtpd >= 1.4.5
asgiref >= 3.9.1
argon2-cffi >= 23.1.0
bcrypt >= 4.1.1
-black >= 25.1.0
+black >= 26.1.0
docutils >= 0.22
geoip2 >= 4.8.0
jinja2 >= 2.11.0
diff --git a/tests/sitemaps_tests/test_http.py b/tests/sitemaps_tests/test_http.py
index b62060c0c6..be96ff6ba3 100644
--- a/tests/sitemaps_tests/test_http.py
+++ b/tests/sitemaps_tests/test_http.py
@@ -51,9 +51,7 @@ class HTTPSitemapTests(SitemapTestsBase):
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap><loc>{0}/simple/sitemap-simple.xml</loc><lastmod>{1}</lastmod></sitemap><sitemap><loc>{0}/simple/sitemap-simple.xml?p=2</loc><lastmod>{1}</lastmod></sitemap>
</sitemapindex>
-""".format(
- self.base_url, date.today()
- )
+""".format(self.base_url, date.today())
self.assertXMLEqual(response.text, expected_content)
@override_settings(
@@ -364,9 +362,7 @@ class HTTPSitemapTests(SitemapTestsBase):
<xhtml:link rel="alternate" hreflang="en" href="{url}/en/i18n/testmodel/{pk}/"/>
<xhtml:link rel="alternate" hreflang="pt" href="{url}/pt/i18n/testmodel/{pk}/"/>
</url>
-""".replace(
- "\n", ""
- )
+""".replace("\n", "")
expected_content = (
f'<?xml version="1.0" encoding="UTF-8"?>\n'
f'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" '
@@ -394,9 +390,7 @@ class HTTPSitemapTests(SitemapTestsBase):
<xhtml:link rel="alternate" hreflang="en" href="{url}/en/i18n/testmodel/{pk}/"/>
<xhtml:link rel="alternate" hreflang="es" href="{url}/es/i18n/testmodel/{pk}/"/>
</url>
-""".replace(
- "\n", ""
- )
+""".replace("\n", "")
expected_content = (
f'<?xml version="1.0" encoding="UTF-8"?>\n'
f'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" '
@@ -424,9 +418,7 @@ class HTTPSitemapTests(SitemapTestsBase):
<xhtml:link rel="alternate" hreflang="pt" href="{url}/pt/i18n/testmodel/{pk}/"/>
<xhtml:link rel="alternate" hreflang="x-default" href="{url}/i18n/testmodel/{pk}/"/>
</url>
-""".replace(
- "\n", ""
- )
+""".replace("\n", "")
expected_content = (
f'<?xml version="1.0" encoding="UTF-8"?>\n'
f'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" '
diff --git a/tests/sphinx/test_github_links.py b/tests/sphinx/test_github_links.py
index c0ca43b092..db0447b628 100644
--- a/tests/sphinx/test_github_links.py
+++ b/tests/sphinx/test_github_links.py
@@ -31,8 +31,7 @@ class GitHubLinkTests(SimpleTestCase):
github_links = _github_links
def test_code_locator(self):
- locator = github_links.CodeLocator.from_code(
- """
+ locator = github_links.CodeLocator.from_code("""
from a import b, c
from .d import e, f as g
@@ -41,8 +40,7 @@ def h():
class I:
def j(self):
- pass"""
- )
+ pass""")
self.assertEqual(locator.node_line_numbers, {"h": 5, "I": 8, "I.j": 9})
self.assertEqual(locator.import_locations, {"b": "a", "c": "a", "e": ".d"})
diff --git a/tests/test_runner/test_parallel.py b/tests/test_runner/test_parallel.py
index 32cc971d30..2ded499642 100644
--- a/tests/test_runner/test_parallel.py
+++ b/tests/test_runner/test_parallel.py
@@ -160,7 +160,7 @@ class RemoteTestResultTest(SimpleTestCase):
self.assertEqual(event[0], "addError")
self.assertEqual(event[1], -1)
self.assertEqual(event[2], test_id)
- (error_type, _, _) = event[3]
+ error_type, _, _ = event[3]
self.assertEqual(error_type, ValueError)
self.assertIs(result.wasSuccessful(), False)
diff --git a/tests/test_utils/tests.py b/tests/test_utils/tests.py
index 70cca3d441..bf332e064a 100644
--- a/tests/test_utils/tests.py
+++ b/tests/test_utils/tests.py
@@ -709,20 +709,16 @@ class HTMLEqualTests(SimpleTestCase):
def test_parse_html_in_script(self):
parse_html('<script>var a = "<p" + ">";</script>')
- parse_html(
- """
+ parse_html("""
<script>
var js_sha_link='<p>***</p>';
</script>
- """
- )
+ """)
# script content will be parsed to text
- dom = parse_html(
- """
+ dom = parse_html("""
<script><p>foo</p> '</scr'+'ipt>' <span>bar</span></script>
- """
- )
+ """)
self.assertEqual(len(dom.children), 1)
self.assertEqual(dom.children[0], "<p>foo</p> '</scr'+'ipt>' <span>bar</span>")
@@ -1021,12 +1017,10 @@ class HTMLEqualTests(SimpleTestCase):
self.assertHTMLEqual("<p><foo></p>", "<p>&#60;foo&#62;</p>")
def test_contains_html(self):
- response = HttpResponse(
- """<body>
+ response = HttpResponse("""<body>
This is a form: <form method="get">
<input type="text" name="Hello" />
- </form></body>"""
- )
+ </form></body>""")
self.assertNotContains(response, "<input name='Hello' type='text'>")
self.assertContains(response, '<form method="get">')
@@ -1223,9 +1217,7 @@ class XMLEqualTests(SimpleTestCase):
- <elem attr1='a' />
+ <elem attr2='b' attr1='a' />
? ++++++++++
-""".format(
- xml1=repr(xml1), xml2=repr(xml2)
- )
+""".format(xml1=repr(xml1), xml2=repr(xml2))
with self.assertRaisesMessage(AssertionError, msg):
self.assertXMLEqual(xml1, xml2)