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