Skip to content

Commit f220235

Browse files
authored
Fix test for changed error message from newer Django (djmain) (#1486)
* fix djmain changes the error message text * remove unnecceesary verbose assert message and avoid E501 * conditionalize error message test based on Django version
1 parent 5ce5e7f commit f220235

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

tests/test_commands.py

Lines changed: 9 additions & 3 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",
@@ -140,6 +142,10 @@ def test_validation_failed_message(self):
140142
stdout=output,
141143
)
142144

143-
self.assertIn("user", output.getvalue())
144-
self.assertIn("783", output.getvalue())
145-
self.assertIn("does not exist", output.getvalue())
145+
output_str = output.getvalue()
146+
self.assertIn("user", output_str)
147+
self.assertIn("783", output_str)
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)