diff --git a/tests/i18n/commands/compilation.py b/tests/i18n/test_compilation.py similarity index 93% rename from tests/i18n/commands/compilation.py rename to tests/i18n/test_compilation.py index 7a159ad1fc..9c10200f9c 100644 --- a/tests/i18n/commands/compilation.py +++ b/tests/i18n/test_compilation.py @@ -1,15 +1,19 @@ import os +import unittest from django.core.management import call_command, CommandError +from django.core.management.utils import find_command from django.test import SimpleTestCase from django.test.utils import override_settings from django.utils import translation from django.utils._os import upath from django.utils.six import StringIO -test_dir = os.path.abspath(os.path.dirname(upath(__file__))) +test_dir = os.path.abspath(os.path.join(os.path.dirname(upath(__file__)), 'commands')) +has_msgfmt = find_command('msgfmt') +@unittest.skipUnless(has_msgfmt, 'msgfmt is mandatory for compilation tests') class MessageCompilationTests(SimpleTestCase): def setUp(self): diff --git a/tests/i18n/commands/extraction.py b/tests/i18n/test_extraction.py similarity index 98% rename from tests/i18n/commands/extraction.py rename to tests/i18n/test_extraction.py index 51d7ac0731..04bc0a8632 100644 --- a/tests/i18n/commands/extraction.py +++ b/tests/i18n/test_extraction.py @@ -5,10 +5,11 @@ import io import os import re import shutil -from unittest import SkipTest +from unittest import SkipTest, skipUnless import warnings from django.core import management +from django.core.management.utils import find_command from django.test import SimpleTestCase from django.utils.encoding import force_text from django.utils._os import upath @@ -18,14 +19,17 @@ from django.utils.translation import TranslatorCommentWarning LOCALE = 'de' +has_xgettext = find_command('xgettext') +@skipUnless(has_xgettext, 'xgettext is mandatory for extraction tests') class ExtractorTests(SimpleTestCase): PO_FILE = 'locale/%s/LC_MESSAGES/django.po' % LOCALE def setUp(self): self._cwd = os.getcwd() - self.test_dir = os.path.abspath(os.path.dirname(upath(__file__))) + self.test_dir = os.path.abspath( + os.path.join(os.path.dirname(upath(__file__)), 'commands')) def _rmrf(self, dname): if os.path.commonprefix([self.test_dir, os.path.abspath(dname)]) != self.test_dir: @@ -302,8 +306,7 @@ class IgnoredExtractorTests(ExtractorTests): class SymlinkExtractorTests(ExtractorTests): def setUp(self): - self._cwd = os.getcwd() - self.test_dir = os.path.abspath(os.path.dirname(upath(__file__))) + super(SymlinkExtractorTests, self).setUp() self.symlinked_dir = os.path.join(self.test_dir, 'templates_symlinked') def tearDown(self): diff --git a/tests/i18n/tests.py b/tests/i18n/tests.py index 1dbd502ed8..0f9bf7e4ed 100644 --- a/tests/i18n/tests.py +++ b/tests/i18n/tests.py @@ -9,7 +9,6 @@ import pickle from threading import local from django.conf import settings -from django.core.management.utils import find_command from django.template import Template, Context from django.template.base import TemplateSyntaxError from django.test import TestCase, RequestFactory @@ -34,16 +33,6 @@ from django.utils.translation import (activate, deactivate, npgettext, npgettext_lazy, check_for_language) -if find_command('xgettext'): - from .commands.extraction import (ExtractorTests, BasicExtractorTests, - JavascriptExtractorTests, IgnoredExtractorTests, SymlinkExtractorTests, - CopyPluralFormsExtractorTests, NoWrapExtractorTests, - LocationCommentsTests, KeepPotFileExtractorTests, - MultipleLocaleExtractionTests) -if find_command('msgfmt'): - from .commands.compilation import (PoFileTests, PoFileContentsTests, - PercentRenderingTests, MultipleLocaleCompilationTests, - CompilationErrorHandling) from .forms import I18nForm, SelectDateForm, SelectDateWidget, CompanyForm from .models import Company, TestModel