summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorrsiemens <ryanjsiemens@gmail.com>2019-01-27 11:35:17 -0800
committerTim Graham <timograham@gmail.com>2019-01-28 18:23:41 -0500
commita168e5616c85dfd658f20ffbb69a3872c2029dd3 (patch)
tree30cc9fa848f7105633097eeda4d1dca8a3c45fa3 /tests
parentbc9f0b32039325e96683e0e4a3ea84428a336c8d (diff)
Fixed #29973 -- Added compilemessages --ignore option.
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.