From 7cf3e528627a1b90e07ba3ead858b2c486ba7e42 Mon Sep 17 00:00:00 2001 From: Jan Pieter Waagmeester Date: Tue, 23 Jul 2024 07:07:05 +0200 Subject: [PATCH] Attempt at shimmming the chenged error message --- tests/test_translating.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/test_translating.py b/tests/test_translating.py index f3281b7..13164e2 100644 --- a/tests/test_translating.py +++ b/tests/test_translating.py @@ -1,3 +1,4 @@ +import django from django.core.exceptions import ImproperlyConfigured, ValidationError from django.db import models from django.test import TestCase @@ -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.get_version.startswith("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()