summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/i18n/test_compilation.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/i18n/test_compilation.py b/tests/i18n/test_compilation.py
index 11266b7a58..aa457f21f6 100644
--- a/tests/i18n/test_compilation.py
+++ b/tests/i18n/test_compilation.py
@@ -3,6 +3,7 @@ import os
import stat
import unittest
from io import StringIO
+from pathlib import Path
from subprocess import Popen
from unittest import mock
@@ -134,6 +135,44 @@ class ExcludedLocaleCompilationTests(MessageCompilationTests):
self.assertFalse(os.path.exists(self.MO_FILE % 'it'))
+class IgnoreDirectoryCompilationTests(MessageCompilationTests):
+ # Reuse the exclude directory since it contains some locale fixtures.
+ work_subdir = 'exclude'
+ MO_FILE = '%s/%s/LC_MESSAGES/django.mo'
+ CACHE_DIR = Path('cache') / 'locale'
+ NESTED_DIR = Path('outdated') / 'v1' / 'locale'
+
+ def setUp(self):
+ super().setUp()
+ copytree('canned_locale', 'locale')
+ copytree('canned_locale', self.CACHE_DIR)
+ copytree('canned_locale', self.NESTED_DIR)
+
+ def assertAllExist(self, dir, langs):
+ self.assertTrue(all(Path(self.MO_FILE % (dir, lang)).exists() for lang in langs))
+
+ def assertNoneExist(self, dir, langs):
+ self.assertTrue(all(Path(self.MO_FILE % (dir, lang)).exists() is False for lang in langs))
+
+ def test_one_locale_dir_ignored(self):
+ call_command('compilemessages', ignore=['cache'], verbosity=0)
+ self.assertAllExist('locale', ['en', 'fr', 'it'])
+ self.assertNoneExist(self.CACHE_DIR, ['en', 'fr', 'it'])
+ self.assertAllExist(self.NESTED_DIR, ['en', 'fr', 'it'])
+
+ def test_multiple_locale_dirs_ignored(self):
+ call_command('compilemessages', ignore=['cache/locale', 'outdated'], verbosity=0)
+ self.assertAllExist('locale', ['en', 'fr', 'it'])
+ self.assertNoneExist(self.CACHE_DIR, ['en', 'fr', 'it'])
+ self.assertNoneExist(self.NESTED_DIR, ['en', 'fr', 'it'])
+
+ def test_ignores_based_on_pattern(self):
+ call_command('compilemessages', ignore=['*/locale'], verbosity=0)
+ self.assertAllExist('locale', ['en', 'fr', 'it'])
+ self.assertNoneExist(self.CACHE_DIR, ['en', 'fr', 'it'])
+ self.assertNoneExist(self.NESTED_DIR, ['en', 'fr', 'it'])
+
+
class CompilationErrorHandling(MessageCompilationTests):
def test_error_reported_by_msgfmt(self):
# po file contains wrong po formatting.