Skip to content

Commit d849f05

Browse files
committed
Fix failures due to CheckMessage.hint being optional
1 parent bce7f72 commit d849f05

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

tests/testapp/test_dynamicfield.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,9 @@ class Invalid(models.Model):
343343
assert len(errors) == 1
344344
assert errors[0].id == "django_mysql.E009"
345345
assert "'spec' must be a dict" in errors[0].msg
346-
assert "The value passed is of type list" in errors[0].hint
346+
hint = errors[0].hint
347+
assert hint is not None
348+
assert "The value passed is of type list" in hint
347349

348350
def test_spec_key_not_valid(self):
349351
class Invalid(models.Model):
@@ -353,8 +355,10 @@ class Invalid(models.Model):
353355
assert len(errors) == 1
354356
assert errors[0].id == "django_mysql.E010"
355357
assert "The key '2.0' in 'spec' is not a string" in errors[0].msg
356-
assert "'spec' keys must be of type " in errors[0].hint
357-
assert "'2.0' is of type float" in errors[0].hint
358+
hint = errors[0].hint
359+
assert hint is not None
360+
assert "'spec' keys must be of type " in hint
361+
assert "'2.0' is of type float" in hint
358362

359363
def test_spec_value_not_valid(self):
360364
class Invalid(models.Model):
@@ -364,9 +368,10 @@ class Invalid(models.Model):
364368
assert len(errors) == 1
365369
assert errors[0].id == "django_mysql.E011"
366370
assert "The value for 'bad' in 'spec' is not an allowed type" in errors[0].msg
371+
hint = errors[0].hint
372+
assert hint is not None
367373
assert (
368-
"'spec' values must be one of the following types: date, datetime"
369-
in errors[0].hint
374+
"'spec' values must be one of the following types: date, datetime" in hint
370375
)
371376

372377
def test_spec_nested_value_not_valid(self):
@@ -381,9 +386,10 @@ class Invalid(models.Model):
381386
assert (
382387
"The value for 'bad' in 'spec.l1' is not an allowed type" in errors[0].msg
383388
)
389+
hint = errors[0].hint
390+
assert hint is not None
384391
assert (
385-
"'spec' values must be one of the following types: date, datetime"
386-
in errors[0].hint
392+
"'spec' values must be one of the following types: date, datetime" in hint
387393
)
388394

389395

0 commit comments

Comments
 (0)