summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJannis Leidel <jannis@leidel.info>2010-02-16 12:15:04 +0000
committerJannis Leidel <jannis@leidel.info>2010-02-16 12:15:04 +0000
commiteb26c9686bc1f9b9b5bcd10e861fc7d055845209 (patch)
tree650e90f9a76dfdcdb782ca20f8c0d003703d76f3 /tests
parentfef575a7f927fd2b080abee63a600d333c26e52d (diff)
Fixed #7050 - Allow the makemessages command to optionally ignore paths when examining source code and templates for translation strings.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12444 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/makemessages/ignore_dir/ignored.html2
-rw-r--r--tests/regressiontests/makemessages/tests.py17
2 files changed, 19 insertions, 0 deletions
diff --git a/tests/regressiontests/makemessages/ignore_dir/ignored.html b/tests/regressiontests/makemessages/ignore_dir/ignored.html
new file mode 100644
index 0000000000..6a296787ef
--- /dev/null
+++ b/tests/regressiontests/makemessages/ignore_dir/ignored.html
@@ -0,0 +1,2 @@
+{% load i18n %}
+{% trans "This should be ignored." %}
diff --git a/tests/regressiontests/makemessages/tests.py b/tests/regressiontests/makemessages/tests.py
index 84eed2edeb..4be31a717b 100644
--- a/tests/regressiontests/makemessages/tests.py
+++ b/tests/regressiontests/makemessages/tests.py
@@ -28,6 +28,9 @@ class ExtractorTests(TestCase):
def assertMsgId(self, msgid, s):
return self.assert_(re.search('^msgid "%s"' % msgid, s, re.MULTILINE))
+ def assertNotMsgId(self, msgid, s):
+ return self.assert_(not re.search('^msgid "%s"' % msgid, s, re.MULTILINE))
+
class JavascriptExtractorTests(ExtractorTests):
@@ -41,6 +44,20 @@ class JavascriptExtractorTests(ExtractorTests):
self.assertMsgId('This literal should be included.', po_contents)
self.assertMsgId('This one as well.', po_contents)
+
+class IgnoredExtractorTests(ExtractorTests):
+
+ PO_FILE='locale/%s/LC_MESSAGES/django.po' % LOCALE
+
+ def test_ignore_option(self):
+ os.chdir(self.test_dir)
+ management.call_command('makemessages', locale=LOCALE, verbosity=0, ignore_patterns=['ignore_dir/*'])
+ self.assert_(os.path.exists(self.PO_FILE))
+ po_contents = open(self.PO_FILE, 'r').read()
+ self.assertMsgId('This literal should be included.', po_contents)
+ self.assertNotMsgId('This should be ignored.', po_contents)
+
+
class SymlinkExtractorTests(ExtractorTests):
PO_FILE='locale/%s/LC_MESSAGES/django.po' % LOCALE