summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/IT-uses-external-dtds.ll.po21
-rw-r--r--tests/IT-uses-external-dtds.ll.xml7
-rw-r--r--tests/IT-uses-external-dtds.pot21
-rw-r--r--tests/IT-uses-external-dtds.xml7
-rw-r--r--tests/run_tests.py19
5 files changed, 72 insertions, 3 deletions
diff --git a/tests/IT-uses-external-dtds.ll.po b/tests/IT-uses-external-dtds.ll.po
new file mode 100644
index 0000000..aef9716
--- /dev/null
+++ b/tests/IT-uses-external-dtds.ll.po
@@ -0,0 +1,21 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"POT-Creation-Date: 2012-08-29 09:51-0400\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#. Put one translator per line, in the form NAME <EMAIL>, YEAR1, YEAR2
+msgctxt "_"
+msgid "translator-credits"
+msgstr ""
+
+#. (itstool) path: bookinfo/title
+#: IT-uses-external-dtds.xml:5
+msgid "The history of Leonard “Bones” McCoy"
+msgstr "La historia de Leonard “Bones” McCoy"
+
diff --git a/tests/IT-uses-external-dtds.ll.xml b/tests/IT-uses-external-dtds.ll.xml
new file mode 100644
index 0000000..e445a60
--- /dev/null
+++ b/tests/IT-uses-external-dtds.ll.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<book lang="test">
+ <bookinfo id="startrek">
+ <title>La historia de Leonard “Bones” McCoy</title>
+ </bookinfo>
+</book>
diff --git a/tests/IT-uses-external-dtds.pot b/tests/IT-uses-external-dtds.pot
new file mode 100644
index 0000000..bc8afaf
--- /dev/null
+++ b/tests/IT-uses-external-dtds.pot
@@ -0,0 +1,21 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"POT-Creation-Date: 2012-08-29 09:51-0400\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#. Put one translator per line, in the form NAME <EMAIL>, YEAR1, YEAR2
+msgctxt "_"
+msgid "translator-credits"
+msgstr ""
+
+#. (itstool) path: bookinfo/title
+#: tests/IT-uses-external-dtds.xml:5
+msgid "The history of Leonard “Bones” McCoy"
+msgstr ""
+
diff --git a/tests/IT-uses-external-dtds.xml b/tests/IT-uses-external-dtds.xml
new file mode 100644
index 0000000..bb87ea8
--- /dev/null
+++ b/tests/IT-uses-external-dtds.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="US-ASCII"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<book>
+ <bookinfo id="startrek">
+ <title>The history of Leonard &ldquo;Bones&rdquo; McCoy</title>
+ </bookinfo>
+</book>
diff --git a/tests/run_tests.py b/tests/run_tests.py
index 5c108e5..10a725e 100644
--- a/tests/run_tests.py
+++ b/tests/run_tests.py
@@ -30,10 +30,11 @@ class ItstoolTests(unittest.TestCase):
result = self.run_command("diff -u %s %s %s" % (options, f1, f2))
self.assertEqual(result['output'], "", result['output'])
- def _test_pot_generation(self, start_file, reference_pot=None, expected_status=0):
+ def _test_pot_generation(self, start_file, reference_pot=None, expected_status=0, options=None):
start_file_base = os.path.splitext(start_file)[0]
- result = self.run_command("cd %(dir)s && python itstool_test -o %(out)s %(in)s" % {
+ result = self.run_command("cd %(dir)s && python itstool_test %(opt)s -o %(out)s %(in)s" % {
'dir' : ITSTOOL_DIR,
+ 'opt' : (options or ''),
'out' : os.path.join('tests', "test.pot"),
'in' : os.path.join('tests', start_file),
}, expected_status)
@@ -70,7 +71,7 @@ class ItstoolTests(unittest.TestCase):
def _test_translation_process(self, start_file, expected_status=0, po_file=None, xml_file=None, options=None):
start_file_base = os.path.splitext(start_file)[0]
- self._test_pot_generation(start_file)
+ self._test_pot_generation(start_file, options=options)
# Compile mo and merge
if po_file is None:
@@ -176,6 +177,18 @@ class ItstoolTests(unittest.TestCase):
res = self._test_pot_generation('IT-malformed.xml', expected_status=1)
#self.assertTrue("libxml2.parserError" in res['errors'])
+ def test_IT_malformed(self):
+ """ Test that parsing XML requiring external DTD generates exception """
+ res = self._test_pot_generation('IT-uses-external-dtds.xml', expected_status=1)
+
+ def test_IT_malformed(self):
+ """ Test that parsing XML requiring external DTD generates exception """
+ res = self._test_pot_generation('IT-uses-external-dtds.xml', expected_status=0,
+ options='--load-dtd')
+
+ def test_IT_translate_with_external_dtds(self):
+ self._test_translation_process('IT-uses-external-dtds.xml', options='--load-dtd')
+
def test_IT_join_1(self):
res = self._test_translation_join('IT-join-1.xml', ('cs', 'de', 'fr'))