summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrançois Freitag <mail@franek.fr>2020-04-06 12:12:41 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-04-07 08:45:11 +0200
commite03eb8db9371c2af864b124701b8f970ff405ca9 (patch)
treeb970f875aef89e5ac89a6e38a711c260129940b5
parent5fbc0e07a92f192acfa6bc4b09c3732476eeefc6 (diff)
Fixed #31428 -- Allowed empty message in management command self.stdout/err proxies.
-rw-r--r--django/contrib/staticfiles/management/commands/collectstatic.py2
-rw-r--r--django/core/management/base.py2
-rw-r--r--django/core/management/commands/loaddata.py2
-rw-r--r--tests/user_commands/management/commands/hal.py1
-rw-r--r--tests/user_commands/tests.py2
5 files changed, 5 insertions, 4 deletions
diff --git a/django/contrib/staticfiles/management/commands/collectstatic.py b/django/contrib/staticfiles/management/commands/collectstatic.py
index b2995acc7e..ce2691aff2 100644
--- a/django/contrib/staticfiles/management/commands/collectstatic.py
+++ b/django/contrib/staticfiles/management/commands/collectstatic.py
@@ -129,7 +129,7 @@ class Command(BaseCommand):
self.stderr.write("Post-processing '%s' failed!" % original_path)
# Add a blank line before the traceback, otherwise it's
# too easy to miss the relevant part of the error message.
- self.stderr.write("")
+ self.stderr.write()
raise processed
if processed:
self.log("Post-processed '%s' as '%s'" %
diff --git a/django/core/management/base.py b/django/core/management/base.py
index f92ceb17d8..74ffc94dcf 100644
--- a/django/core/management/base.py
+++ b/django/core/management/base.py
@@ -137,7 +137,7 @@ class OutputWrapper(TextIOBase):
def isatty(self):
return hasattr(self._out, 'isatty') and self._out.isatty()
- def write(self, msg, style_func=None, ending=None):
+ def write(self, msg='', style_func=None, ending=None):
ending = self.ending if ending is None else ending
if ending and not msg.endswith(ending):
msg += ending
diff --git a/django/core/management/commands/loaddata.py b/django/core/management/commands/loaddata.py
index fb7cf303f2..bdc0c03178 100644
--- a/django/core/management/commands/loaddata.py
+++ b/django/core/management/commands/loaddata.py
@@ -196,7 +196,7 @@ class Command(BaseCommand):
if obj.deferred_fields:
self.objs_with_deferred_fields.append(obj)
if objects and show_progress:
- self.stdout.write('') # add a newline after progress indicator
+ self.stdout.write() # Add a newline after progress indicator.
self.loaded_object_count += loaded_objects_in_fixture
self.fixture_object_count += objects_in_fixture
except Exception as e:
diff --git a/tests/user_commands/management/commands/hal.py b/tests/user_commands/management/commands/hal.py
index 120eec961f..5791e5fae0 100644
--- a/tests/user_commands/management/commands/hal.py
+++ b/tests/user_commands/management/commands/hal.py
@@ -12,6 +12,7 @@ class Command(BaseCommand):
app_labels = set(app_labels)
if options['empty']:
+ self.stdout.write()
self.stdout.write("Dave, I can't do that.")
return
diff --git a/tests/user_commands/tests.py b/tests/user_commands/tests.py
index 4e730472f5..b770e8e459 100644
--- a/tests/user_commands/tests.py
+++ b/tests/user_commands/tests.py
@@ -124,7 +124,7 @@ class CommandTests(SimpleTestCase):
def test_calling_a_command_with_only_empty_parameter_should_ends_gracefully(self):
out = StringIO()
management.call_command('hal', "--empty", stdout=out)
- self.assertIn("Dave, I can't do that.\n", out.getvalue())
+ self.assertEqual(out.getvalue(), "\nDave, I can't do that.\n")
def test_calling_command_with_app_labels_and_parameters_should_be_ok(self):
out = StringIO()