summaryrefslogtreecommitdiff
path: root/tests/run_tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/run_tests.py')
-rw-r--r--tests/run_tests.py40
1 files changed, 38 insertions, 2 deletions
diff --git a/tests/run_tests.py b/tests/run_tests.py
index c14a26d..78d6e6a 100644
--- a/tests/run_tests.py
+++ b/tests/run_tests.py
@@ -1,6 +1,7 @@
import os
import shutil
from subprocess import Popen, PIPE, call
+import sys
import unittest
TEST_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -15,6 +16,7 @@ class ItstoolTests(unittest.TestCase):
def run_command(self, cmd):
""" Helper method to run a shell command """
+ # Set stdout = sys.stdout to debug a subprocess if you set a breakpoint in it
pipe = Popen(cmd, shell=True, env=os.environ, stdin=None, stdout=PIPE, stderr=PIPE)
(output, errout) = pipe.communicate()
status = pipe.returncode
@@ -28,7 +30,7 @@ class ItstoolTests(unittest.TestCase):
result = self.run_command("diff -u %s %s %s" % (options, f1, f2))
return self.assertEqual(result[1], "", result[1])
- def _test_translation_process(self, start_file):
+ def _test_pot_generation(self, start_file, reference_pot=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" % {
'dir' : ITSTOOL_DIR,
@@ -36,10 +38,15 @@ class ItstoolTests(unittest.TestCase):
'in' : os.path.join('tests', start_file),
})
# If a reference pot file is present, test the output with this file
- reference_pot = start_file_base + ".pot"
+ if reference_pot is None:
+ reference_pot = start_file_base + ".pot"
if os.path.exists(reference_pot):
self.assertFilesEqual(os.path.join(TEST_DIR, "test.pot"), os.path.join(TEST_DIR, reference_pot))
+ def _test_translation_process(self, start_file):
+ start_file_base = os.path.splitext(start_file)[0]
+ self._test_pot_generation(start_file)
+
# Compile mo and merge
self.run_command("cd %(dir)s && msgfmt -o test.mo %(base)s.ll.po" % {'dir': TEST_DIR, 'base': start_file_base})
res = self.run_command("cd %(dir)s && python itstool_test -m %(mo)s -o %(res)s %(src)s" % {
@@ -51,6 +58,28 @@ class ItstoolTests(unittest.TestCase):
self.assertFilesEqual(os.path.join(TEST_DIR, "test.xml"), os.path.join(TEST_DIR, "%s.ll.xml" % start_file_base))
+ def test_locnotes(self):
+ # FIXME: only the third note appears currently, as attribute extraction is not yet implemented
+ self._test_pot_generation('LocNote1.xml')
+
+ def test_locnotes_external(self):
+ # FIXME: only the third note appears currently, as attribute extraction is not yet implemented
+ self._test_pot_generation('LocNote2.xml', reference_pot='LocNote1.pot')
+
+ def test_locnotes_ontags(self):
+ self._test_pot_generation('LocNote3.xml')
+
+ def test_locnotes_onspan(self):
+ self._test_pot_generation('LocNote4.xml')
+
+ def test_locnotes_pointer(self):
+ self._test_pot_generation('EX-locNotePointer-attribute-1.xml')
+
+ def test_locnotes_refpointer(self):
+ self._test_pot_generation('EX-locNoteRefPointer-attribute-1.xml')
+
+ # FIXME: test EX-locNote-selector-2.xml when parent locNotes will propagate to children
+
def test_unicode_markup(self):
self._test_translation_process('Translate1.xml')
@@ -76,6 +105,13 @@ class ItstoolTests(unittest.TestCase):
def xx_test_attribute_selectable(self):
self._test_translation_process('TranslateGlobal.xml')
+ def test_withintext(self):
+ self._test_translation_process('WithinText1.xml')
+
+ def test_withintext_linkedrules(self):
+ self._test_translation_process('WithinText2.xml')
+
+
class ITSTestRunner(unittest.TextTestRunner):
def run(self, test):
# Global setup