diff options
| author | Claude Paroz <claude@2xlibre.net> | 2013-10-28 14:17:48 +0100 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2013-10-28 14:17:48 +0100 |
| commit | 0336d0d95e8ce9eb8479ad556d53ada78d06b59c (patch) | |
| tree | 3c393039711e359c0f6562532fd0153fdf51b2a9 /tests | |
| parent | 35db9d58d691d90b0c33e18b613067609d9e638f (diff) | |
Rearranged some i18n tests
Compilation/extraction tests are now properly skipped when gettext
commands are unavailable.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/i18n/test_compilation.py (renamed from tests/i18n/commands/compilation.py) | 6 | ||||
| -rw-r--r-- | tests/i18n/test_extraction.py (renamed from tests/i18n/commands/extraction.py) | 11 | ||||
| -rw-r--r-- | tests/i18n/tests.py | 11 |
3 files changed, 12 insertions, 16 deletions
diff --git a/tests/i18n/commands/compilation.py b/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 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 |
