diff options
author | Claude Paroz <claude@2xlibre.net> | 2016-02-13 18:14:36 +0100 |
---|---|---|
committer | Claude Paroz <claude@2xlibre.net> | 2016-02-23 09:12:12 +0100 |
commit | b46c0ea6c87f006f9ef0ccc5d8c0fa2445fb4156 (patch) | |
tree | b2ad02486c71376062e637b21272f40b24bf56e9 /tests | |
parent | 47b5a6a43c400619ca471de02e9f5fcc9f30d8bf (diff) | |
download | django-b46c0ea6c87f006f9ef0ccc5d8c0fa2445fb4156.tar.gz |
Fixed #26190 -- Returned handle() result from call_command
Thanks Tim Graham for the review.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/user_commands/tests.py | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/tests/user_commands/tests.py b/tests/user_commands/tests.py index 9c27fb6669..f4e6c66353 100644 --- a/tests/user_commands/tests.py +++ b/tests/user_commands/tests.py @@ -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): """ |