diff --git a/tests/test_translating.py b/tests/test_translating.py index f3281b7..895c863 100644 --- a/tests/test_translating.py +++ b/tests/test_translating.py @@ -1,6 +1,7 @@ from django.core.exceptions import ImproperlyConfigured, ValidationError from django.db import models from django.test import TestCase +import django from modeltrans.fields import TranslationField from modeltrans.manager import MultilingualManager, MultilingualQuerySet @@ -289,9 +290,11 @@ def test_limit_choices_to(self): comment = app_models.Comment.objects.create(post=published_post, text="foo") self.assertIsNotNone(comment.pk) - with self.assertRaisesMessage( - ValidationError, - f"post instance with id {unpublished_post.pk} does not exist", - ): + if django.VERSION > (5, 1): + expected = f"post instance with id {unpublished_post.pk} is not a valid choice." + else: + expected = f"post instance with id {unpublished_post.pk} does not exist" + + with self.assertRaisesMessage(ValidationError, expected): comment.post = unpublished_post comment.full_clean()