mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #26190 -- Returned handle() result from call_command
Thanks Tim Graham for the review.
This commit is contained in:
@@ -61,17 +61,15 @@ class CommandTests(SimpleTestCase):
|
||||
|
||||
def test_deactivate_locale_set(self):
|
||||
# Deactivate translation when set to true
|
||||
out = StringIO()
|
||||
with translation.override('pl'):
|
||||
management.call_command('leave_locale_alone_false', stdout=out)
|
||||
self.assertEqual(out.getvalue(), "")
|
||||
result = management.call_command('leave_locale_alone_false', stdout=StringIO())
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_configured_locale_preserved(self):
|
||||
# Leaves locale from settings when set to false
|
||||
out = StringIO()
|
||||
with translation.override('pl'):
|
||||
management.call_command('leave_locale_alone_true', stdout=out)
|
||||
self.assertEqual(out.getvalue(), "pl\n")
|
||||
result = management.call_command('leave_locale_alone_true', stdout=StringIO())
|
||||
self.assertEqual(result, "pl")
|
||||
|
||||
def test_find_command_without_PATH(self):
|
||||
"""
|
||||
@@ -132,16 +130,13 @@ class CommandTests(SimpleTestCase):
|
||||
self.assertIn("Dave, my mind is going. I can feel it. I can feel it.\n", out.getvalue())
|
||||
|
||||
def test_calling_a_command_with_no_app_labels_and_parameters_should_raise_a_command_error(self):
|
||||
out = StringIO()
|
||||
with self.assertRaises(CommandError):
|
||||
management.call_command('hal', stdout=out)
|
||||
management.call_command('hal', stdout=StringIO())
|
||||
|
||||
def test_output_transaction(self):
|
||||
out = StringIO()
|
||||
management.call_command('transaction', stdout=out, no_color=True)
|
||||
output = out.getvalue().strip()
|
||||
self.assertTrue(output.startswith(connection.ops.start_transaction_sql()))
|
||||
self.assertTrue(output.endswith(connection.ops.end_transaction_sql()))
|
||||
output = management.call_command('transaction', stdout=StringIO(), no_color=True)
|
||||
self.assertTrue(output.strip().startswith(connection.ops.start_transaction_sql()))
|
||||
self.assertTrue(output.strip().endswith(connection.ops.end_transaction_sql()))
|
||||
|
||||
def test_call_command_no_checks(self):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user