Skip to content

Commit c8f9f8a

Browse files
committed
conditionalize error message test based on Django version
1 parent 6bf75c0 commit c8f9f8a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

tests/test_commands.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ def test_application_created_with_algorithm(self):
130130
self.assertEqual(app.algorithm, "RS256")
131131

132132
def test_validation_failed_message(self):
133+
import django
134+
133135
output = StringIO()
134136
call_command(
135137
"createapplication",
@@ -143,7 +145,7 @@ def test_validation_failed_message(self):
143145
output_str = output.getvalue()
144146
self.assertIn("user", output_str)
145147
self.assertIn("783", output_str)
146-
# newer Django (>5.1) changes the error message from "does not exist" to "is not a valid choice"
147-
self.assertTrue(
148-
any(substring in output_str for substring in ["does not exist", "is not a valid choice"])
149-
)
148+
if django.VERSION < (5, 2):
149+
self.assertIn("does not exist", output_str)
150+
else:
151+
self.assertIn("is not a valid choice", output_str)

0 commit comments

Comments
 (0)