Fixed #31428 -- Allowed empty message in management command self.stdout/err proxies.
This commit is contained in:
parent
5fbc0e07a9
commit
e03eb8db93
|
@ -129,7 +129,7 @@ class Command(BaseCommand):
|
||||||
self.stderr.write("Post-processing '%s' failed!" % original_path)
|
self.stderr.write("Post-processing '%s' failed!" % original_path)
|
||||||
# Add a blank line before the traceback, otherwise it's
|
# Add a blank line before the traceback, otherwise it's
|
||||||
# too easy to miss the relevant part of the error message.
|
# too easy to miss the relevant part of the error message.
|
||||||
self.stderr.write("")
|
self.stderr.write()
|
||||||
raise processed
|
raise processed
|
||||||
if processed:
|
if processed:
|
||||||
self.log("Post-processed '%s' as '%s'" %
|
self.log("Post-processed '%s' as '%s'" %
|
||||||
|
|
|
@ -137,7 +137,7 @@ class OutputWrapper(TextIOBase):
|
||||||
def isatty(self):
|
def isatty(self):
|
||||||
return hasattr(self._out, 'isatty') and self._out.isatty()
|
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
|
ending = self.ending if ending is None else ending
|
||||||
if ending and not msg.endswith(ending):
|
if ending and not msg.endswith(ending):
|
||||||
msg += ending
|
msg += ending
|
||||||
|
|
|
@ -196,7 +196,7 @@ class Command(BaseCommand):
|
||||||
if obj.deferred_fields:
|
if obj.deferred_fields:
|
||||||
self.objs_with_deferred_fields.append(obj)
|
self.objs_with_deferred_fields.append(obj)
|
||||||
if objects and show_progress:
|
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.loaded_object_count += loaded_objects_in_fixture
|
||||||
self.fixture_object_count += objects_in_fixture
|
self.fixture_object_count += objects_in_fixture
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
@ -12,6 +12,7 @@ class Command(BaseCommand):
|
||||||
app_labels = set(app_labels)
|
app_labels = set(app_labels)
|
||||||
|
|
||||||
if options['empty']:
|
if options['empty']:
|
||||||
|
self.stdout.write()
|
||||||
self.stdout.write("Dave, I can't do that.")
|
self.stdout.write("Dave, I can't do that.")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -124,7 +124,7 @@ class CommandTests(SimpleTestCase):
|
||||||
def test_calling_a_command_with_only_empty_parameter_should_ends_gracefully(self):
|
def test_calling_a_command_with_only_empty_parameter_should_ends_gracefully(self):
|
||||||
out = StringIO()
|
out = StringIO()
|
||||||
management.call_command('hal', "--empty", stdout=out)
|
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):
|
def test_calling_command_with_app_labels_and_parameters_should_be_ok(self):
|
||||||
out = StringIO()
|
out = StringIO()
|
||||||
|
|
Loading…
Reference in New Issue