Refs #23359 -- Removed double newline from output of migrate --list
Thanks Berker Peksag for the review.
This commit is contained in:
parent
789baf9c3a
commit
e08318b4ef
|
@ -68,14 +68,15 @@ class Command(BaseCommand):
|
|||
warnings.warn(
|
||||
"The 'migrate --list' command is deprecated. Use 'showmigrations' instead.",
|
||||
RemovedInDjango20Warning, stacklevel=2)
|
||||
self.stdout.ending = None # Remove when #21429 is fixed
|
||||
return call_command(
|
||||
'showmigrations',
|
||||
'--list',
|
||||
app_labels=[options['app_label']] if options['app_label'] else None,
|
||||
database=db,
|
||||
no_color=options.get('no-color'),
|
||||
no_color=options.get('no_color'),
|
||||
settings=options.get('settings'),
|
||||
stdout=options.get('stdout', self.stdout),
|
||||
stdout=self.stdout,
|
||||
traceback=self.show_traceback,
|
||||
verbosity=self.verbosity,
|
||||
)
|
||||
|
|
|
@ -9,7 +9,7 @@ from django.apps import apps
|
|||
from django.db import connection, models
|
||||
from django.core.management import call_command, CommandError
|
||||
from django.db.migrations import questioner
|
||||
from django.test import ignore_warnings, override_settings
|
||||
from django.test import ignore_warnings, mock, override_settings
|
||||
from django.utils import six
|
||||
from django.utils.deprecation import RemovedInDjango20Warning
|
||||
from django.utils.encoding import force_text
|
||||
|
@ -66,19 +66,27 @@ class MigrateTests(MigrationTestBase):
|
|||
Tests --list output of migrate command
|
||||
"""
|
||||
out = six.StringIO()
|
||||
call_command("migrate", list=True, stdout=out, verbosity=0)
|
||||
self.assertIn("migrations", out.getvalue().lower())
|
||||
self.assertIn("[ ] 0001_initial", out.getvalue().lower())
|
||||
self.assertIn("[ ] 0002_second", out.getvalue().lower())
|
||||
with mock.patch('django.core.management.color.supports_color', lambda *args: True):
|
||||
call_command("migrate", list=True, stdout=out, verbosity=0, no_color=False)
|
||||
self.assertEqual(
|
||||
'\x1b[1mmigrations\n\x1b[0m'
|
||||
' [ ] 0001_initial\n'
|
||||
' [ ] 0002_second\n',
|
||||
out.getvalue().lower()
|
||||
)
|
||||
|
||||
call_command("migrate", "migrations", "0001", verbosity=0)
|
||||
|
||||
out = six.StringIO()
|
||||
# Giving the explicit app_label tests for selective `show_migration_list` in the command
|
||||
call_command("migrate", "migrations", list=True, stdout=out, verbosity=0)
|
||||
self.assertIn("migrations", out.getvalue().lower())
|
||||
self.assertIn("[x] 0001_initial", out.getvalue().lower())
|
||||
self.assertIn("[ ] 0002_second", out.getvalue().lower())
|
||||
call_command("migrate", "migrations", list=True, stdout=out, verbosity=0, no_color=True)
|
||||
self.assertEqual(
|
||||
'migrations\n'
|
||||
' [x] 0001_initial\n'
|
||||
' [ ] 0002_second\n',
|
||||
out.getvalue().lower()
|
||||
)
|
||||
|
||||
# Cleanup by unmigrating everything
|
||||
call_command("migrate", "migrations", "zero", verbosity=0)
|
||||
|
||||
|
@ -88,19 +96,26 @@ class MigrateTests(MigrationTestBase):
|
|||
Tests --list output of showmigrations command
|
||||
"""
|
||||
out = six.StringIO()
|
||||
call_command("showmigrations", format='list', stdout=out, verbosity=0)
|
||||
self.assertIn("migrations", out.getvalue().lower())
|
||||
self.assertIn("[ ] 0001_initial", out.getvalue().lower())
|
||||
self.assertIn("[ ] 0002_second", out.getvalue().lower())
|
||||
with mock.patch('django.core.management.color.supports_color', lambda *args: True):
|
||||
call_command("showmigrations", format='list', stdout=out, verbosity=0, no_color=False)
|
||||
self.assertEqual(
|
||||
'\x1b[1mmigrations\n\x1b[0m'
|
||||
' [ ] 0001_initial\n'
|
||||
' [ ] 0002_second\n',
|
||||
out.getvalue().lower()
|
||||
)
|
||||
|
||||
call_command("migrate", "migrations", "0001", verbosity=0)
|
||||
|
||||
out = six.StringIO()
|
||||
# Giving the explicit app_label tests for selective `show_list` in the command
|
||||
call_command("showmigrations", "migrations", format='list', stdout=out, verbosity=0)
|
||||
self.assertIn("migrations", out.getvalue().lower())
|
||||
self.assertIn("[x] 0001_initial", out.getvalue().lower())
|
||||
self.assertIn("[ ] 0002_second", out.getvalue().lower())
|
||||
call_command("showmigrations", "migrations", format='list', stdout=out, verbosity=0, no_color=True)
|
||||
self.assertEqual(
|
||||
'migrations\n'
|
||||
' [x] 0001_initial\n'
|
||||
' [ ] 0002_second\n',
|
||||
out.getvalue().lower()
|
||||
)
|
||||
# Cleanup by unmigrating everything
|
||||
call_command("migrate", "migrations", "zero", verbosity=0)
|
||||
|
||||
|
|
Loading…
Reference in New Issue