summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorIlja Maas <iljamaas@dreamsolution.nl>2014-11-16 22:16:41 +0100
committerClaude Paroz <claude@2xlibre.net>2014-11-17 09:21:24 +0100
commitbb4a92d7845878b2ce0c4a5ca154cb4db22f7bad (patch)
tree12163a2aaf2187254b30a8eaef31d200bbb02d94 /tests
parent580e9d0045d1b6ffaf7d52751a17b1a5a6075705 (diff)
Fixed #23840 -- Fixed makemessages find_files method
Changed the handling of extensions to be used for gettext. Now obeying the --extension argument. find_files now only find the given or default extensions and puts only these in the TranslatableFiles. As a result there are no more confusing messages for filetypes (extension) not handled by makemessages.
Diffstat (limited to 'tests')
-rw-r--r--tests/i18n/test_extraction.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/i18n/test_extraction.py b/tests/i18n/test_extraction.py
index b2972105c7..ded627e941 100644
--- a/tests/i18n/test_extraction.py
+++ b/tests/i18n/test_extraction.py
@@ -344,6 +344,30 @@ class BasicExtractorTests(ExtractorTests):
self.assertMsgId("Translatable literal #9j", po_contents)
+ def test_makemessages_find_files(self):
+ """
+ Test that find_files only discover files having the proper extensions.
+ """
+ from django.core.management.commands.makemessages import Command
+ cmd = Command()
+ cmd.ignore_patterns = ['CVS', '.*', '*~', '*.pyc']
+ cmd.symlinks = False
+ cmd.domain = 'django'
+ cmd.extensions = ['html', 'txt', 'py']
+ cmd.verbosity = 0
+ cmd.locale_paths = []
+ cmd.default_locale_path = os.path.join(self.test_dir, 'locale')
+ found_files = cmd.find_files(self.test_dir)
+ found_exts = set([os.path.splitext(tfile.file)[1] for tfile in found_files])
+ self.assertEqual(found_exts.difference({'.py', '.html', '.txt'}), set())
+
+ cmd.extensions = ['js']
+ cmd.domain = 'djangojs'
+ found_files = cmd.find_files(self.test_dir)
+ found_exts = set([os.path.splitext(tfile.file)[1] for tfile in found_files])
+ self.assertEqual(found_exts.difference({'.js'}), set())
+
+
class JavascriptExtractorTests(ExtractorTests):
PO_FILE = 'locale/%s/LC_MESSAGES/djangojs.po' % LOCALE