diff --git a/django/core/management/commands/makemigrations.py b/django/core/management/commands/makemigrations.py index 709abaa8d6..c8c688ec94 100644 --- a/django/core/management/commands/makemigrations.py +++ b/django/core/management/commands/makemigrations.py @@ -104,7 +104,7 @@ class Command(BaseCommand): except OperationalError as error: warnings.warn( "Got an error checking a consistent migration history " - "performed for database connection '%s': %s." + "performed for database connection '%s': %s" % (alias, error), RuntimeWarning, ) diff --git a/tests/migrations/test_commands.py b/tests/migrations/test_commands.py index 50f3ea8965..f7b21931e4 100644 --- a/tests/migrations/test_commands.py +++ b/tests/migrations/test_commands.py @@ -1566,8 +1566,9 @@ class MakeMigrationsTests(MigrationTestBase): side_effect=OperationalError('could not connect to server'), ): with self.temporary_migration_module(): - with self.assertWarnsMessage(RuntimeWarning, msg): + with self.assertWarns(RuntimeWarning) as cm: call_command('makemigrations', verbosity=0) + self.assertEqual(str(cm.warning), msg) @mock.patch('builtins.input', return_value='1') @mock.patch('django.db.migrations.questioner.sys.stdin', mock.MagicMock(encoding=sys.getdefaultencoding()))