Skip to content

Commit

Permalink
Fix test for changed error message from newer Django (djmain) (#1486)
Browse files Browse the repository at this point in the history
* fix djmain changes the error message text

* remove unnecceesary verbose assert message and avoid E501

* conditionalize error message test based on Django version
  • Loading branch information
n2ygk authored Sep 6, 2024
1 parent 5ce5e7f commit f220235
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ def test_application_created_with_algorithm(self):
self.assertEqual(app.algorithm, "RS256")

def test_validation_failed_message(self):
import django

output = StringIO()
call_command(
"createapplication",
Expand All @@ -140,6 +142,10 @@ def test_validation_failed_message(self):
stdout=output,
)

self.assertIn("user", output.getvalue())
self.assertIn("783", output.getvalue())
self.assertIn("does not exist", output.getvalue())
output_str = output.getvalue()
self.assertIn("user", output_str)
self.assertIn("783", output_str)
if django.VERSION < (5, 2):
self.assertIn("does not exist", output_str)
else:
self.assertIn("is not a valid choice", output_str)

0 comments on commit f220235

Please sign in to comment.