mirror of
https://github.com/django/django.git
synced 2024-12-01 15:42:04 +01:00
Rearranged some i18n tests
Compilation/extraction tests are now properly skipped when gettext commands are unavailable.
This commit is contained in:
parent
35db9d58d6
commit
0336d0d95e
@ -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):
|
@ -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):
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user