Skip to content

Commit 1d9f531

Browse files
committed
Fix failures due to CheckMessage.hint being optional
1 parent d6ee2dc commit 1d9f531

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
@@ -336,7 +336,9 @@ class Invalid(models.Model):
336336
assert len(errors) == 1
337337
assert errors[0].id == "django_mysql.E009"
338338
assert "'spec' must be a dict" in errors[0].msg
339-
assert "The value passed is of type list" in errors[0].hint
339+
hint = errors[0].hint
340+
assert hint is not None
341+
assert "The value passed is of type list" in hint
340342

341343
def test_spec_key_not_valid(self):
342344
class Invalid(models.Model):
@@ -346,8 +348,10 @@ class Invalid(models.Model):
346348
assert len(errors) == 1
347349
assert errors[0].id == "django_mysql.E010"
348350
assert "The key '2.0' in 'spec' is not a string" in errors[0].msg
349-
assert "'spec' keys must be of type " in errors[0].hint
350-
assert "'2.0' is of type float" in errors[0].hint
351+
hint = errors[0].hint
352+
assert hint is not None
353+
assert "'spec' keys must be of type " in hint
354+
assert "'2.0' is of type float" in hint
351355

352356
def test_spec_value_not_valid(self):
353357
class Invalid(models.Model):
@@ -357,9 +361,10 @@ class Invalid(models.Model):
357361
assert len(errors) == 1
358362
assert errors[0].id == "django_mysql.E011"
359363
assert "The value for 'bad' in 'spec' is not an allowed type" in errors[0].msg
364+
hint = errors[0].hint
365+
assert hint is not None
360366
assert (
361-
"'spec' values must be one of the following types: date, datetime"
362-
in errors[0].hint
367+
"'spec' values must be one of the following types: date, datetime" in hint
363368
)
364369

365370
def test_spec_nested_value_not_valid(self):
@@ -374,9 +379,10 @@ class Invalid(models.Model):
374379
assert (
375380
"The value for 'bad' in 'spec.l1' is not an allowed type" in errors[0].msg
376381
)
382+
hint = errors[0].hint
383+
assert hint is not None
377384
assert (
378-
"'spec' values must be one of the following types: date, datetime"
379-
in errors[0].hint
385+
"'spec' values must be one of the following types: date, datetime" in hint
380386
)
381387

382388

0 commit comments

Comments
 (0)