mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Used assertRaisesMessage() to test Django's error messages.
This commit is contained in:
parent
38988f289f
commit
a51c4de194
69 changed files with 448 additions and 173 deletions
|
@ -29,7 +29,11 @@ class ManyToManyTests(TestCase):
|
|||
# Create an Article.
|
||||
a5 = Article(headline='Django lets you reate Web apps easily')
|
||||
# You can't associate it with a Publication until it's been saved.
|
||||
with self.assertRaises(ValueError):
|
||||
msg = (
|
||||
'"<Article: Django lets you reate Web apps easily>" needs to have '
|
||||
'a value for field "id" before this many-to-many relationship can be used.'
|
||||
)
|
||||
with self.assertRaisesMessage(ValueError, msg):
|
||||
getattr(a5, 'publications')
|
||||
# Save it!
|
||||
a5.save()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue