diff options
author | Shaun McCance <shaunm@gnome.org> | 2011-06-01 09:22:03 -0400 |
---|---|---|
committer | Shaun McCance <shaunm@gnome.org> | 2011-06-01 09:22:03 -0400 |
commit | fadb43fc37dbe18d9b1204bb13fb5ccea492b649 (patch) | |
tree | a3f3ce3ec43d94a7e63e3f9addd1f38e2f96510f | |
parent | 43a518a2da4eb11f78b23cbca6291f9cd7c2f4ab (diff) | |
parent | 1ebcc2af7fa4d6e12687199e173720b44eb823a3 (diff) | |
download | itstool-fadb43fc37dbe18d9b1204bb13fb5ccea492b649.tar.gz |
Merge branch 'testsuite'
33 files changed, 876 insertions, 20 deletions
@@ -109,7 +109,7 @@ class MessageList (object): out.write('"Content-Transfer-Encoding: 8bit\\n"\n') out.write('\n') for msg in msgs: - out.write(msg.format()) + out.write(msg.format().encode('utf-8')) out.write('\n') @@ -126,7 +126,7 @@ class Message (object): class Placeholder (object): def __init__ (self, node): self.node = node - self.name = node.name + self.name = unicode(node.name, 'utf-8') def escape (self, text): return text.replace('\\','\\\\').replace('"', "\\\"").replace("\n","\\n").replace("\t","\\t") @@ -134,6 +134,8 @@ class Message (object): def add_text (self, text): if len(self._message) == 0 or not(isinstance(self._message[-1], basestring)): self._message.append('') + if not isinstance(text, unicode): + text = unicode(text, 'utf-8') self._message[-1] += text.replace('&', '&').replace('<', '<').replace('>', '>') if re.sub('\s+', ' ', text).strip() != '': self._empty = False @@ -146,8 +148,8 @@ class Message (object): def get_placeholder (self, name): placeholder = 1 for holder in self._placeholders: - holdername = '%s-%i' % (holder.name, placeholder) - if holdername == name: + holdername = u'%s-%i' % (holder.name, placeholder) + if holdername == unicode(name, 'utf-8'): return holder placeholder += 1 @@ -173,7 +175,7 @@ class Message (object): if node.children is not None: if len(self._message) == 0 or not(isinstance(self._message[-1], basestring)): self._message.append('') - self._message[-1] += ('</%s>' % node.name) + self._message[-1] += (u'</%s>' % unicode(node.name, 'utf-8')) def is_empty (self): return self._empty @@ -185,7 +187,7 @@ class Message (object): self._ctxt = ctxt def add_source (self, source): - self._sources.append(source) + self._sources.append(unicode(source, 'utf-8')) def get_sources (self): return self._sources @@ -197,13 +199,13 @@ class Message (object): return self._comments def get_string (self): - message = '' + message = u'' placeholder = 1 for msg in self._message: if isinstance(msg, basestring): message += msg elif isinstance(msg, Message.Placeholder): - message += '<_:%s-%i/>' % (msg.name, placeholder) + message += u'<_:%s-%i/>' % (msg.name, placeholder) placeholder += 1 if not self._preserve: message = re.sub('\s+', ' ', message).strip() @@ -216,7 +218,7 @@ class Message (object): self._preserve = preserve def format (self): - ret = '' + ret = u'' for i in range(len(self._comments)): if i != 0: ret += '#.\n' @@ -228,7 +230,7 @@ class Message (object): doadd = True if not doadd: continue - ret += '#. %s\n' % line + ret += u'#. %s\n' % line else: while len(comment) > 72: j = comment.rfind(' ', 0, 72) @@ -236,27 +238,27 @@ class Message (object): j = comment.find(' ') if j == -1: break - ret += '#. %s\n' % comment[:j] + ret += u'#. %s\n' % comment[:j] comment = comment[j+1:] ret += '#. %s\n' % comment for source in self._sources: - ret += '#: %s\n' % source + ret += u'#: %s\n' % source if self._preserve: - ret += '#, no-wrap\n' + ret += u'#, no-wrap\n' if self._ctxt is not None: - ret += 'msgctxt "%s"\n' % self._ctxt + ret += u'msgctxt "%s"\n' % self._ctxt message = self.get_string() if self._preserve: - ret += 'msgid ""\n' + ret += u'msgid ""\n' lines = message.split('\n') for line, no in zip(lines, range(len(lines))): if no == len(lines) - 1: - ret += '"%s"\n' % self.escape(line) + ret += u'"%s"\n' % self.escape(line) else: - ret += '"%s\\n"\n' % self.escape(line) + ret += u'"%s\\n"\n' % self.escape(line) else: - ret += 'msgid "%s"\n' % self.escape(message) - ret += 'msgstr ""\n' + ret += u'msgid "%s"\n' % self.escape(message) + ret += u'msgstr ""\n' return ret @@ -474,6 +476,8 @@ class Document (object): xpath = self._doc.xpathNewContext() reg_ns(xpath, rules) for rule in xml_child_iter(rules): + if rule.type != 'element': + continue if rule.nsDefs() is not None: rule_xpath = self._doc.xpathNewContent() reg_ns(rule_xpath, rule) @@ -616,7 +620,8 @@ class Document (object): ctxt.parseDocument() trnode = ctxt.doc().getRootElement() def scan_node(node): - for child in xml_child_iter(node): + children = [child for child in xml_child_iter(node)] + for child in children: if child.type != 'element': continue if child.ns() is not None and child.ns().content == NS_BLANK: diff --git a/tests/EX-locNotePointer-attribute-1.pot b/tests/EX-locNotePointer-attribute-1.pot new file mode 100644 index 0000000..cf4868f --- /dev/null +++ b/tests/EX-locNotePointer-attribute-1.pot @@ -0,0 +1,21 @@ +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"POT-Creation-Date: 2011-06-01 10:24+0200\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" + +#. Indicates that the resource file {0} could not be loaded. +#: tests/EX-locNotePointer-attribute-1.xml:12(msg/data) +msgid "Cannot find the file {0}." +msgstr "" + +#. A division by 0 was going to be computed. +#: tests/EX-locNotePointer-attribute-1.xml:16(msg/data) +msgid "Invalid parameter." +msgstr "" + diff --git a/tests/EX-locNoteRefPointer-attribute-1.pot b/tests/EX-locNoteRefPointer-attribute-1.pot new file mode 100644 index 0000000..ba33be4 --- /dev/null +++ b/tests/EX-locNoteRefPointer-attribute-1.pot @@ -0,0 +1,21 @@ +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"POT-Creation-Date: 2011-06-01 10:31+0200\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" + +#. SEE: Comments.html#FileNotFound +#: tests/EX-locNoteRefPointer-attribute-1.xml:10(string/data) +msgid "Cannot find the file {0}." +msgstr "" + +#. SEE: Comments.html#DivByZero +#: tests/EX-locNoteRefPointer-attribute-1.xml:13(string/data) +msgid "Invalid parameter." +msgstr "" + diff --git a/tests/LocNote1.pot b/tests/LocNote1.pot new file mode 100644 index 0000000..0be16e3 --- /dev/null +++ b/tests/LocNote1.pot @@ -0,0 +1,25 @@ +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"POT-Creation-Date: 2011-06-01 09:53+0200\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" + +#: tests/LocNote1.xml:17(body/msg) +msgid "This is a hippoptamus: <_:img-1/>." +msgstr "" + +#: tests/LocNote1.xml:18(body/msg) +msgid "This is an elephant: <_:img-1/>." +msgstr "" + +#. The variable {0} has three possible values: 'printer', 'stacker' and +#. 'stapler options'. +#: tests/LocNote1.xml:19(body/msg) +msgid "The {0} has been disabled." +msgstr "" + diff --git a/tests/LocNote2.pot b/tests/LocNote2.pot new file mode 100644 index 0000000..46d04a0 --- /dev/null +++ b/tests/LocNote2.pot @@ -0,0 +1,25 @@ +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"POT-Creation-Date: 2011-06-01 15:08+0200\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" + +#: tests/LocNote2.xml:11(body/msg) +msgid "This is a hippoptamus: <_:img-1/>." +msgstr "" + +#: tests/LocNote2.xml:12(body/msg) +msgid "This is an elephant: <_:img-1/>." +msgstr "" + +#. The variable {0} has three possible values: 'printer', 'stacker' and +#. 'stapler options'. +#: tests/LocNote2.xml:13(body/msg) +msgid "The {0} has been disabled." +msgstr "" + diff --git a/tests/LocNote3.pot b/tests/LocNote3.pot new file mode 100644 index 0000000..f8e3806 --- /dev/null +++ b/tests/LocNote3.pot @@ -0,0 +1,29 @@ +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"POT-Creation-Date: 2011-06-01 10:03+0200\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" + +#: tests/LocNote3.xml:5(msg/data) +msgid "Host {0} cannot be found." +msgstr "" + +#: tests/LocNote3.xml:8(msg/data) +msgid "The connection with {0} has been lost." +msgstr "" + +#. {0} is a filename +#: tests/LocNote3.xml:11(msg/data) +msgid "{0} not found." +msgstr "" + +#. SEE: myLocNotes.htm#CannotLog +#: tests/LocNote3.xml:14(msg/data) +msgid "Cannot log with this username." +msgstr "" + diff --git a/tests/LocNote4.pot b/tests/LocNote4.pot new file mode 100644 index 0000000..421ea1f --- /dev/null +++ b/tests/LocNote4.pot @@ -0,0 +1,30 @@ +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"POT-Creation-Date: 2011-06-01 10:12+0200\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" + +#. SEE: http://en.wikipedia.org/wiki/Doppelganger +#: tests/LocNote4.xml:5(span/span) +msgid "doppelgänger" +msgstr "" + +#: tests/LocNote4.xml:6(span/b) +msgid "serious" +msgstr "" + +#. SEE: http://en.wikipedia.org/wiki/Aficionado +#: tests/LocNote4.xml:6(span/span) +msgid "aficionado" +msgstr "" + +#. If possible keep the non-English terms in the translated version too +#: tests/LocNote4.xml:4(p/span) +msgid "Everything started when Zebulon discovered that he had a <_:span-1/> who was a <_:b-2/> baseball <_:span-3/>." +msgstr "" + diff --git a/tests/README b/tests/README new file mode 100644 index 0000000..0556dfe --- /dev/null +++ b/tests/README @@ -0,0 +1,5 @@ +To run the test suite, place yourself in the itstool root directory and run: + $ python tests/run_tests.py + +Test files are coming from: + http://www.w3.org/International/its/tests/ diff --git a/tests/Translate1.ll.po b/tests/Translate1.ll.po new file mode 100644 index 0000000..29cb646 --- /dev/null +++ b/tests/Translate1.ll.po @@ -0,0 +1,35 @@ +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"POT-Creation-Date: 2011-05-30 18:39+0200\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" + +#: tests/Translate1.xml:15(body/par) +msgid "Text with an image: <img alt=\"Image description\" src=\"img.png\"/>." +msgstr "Texte avec une image : <img alt=\"Description d'image\" src=\"img.png\"/>." + +#: tests/Translate1.xml:16(body/par) +msgid "This is the first paragraph. It has some <_:verbatim-1/>." +msgstr "C'est le premier paragraphe. Il contient du texte <_:verbatim-1/>." + +#: tests/Translate1.xml:21(封面/汇集) +msgid "The Lord of the Rings" +msgstr "Le Seigneur des Anneaux" + +#: tests/Translate1.xml:22(封面/标题) +msgid "The Return of the King" +msgstr "Le retour du Roi" + +#: tests/Translate1.xml:26(章节/头注) +msgid "Minas Tirith" +msgstr "Minas Tirith" + +#: tests/Translate1.xml:27(章节/段落识别) +msgid "<_:姓名-1/> looked out from the shelter of <_:姓名-2/>'s cloak." +msgstr "<_:姓名-1/> regarda depuis l'abri du manteau de <_:姓名-2/>." + diff --git a/tests/Translate1.ll.xml b/tests/Translate1.ll.xml new file mode 100644 index 0000000..bff12e0 --- /dev/null +++ b/tests/Translate1.ll.xml @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<myMetaDoc xmlns:cml="myChineseMakupLanguage"> + <head> + <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0"> + <its:translateRule selector="//img/@alt" translate="yes"/> + <its:translateRule selector="//*/@title" translate="yes"/> + <its:translateRule selector="//verbatim" translate="no"/> + <its:translateRule selector="//verbatim/@*" translate="no"/> + <its:translateRule selector="//verbatim//*/@*" translate="no"/> + <its:withinTextRule selector="//img|//verbatim" withinText="yes"/> + </its:rules> + </head> + <body> + <par>Texte avec une image : <img alt="Description d'image" src="img.png"/>.</par> + <par id="100" title="Text">C'est le premier paragraphe. Il contient du texte <verbatim>un-translatable + code with an image: <img src="test.png" alt="Image description"/></verbatim>.</par> + <insert xmlns:z="myChineseMakupLanguage" xmlns:i="http://www.w3.org/2005/11/its"> + <z:书籍> + <z:封面> + <z:汇集>Le Seigneur des Anneaux</z:汇集> + <z:标题>Le retour du Roi</z:标题> + <z:作者>J.R.R. Tolkein</z:作者> + </z:封面> + <z:章节 数="1"> + <z:头注>Minas Tirith</z:头注> + <z:段落识别 id="A34B"><z:姓名>Pippin</z:姓名> regarda depuis l'abri du manteau de <z:姓名>Gandalf</z:姓名>.</z:段落识别> + </z:章节> + <z:躯> + <i:rules version="1.0"> + <i:translateRule selector="//cml:作者" translate="no"/> + <i:translateRule selector="//cml:姓名" translate="no"/> + <i:withinTextRule selector="//cml:姓名" withinText="yes"/> + </i:rules> + </z:躯> + </z:书籍> + </insert> + </body> +</myMetaDoc> +<!-- timestamp $Id: Translate1.xml,v 1.8 2007/02/02 17:36:15 ysavoure Exp $ --> diff --git a/tests/Translate1.pot b/tests/Translate1.pot new file mode 100644 index 0000000..312e0d6 --- /dev/null +++ b/tests/Translate1.pot @@ -0,0 +1,35 @@ +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"POT-Creation-Date: 2011-05-30 18:39+0200\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" + +#: tests/Translate1.xml:15(body/par) +msgid "Text with an image: <img alt=\"Image description\" src=\"img.png\"/>." +msgstr "" + +#: tests/Translate1.xml:16(body/par) +msgid "This is the first paragraph. It has some <_:verbatim-1/>." +msgstr "" + +#: tests/Translate1.xml:21(封面/汇集) +msgid "The Lord of the Rings" +msgstr "" + +#: tests/Translate1.xml:22(封面/标题) +msgid "The Return of the King" +msgstr "" + +#: tests/Translate1.xml:26(章节/头注) +msgid "Minas Tirith" +msgstr "" + +#: tests/Translate1.xml:27(章节/段落识别) +msgid "<_:姓名-1/> looked out from the shelter of <_:姓名-2/>'s cloak." +msgstr "" + diff --git a/tests/Translate2.ll.po b/tests/Translate2.ll.po new file mode 100644 index 0000000..9078ab4 --- /dev/null +++ b/tests/Translate2.ll.po @@ -0,0 +1,15 @@ +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"POT-Creation-Date: 2011-05-31 21:15+0200\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" + +#: tests/Translate2.xml:8(body/par) +msgid "This is the first paragraph. It has some <_:code-1/>." +msgstr "C'est le premier paragraphe. Il contient du texte <_:code-1/>." + diff --git a/tests/Translate2.ll.xml b/tests/Translate2.ll.xml new file mode 100644 index 0000000..2092f86 --- /dev/null +++ b/tests/Translate2.ll.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> +<myDoc> + <head> + <its:rules xmlns:its="http://www.w3.org/2005/11/its" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.0" xlink:type="simple" xlink:href="Translate2_LinkedRules.xml"/> + </head> + <body> + <par id="100" title="Text">C'est le premier paragraphe. Il contient du texte <code>un-translatable code</code>.</par> + </body> +</myDoc> +<!-- timestamp $Id: Translate2.xml,v 1.4 2007/02/02 16:55:05 srahtz3 Exp $ --> diff --git a/tests/Translate2.pot b/tests/Translate2.pot new file mode 100644 index 0000000..85aac4f --- /dev/null +++ b/tests/Translate2.pot @@ -0,0 +1,15 @@ +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"POT-Creation-Date: 2011-05-31 21:17+0200\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" + +#: tests/Translate2.xml:8(body/par) +msgid "This is the first paragraph. It has some <_:code-1/>." +msgstr "" + diff --git a/tests/Translate3.ll.po b/tests/Translate3.ll.po new file mode 100644 index 0000000..8348ee5 --- /dev/null +++ b/tests/Translate3.ll.po @@ -0,0 +1,19 @@ +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"POT-Creation-Date: 2011-05-31 21:23+0200\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" + +#: tests/Translate3.xml:6(head/title) +msgid "The Life of a Simple Man" +msgstr "La vie d'un simple homme" + +#: tests/Translate3.xml:9(body/p) +msgid "Everything started when Zebulon discovered that he had a <_:span-1/> who was a serious baseball <_:span-2/>." +msgstr "Tout commença alors que Zebulon découvrit qu'il avait un <_:span-1/> qui était un <_:span-2/> sérieux de baseball." + diff --git a/tests/Translate3.ll.xml b/tests/Translate3.ll.xml new file mode 100644 index 0000000..a8376c3 --- /dev/null +++ b/tests/Translate3.ll.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> +<book xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:its="http://www.w3.org/2005/11/its" xsi:noNamespaceSchemaLocation="EX-ways-to-use-its-5.xsd" its:version="1.0" lang="test"> + <head> + <title>La vie d'un simple homme</title> + </head> + <body> + <p>Tout commença alors que Zebulon découvrit qu'il avait un <its:span translate="no">doppelgänger</its:span> qui était un <its:span translate="no">aficionado</its:span> sérieux de baseball.</p> + </body> +</book> +<!-- timestamp $Id: Translate3.xml,v 1.2 2006/12/19 06:24:35 fsasaki Exp $ --> diff --git a/tests/Translate4.ll.po b/tests/Translate4.ll.po new file mode 100644 index 0000000..09505db --- /dev/null +++ b/tests/Translate4.ll.po @@ -0,0 +1,19 @@ +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"POT-Creation-Date: 2011-05-31 21:28+0200\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" + +#: tests/Translate4.xml:3(head/title) +msgid "The Life of a Simple Man" +msgstr "La vie d'un simple homme" + +#: tests/Translate4.xml:6(body/p) +msgid "Everything started when Zebulon discovered that he had a <_:fexp-1/> who was a serious baseball <_:fexp-2/>." +msgstr "Tout commença alors que Zebulon découvrit qu'il avait un <_:fexp-1/> qui était un <_:fexp-2/> sérieux de baseball." + diff --git a/tests/Translate4.ll.xml b/tests/Translate4.ll.xml new file mode 100644 index 0000000..7394181 --- /dev/null +++ b/tests/Translate4.ll.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> +<book xmlns:its="http://www.w3.org/2005/11/its" its:version="1.0" lang="test"> + <head> + <title>La vie d'un simple homme</title> + </head> + <body> + <p>Tout commença alors que Zebulon découvrit qu'il avait un <fexp its:translate="no">doppelgänger</fexp> qui était un <fexp its:translate="no">aficionado</fexp> sérieux de baseball.</p> + </body> +</book> +<!-- timestamp $Id: Translate4.xml,v 1.4 2007/02/02 19:29:30 ysavoure Exp $ --> diff --git a/tests/Translate5.ll.po b/tests/Translate5.ll.po new file mode 100644 index 0000000..d223418 --- /dev/null +++ b/tests/Translate5.ll.po @@ -0,0 +1,19 @@ +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"POT-Creation-Date: 2011-05-31 21:45+0200\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" + +#: tests/Translate5.xml:9(info/item) +msgid "The Life of a <_:b-1/>" +msgstr "La vie d'un <_:b-1/>" + +#: tests/Translate5.xml:15(content/p) +msgid "Everything started when Zebulon discovered that he had a <_:span-1/> who was a serious baseball <_:span-2/>." +msgstr "Tout commença alors que Zebulon découvrit qu'il avait un <_:span-1/> qui était un <_:span-2/> sérieux de baseball." + diff --git a/tests/Translate5.ll.xml b/tests/Translate5.ll.xml new file mode 100644 index 0000000..ccb9cbd --- /dev/null +++ b/tests/Translate5.ll.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<doc xmlns:its="http://www.w3.org/2005/11/its" its:version="1.0"> + <head> + <its:rules version="1.0"> + <its:translateRule selector="//*" translate="no"/> + <its:translateRule selector="//p" translate="yes"/> + </its:rules> + </head> + <info> + <item type="title" its:translate="yes">La vie d'un <b>Simple Man</b></item> + <!-- Note that the contents of <b> and <span> should end up + *not* translatable with these settings --> + <item type="date-main">Dec-05-2006</item> + </info> + <content> + <p>Tout commença alors que Zebulon découvrit qu'il avait un <span>doppelgänger</span> qui était un <span>aficionado</span> sérieux de baseball.</p> + </content> +</doc> +<!-- timestamp $Id: Translate5.xml,v 1.4 2007/02/02 17:14:37 srahtz3 Exp $ --> diff --git a/tests/Translate5.pot b/tests/Translate5.pot new file mode 100644 index 0000000..0e48c38 --- /dev/null +++ b/tests/Translate5.pot @@ -0,0 +1,19 @@ +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"POT-Creation-Date: 2011-05-31 21:45+0200\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" + +#: tests/Translate5.xml:9(info/item) +msgid "The Life of a <_:b-1/>" +msgstr "" + +#: tests/Translate5.xml:15(content/p) +msgid "Everything started when Zebulon discovered that he had a <_:span-1/> who was a serious baseball <_:span-2/>." +msgstr "" + diff --git a/tests/Translate6.ll.po b/tests/Translate6.ll.po new file mode 100644 index 0000000..b589916 --- /dev/null +++ b/tests/Translate6.ll.po @@ -0,0 +1,31 @@ +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"POT-Creation-Date: 2011-05-31 21:48+0200\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" + +#: tests/Translate6.xml:9(item/b) +msgid "Simple Man" +msgstr "simple homme" + +#: tests/Translate6.xml:9(info/item) +msgid "The Life of a <_:b-1/>" +msgstr "La vie d'un <_:b-1/>" + +#: tests/Translate6.xml:16(p/span) +msgid "doppelgänger" +msgstr "double" + +#: tests/Translate6.xml:17(p/span) +msgid "aficionado" +msgstr "passionné" + +#: tests/Translate6.xml:15(content/p) +msgid "Everything started when Zebulon discovered that he had a <_:span-1/> who was a serious baseball <_:span-2/>." +msgstr "Tout commença alors que Zebulon découvrit qu'il avait un <_:span-1/> qui était un <_:span-2/> sérieux de baseball." + diff --git a/tests/Translate6.ll.xml b/tests/Translate6.ll.xml new file mode 100644 index 0000000..7c30876 --- /dev/null +++ b/tests/Translate6.ll.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<doc xmlns:its="http://www.w3.org/2005/11/its" its:version="1.0"> + <head> + <its:rules version="1.0"> + <its:translateRule selector="/doc" translate="no"/> + <its:translateRule selector="//p" translate="yes"/> + </its:rules> + </head> + <info> + <item type="title" its:translate="yes">La vie d'un <b>simple homme</b></item> + <!-- Note that the contents of <b> and <span> should end up + translatable with these settings --> + <item type="date-main">Dec-05-2006</item> + </info> + <content> + <p>Tout commença alors que Zebulon découvrit qu'il avait un <span>double</span> qui était un <span>passionné</span> sérieux de baseball.</p> + </content> +</doc> +<!-- timestamp $Id: Translate6.xml,v 1.5 2007/02/02 17:59:34 srahtz3 Exp $ --> diff --git a/tests/Translate7.ll.po b/tests/Translate7.ll.po new file mode 100644 index 0000000..16acd6c --- /dev/null +++ b/tests/Translate7.ll.po @@ -0,0 +1,19 @@ +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"POT-Creation-Date: 2011-05-31 21:54+0200\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" + +#: tests/Translate7.xml:19(body/p) +msgid "For the implementation of ITS, apply the rules in the order:" +msgstr "Pour l'implémentation d'ITS, appliquez les règles dans l'ordre :" + +#: tests/Translate7.xml:26(body/p) +msgid "<_:ph-1/> The last rule wins." +msgstr "<_:ph-1/> La dernière règle gagne." + diff --git a/tests/Translate7.ll.xml b/tests/Translate7.ll.xml new file mode 100644 index 0000000..1ac74b0 --- /dev/null +++ b/tests/Translate7.ll.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="utf-8"?> +<topic id="myTopic"> + <title>The ITS Topic</title> + <prolog> + <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0"> + <its:translateRule selector="//*" translate="no"/> + <its:translateRule selector="//p" translate="yes"/> + <!-- With these rules only the text "For the implementation of ITS, apply the rules in the order:" + and " The last rule wins." should end up translatable --> + </its:rules> + </prolog> + <body> + <dl> + <dlentry id="tDataCat"> + <dt>Data category</dt> + <dd>ITS defines <term>data category</term> as an abstract concept for a particular + type of information for internationalization and localization of XML schemas and documents.</dd> + </dlentry> + </dl> + <p>Pour l'implémentation d'ITS, appliquez les règles dans l'ordre :</p> + <ul> + <li>Default</li> + <li>Rules in the schema</li> + <li>Rules in the document instance</li> + <li>Local attributes</li> + </ul> + <p><ph xml:lang="fr">Et voilà !</ph> La dernière règle gagne.</p> + </body> +</topic> diff --git a/tests/Translate7.pot b/tests/Translate7.pot new file mode 100644 index 0000000..2fe7d5e --- /dev/null +++ b/tests/Translate7.pot @@ -0,0 +1,19 @@ +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"POT-Creation-Date: 2011-05-31 21:56+0200\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" + +#: tests/Translate7.xml:19(body/p) +msgid "For the implementation of ITS, apply the rules in the order:" +msgstr "" + +#: tests/Translate7.xml:26(body/p) +msgid "<_:ph-1/> The last rule wins." +msgstr "" + diff --git a/tests/WithinText1.ll.po b/tests/WithinText1.ll.po new file mode 100644 index 0000000..4135bf5 --- /dev/null +++ b/tests/WithinText1.ll.po @@ -0,0 +1,23 @@ +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"POT-Creation-Date: 2011-06-01 08:49+0200\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" + +#: tests/WithinText1.xml:9(body/p) +msgid "This is a paragraph with <b>bold</b>, <i>italic</i>, and <u>underlined</u>." +msgstr "Ceci est un paragraphe avec <b>gras</b>, <i>italique</i> et <u>souligné</u>." + +#: tests/WithinText1.xml:10(p/fn) +msgid "This is the text of the footnote" +msgstr "Voici le texte d'une note de pied de page" + +#: tests/WithinText1.xml:10(body/p) +msgid "This is a paragraph with a footnote<_:fn-1/> at the middle." +msgstr "Voici un paragraphe avec une note de pied de page<_:fn-1/> insérée au milieu." + diff --git a/tests/WithinText1.ll.xml b/tests/WithinText1.ll.xml new file mode 100644 index 0000000..d956a50 --- /dev/null +++ b/tests/WithinText1.ll.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8"?> +<doc> + <head> + <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0"> + <its:withinTextRule withinText="yes" selector="//b|//u|//i"/> + <its:withinTextRule withinText="nested" selector="//fn"/> + </its:rules> + </head> + <body> + <p>Ceci est un paragraphe avec <b>gras</b>, <i>italique</i> et <u>souligné</u>.</p> + <p>Voici un paragraphe avec une note de pied de page<fn>Voici le texte d'une note de pied de page</fn> insérée au milieu.</p> + </body> + </doc> +<!-- timestamp $Id: WithinText1.xml,v 1.3 2007/02/02 16:55:05 srahtz3 Exp $ --> diff --git a/tests/WithinText1.pot b/tests/WithinText1.pot new file mode 100644 index 0000000..de0b699 --- /dev/null +++ b/tests/WithinText1.pot @@ -0,0 +1,23 @@ +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"POT-Creation-Date: 2011-06-01 08:49+0200\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" + +#: tests/WithinText1.xml:9(body/p) +msgid "This is a paragraph with <b>bold</b>, <i>italic</i>, and <u>underlined</u>." +msgstr "" + +#: tests/WithinText1.xml:10(p/fn) +msgid "This is the text of the footnote" +msgstr "" + +#: tests/WithinText1.xml:10(body/p) +msgid "This is a paragraph with a footnote<_:fn-1/> at the middle." +msgstr "" + diff --git a/tests/WithinText2.ll.po b/tests/WithinText2.ll.po new file mode 100644 index 0000000..865fbcc --- /dev/null +++ b/tests/WithinText2.ll.po @@ -0,0 +1,51 @@ +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"POT-Creation-Date: 2011-06-01 09:34+0200\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" + +#: tests/WithinText2.xml:9(prolog/author) +msgid "Zebulon Fairfield" +msgstr "Zebulon Fairfield" + +#: tests/WithinText2.xml:10(prolog/version) +msgid "version 12, revision 2 - 2006-08-14" +msgstr "version 12, révision 2 - 14/08/2006" + +#: tests/WithinText2.xml:11(keywords/kw) +msgid "horse" +msgstr "cheval" + +#: tests/WithinText2.xml:11(keywords/kw) +msgid "appaloosa" +msgstr "appaloosa" + +#: tests/WithinText2.xml:12(prolog/storageKey) +msgid "articles-6D272BA9-3B89CAD8" +msgstr "articles-6D272BA9-3B89CAD8" + +#: tests/WithinText2.xml:16(section/title) +msgid "Appaloosa" +msgstr "Appaloosa" + +#: tests/WithinText2.xml:17(p/fnote) +msgid "The name comes from \"Palouse horse\" in reference to the Palouse River in Northern Idaho." +msgstr "Le nom provient de « cheval de Palouse » en référence à la rivière Palouse en Idaho du Nord." + +#: tests/WithinText2.xml:17(section/p) +msgid "The Appaloosa<_:fnote-1/> are rugged horses originally breed by the <kw>Nez-Perce</kw> tribe in the US Northwest." +msgstr "Les appaloosas<_:fnote-1/> sont de rudes chevaux élevés initialement par la tribu des <kw>Nez-Percés</kw> dans le Nord-ouest américain." + +#: tests/WithinText2.xml:20(section/p) +msgid "They are often characterized by their spotted coats, as shown here: <img src=\"appaloosa.png\" alt=\"Appaloosa horses\"/>" +msgstr "Ils sont souvent caractérisés par leur robe tachetée, comme sur cette image : <img src=\"appaloosa.png\" alt=\"Chevaux appaloosas\"/>" + +#: tests/WithinText2.xml:23(footer/p) +msgid "Copyright: <em>Zebulon Inc.</em>" +msgstr "Copyright : <em>Zebulon Inc.</em>" + diff --git a/tests/WithinText2.ll.xml b/tests/WithinText2.ll.xml new file mode 100644 index 0000000..7fd9e1e --- /dev/null +++ b/tests/WithinText2.ll.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<myDocument xmlns="http://my.DocumentURI/" xml:lang="en"> + <prolog> +<its:rules xmlns:its="http://www.w3.org/2005/11/its" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:d="http://my.DocumentURI/" version="1.0" xlink:type="simple" xlink:href="WithinText2_LinkedRules.xml"> + <its:withinTextRule selector="//d:keywords/d:kw" withinText="no"/> +</its:rules> + <author>Zebulon Fairfield</author> + <version>version 12, révision 2 - 14/08/2006</version> + <keywords><kw>cheval</kw><kw>appaloosa</kw></keywords> + <storageKey>articles-6D272BA9-3B89CAD8</storageKey> + </prolog> + <content> + <section> + <title>Appaloosa</title> + <p>Les appaloosas<fnote>Le nom provient de « cheval de Palouse » en référence à la rivière Palouse en Idaho du Nord.</fnote> sont de rudes chevaux élevés initialement par la tribu des <kw>Nez-Percés</kw> dans le Nord-ouest américain.</p> + <p>Ils sont souvent caractérisés par leur robe tachetée, comme sur cette image : <img src="appaloosa.png" alt="Chevaux appaloosas"/></p> + </section> + <footer><p>Copyright : <em>Zebulon Inc.</em></p></footer> + </content> +</myDocument> +<!-- timestamp $Id: WithinText2.xml,v 1.8 2007/02/02 16:55:05 srahtz3 Exp $ --> diff --git a/tests/WithinText2.pot b/tests/WithinText2.pot new file mode 100644 index 0000000..0830499 --- /dev/null +++ b/tests/WithinText2.pot @@ -0,0 +1,51 @@ +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"POT-Creation-Date: 2011-06-01 09:34+0200\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" + +#: tests/WithinText2.xml:9(prolog/author) +msgid "Zebulon Fairfield" +msgstr "" + +#: tests/WithinText2.xml:10(prolog/version) +msgid "version 12, revision 2 - 2006-08-14" +msgstr "" + +#: tests/WithinText2.xml:11(keywords/kw) +msgid "horse" +msgstr "" + +#: tests/WithinText2.xml:11(keywords/kw) +msgid "appaloosa" +msgstr "" + +#: tests/WithinText2.xml:12(prolog/storageKey) +msgid "articles-6D272BA9-3B89CAD8" +msgstr "" + +#: tests/WithinText2.xml:16(section/title) +msgid "Appaloosa" +msgstr "" + +#: tests/WithinText2.xml:17(p/fnote) +msgid "The name comes from \"Palouse horse\" in reference to the Palouse River in Northern Idaho." +msgstr "" + +#: tests/WithinText2.xml:17(section/p) +msgid "The Appaloosa<_:fnote-1/> are rugged horses originally breed by the <kw>Nez-Perce</kw> tribe in the US Northwest." +msgstr "" + +#: tests/WithinText2.xml:20(section/p) +msgid "They are often characterized by their spotted coats, as shown here: <img src=\"appaloosa.png\" alt=\"Appaloosa horses\"/>" +msgstr "" + +#: tests/WithinText2.xml:23(footer/p) +msgid "Copyright: <em>Zebulon Inc.</em>" +msgstr "" + diff --git a/tests/run_tests.py b/tests/run_tests.py new file mode 100644 index 0000000..fafc1cb --- /dev/null +++ b/tests/run_tests.py @@ -0,0 +1,131 @@ +import os +import shutil +from subprocess import Popen, PIPE, call +import sys +import unittest + +TEST_DIR = os.path.dirname(os.path.abspath(__file__)) +ITSTOOL_DIR = os.path.dirname(TEST_DIR) + +class ItstoolTests(unittest.TestCase): + def tearDown(self): + for test_file in ('test.pot', 'test.mo', 'test.xml'): + path = os.path.join(TEST_DIR, test_file) + if os.path.exists(path): + os.remove(path) + + 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 + self.assertEqual(status, 0, errout or output) + return (status, output, errout) + + def assertFilesEqual(self, f1, f2): + options = "" + if f1.endswith(".po") or f1.endswith(".pot"): + options = "--ignore-matching-lines=^\\\"POT-Creation-Date" + result = self.run_command("diff -u %s %s %s" % (options, f1, f2)) + return self.assertEqual(result[1], "", result[1]) + + 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, + 'out' : os.path.join('tests', "test.pot"), + 'in' : os.path.join('tests', start_file), + }) + # If a reference pot file is present, test the output with this file + if reference_pot is None: + reference_pot = start_file_base + ".pot" + if os.path.exists(os.path.join(TEST_DIR, 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" % { + 'dir': ITSTOOL_DIR, + 'mo' : os.path.join(TEST_DIR, "test.mo"), + 'res': os.path.join(TEST_DIR, "test.xml"), + 'src': os.path.join(TEST_DIR, start_file), + }) + 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') + + 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') + + def test_external_rules(self): + self._test_translation_process('Translate2.xml') + + def test_embedded_its(self): + self._test_translation_process('Translate3.xml') + + def test_notranslate_to_simpletag(self): + self._test_translation_process('Translate4.xml') + + def test_selector_translate_rule(self): + self._test_translation_process('Translate5.xml') + + def test_root_selector(self): + self._test_translation_process('Translate6.xml') + + def test_last_rule_win(self): + self._test_translation_process('Translate7.xml') + + # FIXME: currently deactivated until attributes are translatable + 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 + test_binary_path = os.path.join(ITSTOOL_DIR, "itstool_test") + shutil.copy(os.path.join(ITSTOOL_DIR, "itstool.in"), test_binary_path) + data_dir = os.path.join(ITSTOOL_DIR, "its") + call("sed -i -e 's/@DATADIR@/%s/' %s" % (data_dir.replace('/', '\/'), test_binary_path), shell=True) + + result = super(ITSTestRunner, self).run(test) + + os.remove(test_binary_path) + return result + + +if __name__ == '__main__': + unittest.main(testRunner=ITSTestRunner) + |