mirror of
https://github.com/django/django.git
synced 2025-10-17 22:07:29 +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
|
@ -757,8 +757,18 @@ class MakeMigrationsTests(MigrationTestBase):
|
|||
makemigrations exits if it detects a conflict.
|
||||
"""
|
||||
with self.temporary_migration_module(module="migrations.test_migrations_conflict"):
|
||||
with self.assertRaises(CommandError):
|
||||
with self.assertRaises(CommandError) as context:
|
||||
call_command("makemigrations")
|
||||
exception_message = str(context.exception)
|
||||
self.assertIn(
|
||||
'Conflicting migrations detected; multiple leaf nodes '
|
||||
'in the migration graph:',
|
||||
exception_message
|
||||
)
|
||||
self.assertIn('0002_second', exception_message)
|
||||
self.assertIn('0002_conflicting_second', exception_message)
|
||||
self.assertIn('in migrations', exception_message)
|
||||
self.assertIn("To fix them run 'python manage.py makemigrations --merge'", exception_message)
|
||||
|
||||
def test_makemigrations_merge_no_conflict(self):
|
||||
"""
|
||||
|
@ -780,7 +790,8 @@ class MakeMigrationsTests(MigrationTestBase):
|
|||
"""
|
||||
makemigrations exits if no app is specified with 'empty' mode.
|
||||
"""
|
||||
with self.assertRaises(CommandError):
|
||||
msg = 'You must supply at least one app label when using --empty.'
|
||||
with self.assertRaisesMessage(CommandError, msg):
|
||||
call_command("makemigrations", empty=True)
|
||||
|
||||
def test_makemigrations_empty_migration(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue