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.py237
1 files changed, 190 insertions, 47 deletions
diff --git a/tests/run_tests.py b/tests/run_tests.py
index 48bd25f..6939ff6 100644
--- a/tests/run_tests.py
+++ b/tests/run_tests.py
@@ -32,7 +32,7 @@ class ItstoolTests(unittest.TestCase):
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 %(opt)s -o %(out)s %(in)s" % {
+ result = self.run_command("cd %(dir)s && python itstool_test %(opt)s -n -o %(out)s %(in)s" % {
'dir' : ITSTOOL_DIR,
'opt' : (options or ''),
'out' : os.path.join('tests', "test.pot"),
@@ -57,14 +57,14 @@ class ItstoolTests(unittest.TestCase):
mo_file = '%s.mo' % lang
self.run_command("cd %(dir)s && msgfmt -o %(mo_file)s %(po_file)s" %
{'dir': TEST_DIR, 'mo_file': mo_file, 'po_file': po_file})
- result = self.run_command("cd %(dir)s && python itstool_test -o%(res)s -j %(src)s %(mo)s" % {
+ result = self.run_command("cd %(dir)s && python itstool_test -n -o%(res)s -j %(src)s %(mo)s" % {
'dir': ITSTOOL_DIR,
'res': os.path.join(TEST_DIR, 'test.xml'),
'src': os.path.join(TEST_DIR, start_file),
'mo': ' '.join([os.path.join(TEST_DIR, '%s.mo' % lang) for lang in langs])
})
if xml_file is None:
- xml_file = '%s.ll.xml' % start_file_base
+ xml_file = '%s.joined.xml' % start_file_base
self.assertFilesEqual(
os.path.join(TEST_DIR, 'test.xml'),
os.path.join(TEST_DIR, xml_file)
@@ -72,83 +72,222 @@ class ItstoolTests(unittest.TestCase):
return result
- def _test_translation_process(self, start_file, expected_status=0, po_file=None, xml_file=None, options=None):
+ def _test_translation_process(self, start_file, expected_status=0, outputs=None, options=None):
start_file_base = os.path.splitext(start_file)[0]
self._test_pot_generation(start_file, options=options)
- # Compile mo and merge
- if po_file is None:
- po_file = "%s.ll.po" % start_file_base
- self.run_command("cd %(dir)s && msgfmt -o test.mo %(po_file)s" % {'dir': TEST_DIR, 'po_file': po_file})
- result = self.run_command("cd %(dir)s && python itstool_test %(opt)s -m %(mo)s -o %(res)s %(src)s" % {
- 'dir': ITSTOOL_DIR,
- 'opt': (options or ''),
- 'mo' : os.path.join(TEST_DIR, "test.mo"),
- 'res': os.path.join(TEST_DIR, "test.xml"),
- 'src': os.path.join(TEST_DIR, start_file),
- }, expected_status)
- if xml_file is None:
- xml_file = "%s.ll.xml" % start_file_base
- if (expected_status == 0):
- self.assertFilesEqual(
- os.path.join(TEST_DIR, "test.xml"),
- os.path.join(TEST_DIR, xml_file)
- )
- return result
+ if outputs is None:
+ outputs = [("%s.ll.po" % start_file_base, "%s.ll.xml" % start_file_base, 'll')]
+ for po_file, xml_file, lang in outputs:
+ self.run_command("cd %(dir)s && msgfmt -o test.mo %(po_file)s" % {'dir': TEST_DIR, 'po_file': po_file})
+ self.run_command("cd %(dir)s && python itstool_test -n %(opt)s -l %(lc)s -m %(mo)s -o %(res)s %(src)s" % {
+ 'dir': ITSTOOL_DIR,
+ 'opt': (options or ''),
+ 'lc' : lang,
+ 'mo' : os.path.join(TEST_DIR, "test.mo"),
+ 'res': os.path.join(TEST_DIR, "test.xml"),
+ 'src': os.path.join(TEST_DIR, start_file),
+ }, expected_status)
+ if (expected_status == 0):
+ self.assertFilesEqual(
+ os.path.join(TEST_DIR, "test.xml"),
+ os.path.join(TEST_DIR, xml_file)
+ )
def test_LocNote1(self):
# FIXME: only the third note appears currently, as notes on subnodes don't propagate to parent nodes
- self._test_pot_generation('LocNote1.xml')
+ self._test_pot_generation('LocNote/LocNote1.xml')
def test_LocNote2(self):
# FIXME: only the third note appears currently, as notes on subnodes don't propagate to parent nodes
- self._test_pot_generation('LocNote2.xml')
+ self._test_pot_generation('LocNote/LocNote2.xml')
def test_LocNote3(self):
- self._test_pot_generation('LocNote3.xml')
+ self._test_pot_generation('LocNote/LocNote3.xml')
def test_LocNote4(self):
- self._test_pot_generation('LocNote4.xml')
+ self._test_pot_generation('LocNote/LocNote4.xml')
def test_EX_locNote_element_1(self):
- self._test_pot_generation('EX-locNote-element-1.xml')
+ self._test_pot_generation('LocNote/EX-locNote-element-1.xml')
def test_EX_locNote_selector_2(self):
- self._test_pot_generation('EX-locNote-selector-2.xml')
+ self._test_pot_generation('LocNote/EX-locNote-selector-2.xml')
def test_EX_locNotePointer_attribute_1(self):
- self._test_pot_generation('EX-locNotePointer-attribute-1.xml')
+ self._test_pot_generation('LocNote/EX-locNotePointer-attribute-1.xml')
def test_EX_locNoteRef_attribute_1(self):
- self._test_pot_generation('EX-locNoteRef-attribute-1.xml')
+ self._test_pot_generation('LocNote/EX-locNoteRef-attribute-1.xml')
def test_EX_locNoteRefPointer_attribute_1(self):
- self._test_pot_generation('EX-locNoteRefPointer-attribute-1.xml')
+ self._test_pot_generation('LocNote/EX-locNoteRefPointer-attribute-1.xml')
+
+ def test_PreserveSpace1(self):
+ self._test_pot_generation('preservespace1xml.xml')
+
+ def test_PreserveSpace2(self):
+ self._test_pot_generation('preservespace2xml.xml')
+
+ def test_PreserveSpace3(self):
+ self._test_pot_generation('preservespace3xml.xml')
+
+ def test_PreserveSpace4(self):
+ self._test_pot_generation('preservespace4xml.xml')
def test_Translate1(self):
- self._test_translation_process('Translate1.xml')
+ self._test_translation_process('Translate/Translate1.xml')
def test_Translate2(self):
- self._test_translation_process('Translate2.xml')
+ self._test_translation_process('Translate/Translate2.xml')
def test_Translate3(self):
- self._test_translation_process('Translate3.xml')
+ self._test_translation_process('Translate/Translate3.xml')
def test_Translate4(self):
- self._test_translation_process('Translate4.xml')
+ self._test_translation_process('Translate/Translate4.xml')
def test_Translate5(self):
- self._test_translation_process('Translate5.xml')
+ self._test_translation_process('Translate/Translate5.xml')
def test_Translate6(self):
- self._test_translation_process('Translate6.xml')
+ self._test_translation_process('Translate/Translate6.xml')
def test_Translate7(self):
- self._test_translation_process('Translate7.xml')
+ self._test_translation_process('Translate/Translate7.xml')
def test_TranslateGlobal(self):
- self._test_translation_process('TranslateGlobal.xml')
+ self._test_translation_process('Translate/TranslateGlobal.xml')
+
+ def test_ExternalResource1(self):
+ self._test_pot_generation('ExternalResource/ExternalResource1Xml.xml')
+
+ def test_ExternalResource2(self):
+ self._test_pot_generation('ExternalResource/ExternalResource2Xml.xml')
+
+ def test_ExternalResource3(self):
+ self._test_pot_generation('ExternalResource/ExternalResource3Xml.xml')
+
+ def test_ExternalResource1Attr(self):
+ self._test_pot_generation('ExternalResource/Attr/ExternalResource1AttrXml.xml')
+
+ def test_ExternalResource2Attr(self):
+ self._test_pot_generation('ExternalResource/Attr/ExternalResource2AttrXml.xml')
+
+ def test_ExternalResource3Attr(self):
+ self._test_pot_generation('ExternalResource/Attr/ExternalResource3AttrXml.xml')
+
+ def test_IdValue1(self):
+ self._test_pot_generation('IdValue/idvalue1xml.xml')
+
+ def test_IdValue2(self):
+ self._test_pot_generation('IdValue/idvalue2xml.xml')
+
+ def test_IdValue3(self):
+ self._test_pot_generation('IdValue/idvalue3xml.xml')
+
+ def test_Locale1(self):
+ self._test_translation_process('LocaleFilter/Locale1Xml.xml',
+ outputs=[('LocaleFilter/Locale1Xml.fr_FR.po',
+ 'LocaleFilter/Locale1Xml.fr_FR.xml',
+ 'fr-FR'),
+ ('LocaleFilter/Locale1Xml.fr_CA.po',
+ 'LocaleFilter/Locale1Xml.fr_CA.xml',
+ 'fr-CA'),
+ ('LocaleFilter/Locale1Xml.fr_CH.po',
+ 'LocaleFilter/Locale1Xml.fr_CH.xml',
+ 'fr-CH')])
+
+ def test_Locale2(self):
+ self._test_translation_process('LocaleFilter/Locale2Xml.xml',
+ outputs=[('LocaleFilter/Locale2Xml.fr_FR.po',
+ 'LocaleFilter/Locale2Xml.fr_FR.xml',
+ 'fr-FR'),
+ ('LocaleFilter/Locale2Xml.fr_CA.po',
+ 'LocaleFilter/Locale2Xml.fr_CA.xml',
+ 'fr-CA'),
+ ('LocaleFilter/Locale2Xml.fr_CH.po',
+ 'LocaleFilter/Locale2Xml.fr_CH.xml',
+ 'fr-CH')])
+
+ def test_Locale3(self):
+ self._test_translation_process('LocaleFilter/Locale3Xml.xml',
+ outputs=[('LocaleFilter/Locale3Xml.fr_FR.po',
+ 'LocaleFilter/Locale3Xml.fr_FR.xml',
+ 'fr-FR'),
+ ('LocaleFilter/Locale3Xml.fr_CA.po',
+ 'LocaleFilter/Locale3Xml.fr_CA.xml',
+ 'fr-CA'),
+ ('LocaleFilter/Locale3Xml.fr_CH.po',
+ 'LocaleFilter/Locale3Xml.fr_CH.xml',
+ 'fr-CH')])
+
+ def test_Locale4(self):
+ self._test_translation_process('LocaleFilter/Locale4Xml.xml',
+ outputs=[('LocaleFilter/Locale4Xml.fr_FR.po',
+ 'LocaleFilter/Locale4Xml.fr_FR.xml',
+ 'fr-FR'),
+ ('LocaleFilter/Locale4Xml.fr_CA.po',
+ 'LocaleFilter/Locale4Xml.fr_CA.xml',
+ 'fr-CA'),
+ ('LocaleFilter/Locale4Xml.fr_CH.po',
+ 'LocaleFilter/Locale4Xml.fr_CH.xml',
+ 'fr-CH')])
+
+ def test_Locale5(self):
+ self._test_translation_process('LocaleFilter/Locale5Xml.xml',
+ outputs=[('LocaleFilter/Locale5Xml.fr_FR.po',
+ 'LocaleFilter/Locale5Xml.fr_FR.xml',
+ 'fr-FR'),
+ ('LocaleFilter/Locale5Xml.fr_CA.po',
+ 'LocaleFilter/Locale5Xml.fr_CA.xml',
+ 'fr-CA'),
+ ('LocaleFilter/Locale5Xml.fr_CH.po',
+ 'LocaleFilter/Locale5Xml.fr_CH.xml',
+ 'fr-CH')])
+
+ def test_Locale6(self):
+ self._test_translation_process('LocaleFilter/Locale6Xml.xml',
+ outputs=[('LocaleFilter/Locale6Xml.fr_FR.po',
+ 'LocaleFilter/Locale6Xml.fr_FR.xml',
+ 'fr-FR'),
+ ('LocaleFilter/Locale6Xml.fr_CA.po',
+ 'LocaleFilter/Locale6Xml.fr_CA.xml',
+ 'fr-CA'),
+ ('LocaleFilter/Locale6Xml.fr_CH.po',
+ 'LocaleFilter/Locale6Xml.fr_CH.xml',
+ 'fr-CH')])
+
+ def test_Locale1_join(self):
+ self._test_translation_join('LocaleFilter/Locale1Xml.xml',
+ ('fr_FR', 'fr_CA', 'fr_CH'))
+
+ def test_Locale2_join(self):
+ self._test_translation_join('LocaleFilter/Locale2Xml.xml',
+ ('fr_FR', 'fr_CA', 'fr_CH'))
+
+ def test_Locale3_join(self):
+ self._test_translation_join('LocaleFilter/Locale3Xml.xml',
+ ('fr_FR', 'fr_CA', 'fr_CH'))
+
+ def test_Locale4_join(self):
+ self._test_translation_join('LocaleFilter/Locale4Xml.xml',
+ ('fr_FR', 'fr_CA', 'fr_CH'))
+
+ def test_Locale5_join(self):
+ self._test_translation_join('LocaleFilter/Locale5Xml.xml',
+ ('fr_FR', 'fr_CA', 'fr_CH'))
+
+ def test_Locale6_join(self):
+ self._test_translation_join('LocaleFilter/Locale6Xml.xml',
+ ('fr_FR', 'fr_CA', 'fr_CH'))
+
+ def test_elementwithintextlocalitsSpanXml(self):
+ self._test_translation_process('elementwithintextlocalitsSpanXml.xml')
+
+ def test_elementwithintextLocalXml(self):
+ self._test_translation_process('elementwithintextLocalXml.xml')
def test_WithinText1(self):
self._test_translation_process('WithinText1.xml')
@@ -156,6 +295,9 @@ class ItstoolTests(unittest.TestCase):
def test_WithinText2(self):
self._test_translation_process('WithinText2.xml')
+ def test_IT_externalRef1(self):
+ self._test_translation_process('IT-externalRef1.xml')
+
def test_IT_locNote_inline(self):
self._test_pot_generation('IT-locNote-inline.xml')
@@ -201,20 +343,21 @@ class ItstoolTests(unittest.TestCase):
self._test_translation_process('IT-keep-entities-2.xml', options='--keep-entities')
def test_IT_join_1(self):
- res = self._test_translation_join('IT-join-1.xml', ('cs', 'de', 'fr'))
+ self._test_translation_join('IT-join-1.xml', ('cs', 'de', 'fr'))
def test_Translate3_wrong1(self):
""" Test that bad XML syntax in translation generates a proper exception """
- res = self._test_translation_process('Translate3.xml', expected_status=1,
- po_file='Translate3.ll.wrong.po',
- options='-s')
+ self._test_translation_process('Translate/Translate3.xml', expected_status=1,
+ outputs=[('Translate/Translate3.ll.wrong.po', None, 'll')],
+ options='-s')
#self.assertTrue("libxml2.parserError" in res['errors'])
def test_Translate3_wrong2(self):
""" Test that bad XML syntax in translation is handled gracefully """
- res = self._test_translation_process('Translate3.xml',
- po_file='Translate3.ll.wrong.po',
- xml_file='Translate3.ll.wrong.xml')
+ self._test_translation_process('Translate/Translate3.xml',
+ outputs=[('Translate/Translate3.ll.wrong.po',
+ 'Translate/Translate3.ll.wrong.xml',
+ 'll')])
class ITSTestRunner(unittest.TextTestRunner):