Disabled management commands output with verbosity 0 in various tests.

This commit is contained in:
François Freitag 2020-05-13 07:12:43 +00:00 committed by GitHub
parent 7cd88b3fec
commit c8bebbd541
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 13 deletions

View File

@ -310,13 +310,12 @@ class CreatesuperuserManagementCommandTestCase(TestCase):
self.assertFalse(u.has_usable_password())
def test_email_in_username(self):
new_io = StringIO()
call_command(
"createsuperuser",
interactive=False,
username="joe+admin@somewhere.org",
email="joe@somewhere.org",
stdout=new_io
verbosity=0,
)
u = User._default_manager.get(username="joe+admin@somewhere.org")
self.assertEqual(u.email, 'joe@somewhere.org')

View File

@ -1,5 +1,3 @@
from io import StringIO
from django.apps import apps
from django.core import management
from django.db import migrations
@ -9,7 +7,7 @@ from django.test import TransactionTestCase, override_settings
APP_CONFIG = apps.get_app_config('migrate_signals')
SIGNAL_ARGS = ['app_config', 'verbosity', 'interactive', 'using', 'plan', 'apps']
MIGRATE_DATABASE = 'default'
MIGRATE_VERBOSITY = 1
MIGRATE_VERBOSITY = 0
MIGRATE_INTERACTIVE = False
@ -71,7 +69,7 @@ class MigrateSignalTests(TransactionTestCase):
post_migrate_receiver = Receiver(signals.post_migrate)
management.call_command(
'migrate', database=MIGRATE_DATABASE, verbosity=MIGRATE_VERBOSITY,
interactive=MIGRATE_INTERACTIVE, stdout=StringIO(),
interactive=MIGRATE_INTERACTIVE,
)
for receiver in [pre_migrate_receiver, post_migrate_receiver]:
@ -92,10 +90,9 @@ class MigrateSignalTests(TransactionTestCase):
"""
pre_migrate_receiver = Receiver(signals.pre_migrate)
post_migrate_receiver = Receiver(signals.post_migrate)
stdout = StringIO()
management.call_command(
'migrate', database=MIGRATE_DATABASE, verbosity=MIGRATE_VERBOSITY,
interactive=MIGRATE_INTERACTIVE, stdout=stdout,
interactive=MIGRATE_INTERACTIVE,
)
for receiver in [pre_migrate_receiver, post_migrate_receiver]:
args = receiver.call_args
@ -119,7 +116,7 @@ class MigrateSignalTests(TransactionTestCase):
post_migrate_receiver = Receiver(signals.post_migrate)
management.call_command(
'migrate', database=MIGRATE_DATABASE, verbosity=MIGRATE_VERBOSITY,
interactive=MIGRATE_INTERACTIVE, stdout=stdout,
interactive=MIGRATE_INTERACTIVE,
)
self.assertEqual(
[model._meta.label for model in pre_migrate_receiver.call_args['apps'].get_models()],

View File

@ -1,5 +1,3 @@
from io import StringIO
from django.contrib.auth.models import Permission
from django.contrib.contenttypes.models import ContentType
from django.core import management
@ -26,8 +24,7 @@ class SwappableModelTests(TestCase):
ContentType.objects.filter(app_label='swappable_models').delete()
# Re-run migrate. This will re-build the permissions and content types.
new_io = StringIO()
management.call_command('migrate', interactive=False, stdout=new_io)
management.call_command('migrate', interactive=False, verbosity=0)
# Content types and permissions exist for the swapped model,
# but not for the swappable model.