diff options
Diffstat (limited to 'tests/user_commands/tests.py')
| -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): """ |
