From d65b0f72de8d35617fe0554ddabc950c7f323eef Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Mon, 4 Feb 2013 14:35:52 +0100 Subject: Fixed #17379 -- Removed management commands deactivation of the locale. --- tests/i18n/test_extraction.py | 4 ---- .../management/commands/leave_locale_alone_false.py | 10 ---------- .../management/commands/leave_locale_alone_true.py | 10 ---------- .../management/commands/no_translations.py | 9 +++++++++ tests/user_commands/tests.py | 17 ++++++++--------- 5 files changed, 17 insertions(+), 33 deletions(-) delete mode 100644 tests/user_commands/management/commands/leave_locale_alone_false.py delete mode 100644 tests/user_commands/management/commands/leave_locale_alone_true.py create mode 100644 tests/user_commands/management/commands/no_translations.py (limited to 'tests') diff --git a/tests/i18n/test_extraction.py b/tests/i18n/test_extraction.py index b4c2ce4c9d..d9ce3b43c7 100644 --- a/tests/i18n/test_extraction.py +++ b/tests/i18n/test_extraction.py @@ -194,10 +194,6 @@ class BasicExtractorTests(ExtractorTests): self.assertMsgId("Get my line number", po_contents) self.assertLocationCommentPresent(self.PO_FILE, 'Get my line number', 'templates', 'test.html') - def test_force_en_us_locale(self): - """Value of locale-munging option used by the command is the right one""" - self.assertTrue(MakeMessagesCommand.leave_locale_alone) - def test_extraction_error(self): msg = ( 'Translation blocks must not include other block tags: blocktrans ' diff --git a/tests/user_commands/management/commands/leave_locale_alone_false.py b/tests/user_commands/management/commands/leave_locale_alone_false.py deleted file mode 100644 index aa3e20664a..0000000000 --- a/tests/user_commands/management/commands/leave_locale_alone_false.py +++ /dev/null @@ -1,10 +0,0 @@ -from django.core.management.base import BaseCommand -from django.utils import translation - - -class Command(BaseCommand): - - leave_locale_alone = False - - def handle(self, *args, **options): - return translation.get_language() diff --git a/tests/user_commands/management/commands/leave_locale_alone_true.py b/tests/user_commands/management/commands/leave_locale_alone_true.py deleted file mode 100644 index 3100a2901b..0000000000 --- a/tests/user_commands/management/commands/leave_locale_alone_true.py +++ /dev/null @@ -1,10 +0,0 @@ -from django.core.management.base import BaseCommand -from django.utils import translation - - -class Command(BaseCommand): - - leave_locale_alone = True - - def handle(self, *args, **options): - return translation.get_language() diff --git a/tests/user_commands/management/commands/no_translations.py b/tests/user_commands/management/commands/no_translations.py new file mode 100644 index 0000000000..2a8af6605b --- /dev/null +++ b/tests/user_commands/management/commands/no_translations.py @@ -0,0 +1,9 @@ +from django.core.management.base import BaseCommand, no_translations +from django.utils import translation + + +class Command(BaseCommand): + + @no_translations + def handle(self, *args, **options): + return translation.get_language() diff --git a/tests/user_commands/tests.py b/tests/user_commands/tests.py index 61e649c75a..b5d29721b4 100644 --- a/tests/user_commands/tests.py +++ b/tests/user_commands/tests.py @@ -63,17 +63,16 @@ class CommandTests(SimpleTestCase): dance.Command.requires_system_checks = True self.assertIn("CommandError", stderr.getvalue()) - def test_deactivate_locale_set(self): - # Deactivate translation when set to true + def test_no_translations_deactivate_translations(self): + """ + When the Command handle method is decorated with @no_translations, + translations are deactivated inside the command. + """ + current_locale = translation.get_language() with translation.override('pl'): - result = management.call_command('leave_locale_alone_false', stdout=StringIO()) + result = management.call_command('no_translations', stdout=StringIO()) self.assertIsNone(result) - - def test_configured_locale_preserved(self): - # Leaves locale from settings when set to false - with translation.override('pl'): - result = management.call_command('leave_locale_alone_true', stdout=StringIO()) - self.assertEqual(result, "pl") + self.assertEqual(translation.get_language(), current_locale) def test_find_command_without_PATH(self): """ -- cgit v1.3