summaryrefslogtreecommitdiff
path: root/tests/invalid_models_tests
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2022-02-04 08:08:27 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-02-07 20:37:05 +0100
commit7119f40c9881666b6f9b5cf7df09ee1d21cc8344 (patch)
treefa50869f5614295f462d9bf77fec59365c621609 /tests/invalid_models_tests
parent9c19aff7c7561e3a82978a272ecdaad40dda5c00 (diff)
Refs #33476 -- Refactored code to strictly match 88 characters line length.
Diffstat (limited to 'tests/invalid_models_tests')
-rw-r--r--tests/invalid_models_tests/test_deprecated_fields.py6
-rw-r--r--tests/invalid_models_tests/test_models.py9
-rw-r--r--tests/invalid_models_tests/test_ordinary_fields.py3
-rw-r--r--tests/invalid_models_tests/test_relative_fields.py74
4 files changed, 68 insertions, 24 deletions
diff --git a/tests/invalid_models_tests/test_deprecated_fields.py b/tests/invalid_models_tests/test_deprecated_fields.py
index fee5fb39f8..3f3953496c 100644
--- a/tests/invalid_models_tests/test_deprecated_fields.py
+++ b/tests/invalid_models_tests/test_deprecated_fields.py
@@ -37,7 +37,11 @@ class DeprecatedFieldsTests(SimpleTestCase):
checks.Error(
"CommaSeparatedIntegerField is removed except for support in "
"historical migrations.",
- hint="Use CharField(validators=[validate_comma_separated_integer_list]) instead.",
+ hint=(
+ "Use "
+ "CharField(validators=[validate_comma_separated_integer_list]) "
+ "instead."
+ ),
obj=CommaSeparatedIntegerModel._meta.get_field("csi"),
id="fields.E901",
)
diff --git a/tests/invalid_models_tests/test_models.py b/tests/invalid_models_tests/test_models.py
index 6daa14f0ad..5ea830d0ec 100644
--- a/tests/invalid_models_tests/test_models.py
+++ b/tests/invalid_models_tests/test_models.py
@@ -228,7 +228,8 @@ class UniqueTogetherTests(SimpleTestCase):
Model.check(),
[
Error(
- "'unique_together' refers to the nonexistent field 'missing_field'.",
+ "'unique_together' refers to the nonexistent field "
+ "'missing_field'.",
obj=Model,
id="models.E012",
),
@@ -1452,7 +1453,8 @@ class OtherModelTests(SimpleTestCase):
Model.check(),
[
Error(
- "The model cannot have more than one field with 'primary_key=True'.",
+ "The model cannot have more than one field with "
+ "'primary_key=True'.",
obj=Model,
id="models.E026",
)
@@ -1469,7 +1471,8 @@ class OtherModelTests(SimpleTestCase):
Model.check(),
[
Error(
- "'TEST_SWAPPED_MODEL_BAD_VALUE' is not of the form 'app_label.app_name'.",
+ "'TEST_SWAPPED_MODEL_BAD_VALUE' is not of the form "
+ "'app_label.app_name'.",
id="models.E001",
),
],
diff --git a/tests/invalid_models_tests/test_ordinary_fields.py b/tests/invalid_models_tests/test_ordinary_fields.py
index ba63cb2903..ef7f845a33 100644
--- a/tests/invalid_models_tests/test_ordinary_fields.py
+++ b/tests/invalid_models_tests/test_ordinary_fields.py
@@ -750,7 +750,8 @@ class FilePathFieldTests(SimpleTestCase):
field.check(),
[
Error(
- "FilePathFields must have either 'allow_files' or 'allow_folders' set to True.",
+ "FilePathFields must have either 'allow_files' or 'allow_folders' "
+ "set to True.",
obj=field,
id="fields.E140",
),
diff --git a/tests/invalid_models_tests/test_relative_fields.py b/tests/invalid_models_tests/test_relative_fields.py
index 1dc4e7e6be..5b4bb45ff8 100644
--- a/tests/invalid_models_tests/test_relative_fields.py
+++ b/tests/invalid_models_tests/test_relative_fields.py
@@ -343,7 +343,10 @@ class RelativeFieldTests(SimpleTestCase):
"foreign keys to 'Person', which is ambiguous. You must specify "
"which two foreign keys Django should use via the through_fields "
"keyword argument.",
- hint="Use through_fields to specify which two foreign keys Django should use.",
+ hint=(
+ "Use through_fields to specify which two foreign keys Django "
+ "should use."
+ ),
obj=InvalidRelationship,
id="fields.E333",
),
@@ -425,7 +428,8 @@ class RelativeFieldTests(SimpleTestCase):
field.check(),
[
Error(
- "'Target.bad' must be unique because it is referenced by a foreign key.",
+ "'Target.bad' must be unique because it is referenced by a foreign "
+ "key.",
hint=(
"Add unique=True to this field or add a UniqueConstraint "
"(without condition) in the model Meta.constraints."
@@ -448,7 +452,8 @@ class RelativeFieldTests(SimpleTestCase):
field.check(),
[
Error(
- "'Target.bad' must be unique because it is referenced by a foreign key.",
+ "'Target.bad' must be unique because it is referenced by a foreign "
+ "key.",
hint=(
"Add unique=True to this field or add a UniqueConstraint "
"(without condition) in the model Meta.constraints."
@@ -532,7 +537,8 @@ class RelativeFieldTests(SimpleTestCase):
field.check(),
[
Error(
- "No subset of the fields 'country_id', 'city_id' on model 'Person' is unique.",
+ "No subset of the fields 'country_id', 'city_id' on model 'Person' "
+ "is unique.",
hint=(
"Mark a single field as unique=True or add a set of "
"fields to a unique constraint (via unique_together or a "
@@ -627,7 +633,10 @@ class RelativeFieldTests(SimpleTestCase):
[
Error(
"Field specifies on_delete=SET_NULL, but cannot be null.",
- hint="Set null=True argument on the field, or change the on_delete rule.",
+ hint=(
+ "Set null=True argument on the field, or change the on_delete "
+ "rule."
+ ),
obj=field,
id="fields.E320",
),
@@ -668,7 +677,10 @@ class RelativeFieldTests(SimpleTestCase):
[
Error(
"Primary keys must not have null=True.",
- hint="Set null=False on the field, or remove primary_key=True argument.",
+ hint=(
+ "Set null=False on the field, or remove primary_key=True "
+ "argument."
+ ),
obj=field,
id="fields.E007",
),
@@ -802,7 +814,10 @@ class RelativeFieldTests(SimpleTestCase):
Error(
"The name '%s' is invalid related_name for field Child%s.parent"
% (invalid_related_name, invalid_related_name),
- hint="Related name must be a valid Python identifier or end with a '+'",
+ hint=(
+ "Related name must be a valid Python identifier or end "
+ "with a '+'"
+ ),
obj=field,
id="fields.E306",
),
@@ -861,12 +876,14 @@ class RelativeFieldTests(SimpleTestCase):
field.check(),
[
Error(
- "The to_field 'a' doesn't exist on the related model 'invalid_models_tests.Parent'.",
+ "The to_field 'a' doesn't exist on the related model "
+ "'invalid_models_tests.Parent'.",
obj=field,
id="fields.E312",
),
Error(
- "The to_field 'b' doesn't exist on the related model 'invalid_models_tests.Parent'.",
+ "The to_field 'b' doesn't exist on the related model "
+ "'invalid_models_tests.Parent'.",
obj=field,
id="fields.E312",
),
@@ -889,8 +906,9 @@ class RelativeFieldTests(SimpleTestCase):
field.check(),
[
Error(
- "Field defines a relation with model 'invalid_models_tests.Parent', "
- "which is either not installed, or is abstract.",
+ "Field defines a relation with model "
+ "'invalid_models_tests.Parent', which is either not installed, or "
+ "is abstract.",
id="fields.E300",
obj=field,
),
@@ -1831,13 +1849,19 @@ class M2mThroughFieldsTests(SimpleTestCase):
[
Error(
"'Invitation.invitee' is not a foreign key to 'Event'.",
- hint="Did you mean one of the following foreign keys to 'Event': event?",
+ hint=(
+ "Did you mean one of the following foreign keys to 'Event': "
+ "event?"
+ ),
obj=field,
id="fields.E339",
),
Error(
"'Invitation.event' is not a foreign key to 'Fan'.",
- hint="Did you mean one of the following foreign keys to 'Fan': invitee, inviter?",
+ hint=(
+ "Did you mean one of the following foreign keys to 'Fan': "
+ "invitee, inviter?"
+ ),
obj=field,
id="fields.E339",
),
@@ -1870,14 +1894,22 @@ class M2mThroughFieldsTests(SimpleTestCase):
field.check(from_model=Event),
[
Error(
- "The intermediary model 'invalid_models_tests.Invitation' has no field 'invalid_field_1'.",
- hint="Did you mean one of the following foreign keys to 'Event': event?",
+ "The intermediary model 'invalid_models_tests.Invitation' has no "
+ "field 'invalid_field_1'.",
+ hint=(
+ "Did you mean one of the following foreign keys to 'Event': "
+ "event?"
+ ),
obj=field,
id="fields.E338",
),
Error(
- "The intermediary model 'invalid_models_tests.Invitation' has no field 'invalid_field_2'.",
- hint="Did you mean one of the following foreign keys to 'Fan': invitee, inviter?",
+ "The intermediary model 'invalid_models_tests.Invitation' has no "
+ "field 'invalid_field_2'.",
+ hint=(
+ "Did you mean one of the following foreign keys to 'Fan': "
+ "invitee, inviter?"
+ ),
obj=field,
id="fields.E338",
),
@@ -1911,7 +1943,10 @@ class M2mThroughFieldsTests(SimpleTestCase):
"Field specifies 'through_fields' but does not provide the names "
"of the two link fields that should be used for the relation "
"through model 'invalid_models_tests.Invitation'.",
- hint="Make sure you specify 'through_fields' as through_fields=('field1', 'field2')",
+ hint=(
+ "Make sure you specify 'through_fields' as "
+ "through_fields=('field1', 'field2')"
+ ),
obj=field,
id="fields.E337",
),
@@ -1985,7 +2020,8 @@ class M2mThroughFieldsTests(SimpleTestCase):
field.check(from_model=Child),
[
Error(
- "No subset of the fields 'a', 'b', 'd' on model 'Parent' is unique.",
+ "No subset of the fields 'a', 'b', 'd' on model 'Parent' is "
+ "unique.",
hint=(
"Mark a single field as unique=True or add a set of "
"fields to a unique constraint (via unique_together or a "