From c8bebbd541d601ed283617166609b37d2ccd7f96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Freitag?= Date: Wed, 13 May 2020 07:12:43 +0000 Subject: [PATCH] Disabled management commands output with verbosity 0 in various tests. --- tests/auth_tests/test_management.py | 3 +-- tests/migrate_signals/tests.py | 11 ++++------- tests/swappable_models/tests.py | 5 +---- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/tests/auth_tests/test_management.py b/tests/auth_tests/test_management.py index 0acdb4ece24..eb2be26dc3f 100644 --- a/tests/auth_tests/test_management.py +++ b/tests/auth_tests/test_management.py @@ -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') diff --git a/tests/migrate_signals/tests.py b/tests/migrate_signals/tests.py index 563be2a82d1..9611fc90e15 100644 --- a/tests/migrate_signals/tests.py +++ b/tests/migrate_signals/tests.py @@ -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()], diff --git a/tests/swappable_models/tests.py b/tests/swappable_models/tests.py index bdf681dd87d..b1bcaa9f70e 100644 --- a/tests/swappable_models/tests.py +++ b/tests/swappable_models/tests.py @@ -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.