summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJustin Hamade <justhamade@gmail.com>2014-08-08 22:47:35 +0200
committerClaude Paroz <claude@2xlibre.net>2014-08-08 22:55:45 +0200
commit98d6f128d0fd5aec0c8d49da273e369e8345a726 (patch)
tree067795b9f3fb4eda687144461850bfcd0744cb77 /tests
parentab883a3477147faece3484d50f7e38bf9b138d8f (diff)
[1.7.x] Fixed #22336 -- Added path matching for makemessages ignore option
This fixes a regression introduced by 9012a9e200. Backport of 8fe406864c from master.
Diffstat (limited to 'tests')
-rw-r--r--tests/i18n/commands/templates/subdir/ignored.html2
-rw-r--r--tests/i18n/test_extraction.py46
2 files changed, 31 insertions, 17 deletions
diff --git a/tests/i18n/commands/templates/subdir/ignored.html b/tests/i18n/commands/templates/subdir/ignored.html
new file mode 100644
index 0000000000..d36a6fe881
--- /dev/null
+++ b/tests/i18n/commands/templates/subdir/ignored.html
@@ -0,0 +1,2 @@
+{% load i18n %}
+{% trans "This subdir should be ignored too." %}
diff --git a/tests/i18n/test_extraction.py b/tests/i18n/test_extraction.py
index 295388ec5e..2809a727bb 100644
--- a/tests/i18n/test_extraction.py
+++ b/tests/i18n/test_extraction.py
@@ -342,35 +342,47 @@ class JavascriptExtractorTests(ExtractorTests):
class IgnoredExtractorTests(ExtractorTests):
- def test_ignore_option(self):
+ def _run_makemessages(self, **options):
os.chdir(self.test_dir)
- ignore_patterns = [
- os.path.join('ignore_dir', '*'),
- 'xxx_*',
- ]
stdout = StringIO()
management.call_command('makemessages', locale=[LOCALE], verbosity=2,
- ignore_patterns=ignore_patterns, stdout=stdout)
+ stdout=stdout, **options)
data = stdout.getvalue()
- self.assertTrue("ignoring directory ignore_dir" in data)
- self.assertTrue("ignoring file xxx_ignored.html" in data)
self.assertTrue(os.path.exists(self.PO_FILE))
with open(self.PO_FILE, 'r') as fp:
po_contents = fp.read()
- self.assertMsgId('This literal should be included.', po_contents)
- self.assertNotMsgId('This should be ignored.', po_contents)
- self.assertNotMsgId('This should be ignored too.', po_contents)
+ return data, po_contents
+
+ def test_ignore_directory(self):
+ out, po_contents = self._run_makemessages(ignore_patterns=[
+ os.path.join('ignore_dir', '*'),
+ ])
+ self.assertTrue("ignoring directory ignore_dir" in out)
+ self.assertMsgId('This literal should be included.', po_contents)
+ self.assertNotMsgId('This should be ignored.', po_contents)
+
+ def test_ignore_subdirectory(self):
+ out, po_contents = self._run_makemessages(ignore_patterns=[
+ 'templates/*/ignore.html',
+ 'templates/subdir/*',
+ ])
+ self.assertTrue("ignoring directory subdir" in out)
+ self.assertNotMsgId('This subdir should be ignored too.', po_contents)
+
+ def test_ignore_file_patterns(self):
+ out, po_contents = self._run_makemessages(ignore_patterns=[
+ 'xxx_*',
+ ])
+ self.assertTrue("ignoring file xxx_ignored.html" in out)
+ self.assertNotMsgId('This should be ignored too.', po_contents)
@override_settings(
STATIC_ROOT=os.path.join(this_directory, 'commands', 'static_root/'),
MEDIA_ROOT=os.path.join(this_directory, 'commands', 'media_root/'))
def test_media_static_dirs_ignored(self):
- os.chdir(self.test_dir)
- stdout = StringIO()
- management.call_command('makemessages', locale=[LOCALE], verbosity=2, stdout=stdout)
- data = stdout.getvalue()
- self.assertIn("ignoring directory static_root", data)
- self.assertIn("ignoring directory media_root", data)
+ out, _ = self._run_makemessages()
+ self.assertIn("ignoring directory static_root", out)
+ self.assertIn("ignoring directory media_root", out)
class SymlinkExtractorTests(ExtractorTests):