1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Refs #33476 -- Refactored code to strictly match 88 characters line length.

This commit is contained in:
Mariusz Felisiak
2022-02-04 08:08:27 +01:00
parent 9c19aff7c7
commit 7119f40c98
404 changed files with 5944 additions and 2842 deletions

View File

@@ -540,11 +540,17 @@ class TestQuerying(PostgreSQLTestCase):
)
def test_unsupported_lookup(self):
msg = "Unsupported lookup '0_bar' for ArrayField or join on the field not permitted."
msg = (
"Unsupported lookup '0_bar' for ArrayField or join on the field not "
"permitted."
)
with self.assertRaisesMessage(FieldError, msg):
list(NullableIntegerArrayModel.objects.filter(field__0_bar=[2]))
msg = "Unsupported lookup '0bar' for ArrayField or join on the field not permitted."
msg = (
"Unsupported lookup '0bar' for ArrayField or join on the field not "
"permitted."
)
with self.assertRaisesMessage(FieldError, msg):
list(NullableIntegerArrayModel.objects.filter(field__0bar=[2]))
@@ -881,7 +887,10 @@ class TestMigrations(TransactionTestCase):
class TestSerialization(PostgreSQLSimpleTestCase):
test_data = '[{"fields": {"field": "[\\"1\\", \\"2\\", null]"}, "model": "postgres_tests.integerarraymodel", "pk": null}]'
test_data = (
'[{"fields": {"field": "[\\"1\\", \\"2\\", null]"}, '
'"model": "postgres_tests.integerarraymodel", "pk": null}]'
)
def test_dumping(self):
instance = IntegerArrayModel(field=[1, 2, None])
@@ -937,7 +946,8 @@ class TestValidation(PostgreSQLSimpleTestCase):
exception = cm.exception.error_list[0]
self.assertEqual(
exception.message,
"Item 1 in the array did not validate: Ensure this value has at most 2 characters (it has 3).",
"Item 1 in the array did not validate: Ensure this value has at most 2 "
"characters (it has 3).",
)
self.assertEqual(exception.code, "item_invalid")
self.assertEqual(
@@ -956,7 +966,8 @@ class TestValidation(PostgreSQLSimpleTestCase):
exception = cm.exception.error_list[0]
self.assertEqual(
exception.message,
"Item 1 in the array did not validate: Ensure this value is greater than or equal to 1.",
"Item 1 in the array did not validate: Ensure this value is greater than "
"or equal to 1.",
)
self.assertEqual(exception.code, "item_invalid")
self.assertEqual(
@@ -997,7 +1008,8 @@ class TestSimpleFormField(PostgreSQLSimpleTestCase):
first_error = errors[0]
self.assertEqual(
first_error.message,
"Item 1 in the array did not validate: Ensure this value has at most 2 characters (it has 3).",
"Item 1 in the array did not validate: Ensure this value has at most 2 "
"characters (it has 3).",
)
self.assertEqual(first_error.code, "item_invalid")
self.assertEqual(
@@ -1007,7 +1019,8 @@ class TestSimpleFormField(PostgreSQLSimpleTestCase):
second_error = errors[1]
self.assertEqual(
second_error.message,
"Item 3 in the array did not validate: Ensure this value has at most 2 characters (it has 4).",
"Item 3 in the array did not validate: Ensure this value has at most 2 "
"characters (it has 4).",
)
self.assertEqual(second_error.code, "item_invalid")
self.assertEqual(
@@ -1169,7 +1182,10 @@ class TestSplitFormField(PostgreSQLSimpleTestCase):
)
def test_invalid_integer(self):
msg = "Item 2 in the array did not validate: Ensure this value is less than or equal to 100."
msg = (
"Item 2 in the array did not validate: Ensure this value is less than or "
"equal to 100."
)
with self.assertRaisesMessage(exceptions.ValidationError, msg):
SplitArrayField(forms.IntegerField(max_value=100), size=2).clean([0, 101])
@@ -1200,8 +1216,10 @@ class TestSplitFormField(PostgreSQLSimpleTestCase):
self.assertEqual(
cm.exception.messages,
[
"Item 1 in the array did not validate: Ensure this value has at most 2 characters (it has 3).",
"Item 3 in the array did not validate: Ensure this value has at most 2 characters (it has 4).",
"Item 1 in the array did not validate: Ensure this value has at most 2 "
"characters (it has 3).",
"Item 3 in the array did not validate: Ensure this value has at most 2 "
"characters (it has 4).",
],
)

View File

@@ -920,7 +920,8 @@ class ExclusionConstraintTests(PostgreSQLTestCase):
)
with connection.schema_editor() as editor:
with mock.patch(
"django.db.backends.postgresql.features.DatabaseFeatures.supports_covering_gist_indexes",
"django.db.backends.postgresql.features.DatabaseFeatures."
"supports_covering_gist_indexes",
False,
):
with self.assertRaisesMessage(NotSupportedError, msg):

View File

@@ -519,7 +519,8 @@ class SchemaTests(PostgreSQLTestCase):
msg = "Covering GiST indexes require PostgreSQL 12+."
with self.assertRaisesMessage(NotSupportedError, msg):
with mock.patch(
"django.db.backends.postgresql.features.DatabaseFeatures.supports_covering_gist_indexes",
"django.db.backends.postgresql.features.DatabaseFeatures."
"supports_covering_gist_indexes",
False,
):
with connection.schema_editor() as editor:
@@ -632,7 +633,8 @@ class SchemaTests(PostgreSQLTestCase):
msg = "Covering SP-GiST indexes require PostgreSQL 14+."
with self.assertRaisesMessage(NotSupportedError, msg):
with mock.patch(
"django.db.backends.postgresql.features.DatabaseFeatures.supports_covering_spgist_indexes",
"django.db.backends.postgresql.features.DatabaseFeatures."
"supports_covering_spgist_indexes",
False,
):
with connection.schema_editor() as editor:

View File

@@ -23,10 +23,15 @@ class InspectDBTests(PostgreSQLTestCase):
self.assertFieldsInModel(
"postgres_tests_rangesmodel",
[
"ints = django.contrib.postgres.fields.IntegerRangeField(blank=True, null=True)",
"bigints = django.contrib.postgres.fields.BigIntegerRangeField(blank=True, null=True)",
"decimals = django.contrib.postgres.fields.DecimalRangeField(blank=True, null=True)",
"timestamps = django.contrib.postgres.fields.DateTimeRangeField(blank=True, null=True)",
"dates = django.contrib.postgres.fields.DateRangeField(blank=True, null=True)",
"ints = django.contrib.postgres.fields.IntegerRangeField(blank=True, "
"null=True)",
"bigints = django.contrib.postgres.fields.BigIntegerRangeField("
"blank=True, null=True)",
"decimals = django.contrib.postgres.fields.DecimalRangeField("
"blank=True, null=True)",
"timestamps = django.contrib.postgres.fields.DateTimeRangeField("
"blank=True, null=True)",
"dates = django.contrib.postgres.fields.DateRangeField(blank=True, "
"null=True)",
],
)

View File

@@ -550,13 +550,14 @@ class TestSerialization(PostgreSQLSimpleTestCase):
test_data = (
'[{"fields": {"ints": "{\\"upper\\": \\"10\\", \\"lower\\": \\"0\\", '
'\\"bounds\\": \\"[)\\"}", "decimals": "{\\"empty\\": true}", '
'"bigints": null, "timestamps": "{\\"upper\\": \\"2014-02-02T12:12:12+00:00\\", '
'"bigints": null, "timestamps": '
'"{\\"upper\\": \\"2014-02-02T12:12:12+00:00\\", '
'\\"lower\\": \\"2014-01-01T00:00:00+00:00\\", \\"bounds\\": \\"[)\\"}", '
'"timestamps_inner": null, '
'"timestamps_closed_bounds": "{\\"upper\\": \\"2014-02-02T12:12:12+00:00\\", '
'\\"lower\\": \\"2014-01-01T00:00:00+00:00\\", \\"bounds\\": \\"()\\"}", '
'"dates": "{\\"upper\\": \\"2014-02-02\\", \\"lower\\": \\"2014-01-01\\", \\"bounds\\": \\"[)\\"}", '
'"dates_inner": null }, '
'"dates": "{\\"upper\\": \\"2014-02-02\\", \\"lower\\": \\"2014-01-01\\", '
'\\"bounds\\": \\"[)\\"}", "dates_inner": null }, '
'"model": "postgres_tests.rangesmodel", "pk": null}]'
)
@@ -730,8 +731,10 @@ class TestFormField(PostgreSQLSimpleTestCase):
</th><td>
<input type="text" name="datetime_field_0" id="id_datetime_field_0">
<input type="text" name="datetime_field_1" id="id_datetime_field_1">
<input type="hidden" name="initial-datetime_field_0" id="initial-id_datetime_field_0">
<input type="hidden" name="initial-datetime_field_1" id="initial-id_datetime_field_1">
<input type="hidden" name="initial-datetime_field_0"
id="initial-id_datetime_field_0">
<input type="hidden" name="initial-datetime_field_1"
id="initial-id_datetime_field_1">
</td></tr>
""",
)
@@ -751,10 +754,10 @@ class TestFormField(PostgreSQLSimpleTestCase):
value="2010-01-01 11:13:00" id="id_datetime_field_0">
<input type="text" name="datetime_field_1"
value="2020-12-12 16:59:00" id="id_datetime_field_1">
<input type="hidden" name="initial-datetime_field_0" value="2010-01-01 11:13:00"
id="initial-id_datetime_field_0">
<input type="hidden" name="initial-datetime_field_1" value="2020-12-12 16:59:00"
id="initial-id_datetime_field_1"></td></tr>
<input type="hidden" name="initial-datetime_field_0"
value="2010-01-01 11:13:00" id="initial-id_datetime_field_0">
<input type="hidden" name="initial-datetime_field_1"
value="2020-12-12 16:59:00" id="initial-id_datetime_field_1"></td></tr>
""",
)
@@ -1074,11 +1077,13 @@ class TestWidget(PostgreSQLSimpleTestCase):
f = pg_forms.ranges.DateTimeRangeField()
self.assertHTMLEqual(
f.widget.render("datetimerange", ""),
'<input type="text" name="datetimerange_0"><input type="text" name="datetimerange_1">',
'<input type="text" name="datetimerange_0">'
'<input type="text" name="datetimerange_1">',
)
self.assertHTMLEqual(
f.widget.render("datetimerange", None),
'<input type="text" name="datetimerange_0"><input type="text" name="datetimerange_1">',
'<input type="text" name="datetimerange_0">'
'<input type="text" name="datetimerange_1">',
)
dt_range = DateTimeTZRange(
datetime.datetime(2006, 1, 10, 7, 30), datetime.datetime(2006, 2, 12, 9, 50)