From 9b0e40c6bd4dab428a0d196b71fb18b224999568 Mon Sep 17 00:00:00 2001 From: dbs Date: Wed, 12 Dec 2007 04:38:24 +0000 Subject: [PATCH] Make unit tests less fragile. Correct POT output where headers require an escaped \n. git-svn-id: svn://svn.open-ils.org/ILS/trunk@8203 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- build/i18n/Makefile | 40 ++++++++++++----- build/i18n/po/db.seed.pot | 18 ++++---- build/i18n/po/fm_IDL.pot | 18 ++++---- build/i18n/po/opac.dtd.pot | 18 +++----- build/i18n/scripts/basel10n.py | 18 ++++---- build/i18n/tests/data/complex.po | 18 ++++---- build/i18n/tests/data/complex.pot | 18 ++++---- build/i18n/tests/data/sql2pot.pot | 16 +++---- build/i18n/tests/data/sqlsource.po | 18 ++++---- build/i18n/tests/data/testidl.po | 18 ++++---- build/i18n/tests/data/testidl.pot | 16 +++---- build/i18n/tests/testbase.py | 6 +-- build/i18n/tests/testpo.py | 72 +++++++++++++++++------------- 13 files changed, 159 insertions(+), 135 deletions(-) diff --git a/build/i18n/Makefile b/build/i18n/Makefile index add13bd7f1..0d6f81382b 100644 --- a/build/i18n/Makefile +++ b/build/i18n/Makefile @@ -5,8 +5,12 @@ DTDDIR=../../Open-ILS/web/opac/locale PROPSDIR=../../Open-ILS/xul/staff_client/chrome/locale FMIDLSRC=../../Open-ILS/examples/fm_IDL.xml FMIDLOUT=fm_IDL.pot +FMIDLENT=fm_IDL.xml +FMIDLENTITY=fm_IDL.xml.ent +FMIDLPO=fm_IDL.po SQLSRC=../../Open-ILS/src/sql/Pg/950.data.seed-values.sql SQLOUT=db.seed.pot +SQLPO=db.seed.po PROGRESS=--progress none # This Makefile can be used to generate and update PO files for Evergreen, @@ -23,23 +27,29 @@ PROGRESS=--progress none # # To update a set of translated PO files with new or changed en-US strings: # make LOCALE=ll-LL updatepo +# +# To create a new set of project files (DTDs, JavaScript message catalogs): +# make LOCALE=ll-LL updatepo -newpo: dtds2po props2po +# Generate PO files from all POT files in POOUTDIR for locale LOCALE +newpo: + @pot2po $(PROGRESS) -i $(POOUTDIR) -o $(POOUTDIR)/$(LOCALE) @echo "Generated new PO files for locale $(LOCALE)" -newpot: dtds2pot fmidl2pot props2pot sql2pot +# Generate a new set of POT files and entityized fieldmapper IDL +newpot: dtds2pot fmidl2pot fmidl2ent props2pot sql2pot @echo "Generated new POT files" -newproject: po2dtds po2props - @echo "Generated newly translated project files for locale $(LOCALE)" +# Generate DTD, JavaScript message catalogs, fieldmapper IDL, +# and SQL insert files from PO for locale LOCALE +newproject: po2dtds po2props po2sql fmidlpo2entity + @echo "Generated project files for locale $(LOCALE)" +# Update PO files with new and changed strings from POT files updatepo: @pot2po $(PROGRESS) -o $(POOUTDIR)/$(LOCALE) -i $(POOUTDIR) -t $(POOUTDIR)/$(LOCALE) 2>&1 @echo "Updated PO files for locale $(LOCALE)" -updateproject: update_moz_dtds update_moz_props - @echo "Updated translated project files for locale $(LOCALE)" - dtds2po: @moz2po $(PROGRESS) -o $(POOUTDIR)/$(LOCALE) -i $(DTDDIR)/en-US/ 2>&1 @@ -61,11 +71,17 @@ po2props: sql2pot: @scripts/db-seed-i18n.py --pot $(SQLSRC) --output $(POOUTDIR)/$(SQLOUT) +po2sql: + @scripts/db-seed-i18n.py --sql $(POINDIR)/$(LOCALE)/$(SQLPO) --locale $(LOCALE) --output locale/$(LOCALE)/$(SQLOUT) + +# Generate a fieldmapper IDL file that uses entities instead of hard-coded strings +fmidlpo2fmidlent: + @scripts/fieldmapper.py --convert $(FMIDLSRC) --output $(POOUTDIR)/$(FMIDLENT) + +# Generate a POT file for translating the entity values fmidl2pot: @scripts/fieldmapper.py --pot $(FMIDLSRC) --output $(POOUTDIR)/$(FMIDLOUT) -update_moz_dtds: - @po2moz $(PROGRESS) -o locale/$(LOCALE) -t $(DTDDIR)/en-US/ -i $(POINDIR)/$(LOCALE) 2>&1 - -update_moz_props: - @po2moz $(PROGRESS) -o locale/$(LOCALE) -t $(PROPSDIR)/en-US/ -i $(POINDIR)/$(LOCALE) 2>&1 +# Generate a set of entity declarations from a PO file +fmidlpo2entity: + @scripts/fieldmapper.py --entity $(POINDIR)/$(LOCALE)/$(FMIDLOUT) --output locale/$(LOCALE)/$(FMIDLENTITY) diff --git a/build/i18n/po/db.seed.pot b/build/i18n/po/db.seed.pot index b112c2b0be..d684da88f2 100644 --- a/build/i18n/po/db.seed.pot +++ b/build/i18n/po/db.seed.pot @@ -1,15 +1,15 @@ # msgid "" msgstr "" -"Project-Id-Version: Evergreen 1.4" -"Report-Msgid-Bugs-To: open-ils-dev@list.georgialibraries.org" -"POT-Creation-Date: 2007-12-10 21:54:29-0400" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE" -"Last-Translator: FULL NAME " -"Language-Team: LANGUAGE " -"MIME-Version: 1.0" -"Content-Type: text/plain; charset=utf-8" -"Content-Transfer-Encoding: 8-bit" +"Project-Id-Version: Evergreen 1.4\n" +"Report-Msgid-Bugs-To: open-ils-dev@list.georgialibraries.org\n" +"POT-Creation-Date: 2007-12-11 13:27:40-0400\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8-bit\n" #: config.bib_source:3 msgid "oclc" diff --git a/build/i18n/po/fm_IDL.pot b/build/i18n/po/fm_IDL.pot index c411702736..2b3d390c0c 100644 --- a/build/i18n/po/fm_IDL.pot +++ b/build/i18n/po/fm_IDL.pot @@ -1,15 +1,15 @@ # msgid "" msgstr "" -"Project-Id-Version: Evergreen 1.4" -"Report-Msgid-Bugs-To: open-ils-dev@list.georgialibraries.org" -"POT-Creation-Date: 2007-12-10 21:54:25-0400" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE" -"Last-Translator: FULL NAME " -"Language-Team: LANGUAGE " -"MIME-Version: 1.0" -"Content-Type: text/plain; charset=utf-8" -"Content-Transfer-Encoding: 8-bit" +"Project-Id-Version: Evergreen 1.4\n" +"Report-Msgid-Bugs-To: open-ils-dev@list.georgialibraries.org\n" +"POT-Creation-Date: 2007-12-11 13:27:35-0400\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8-bit\n" #: field.aihu.org_unit.label:240 field.ancihu.org_unit.label:257 msgid "Using Library" diff --git a/build/i18n/po/opac.dtd.pot b/build/i18n/po/opac.dtd.pot index d950e52e2c..58d3a0606f 100644 --- a/build/i18n/po/opac.dtd.pot +++ b/build/i18n/po/opac.dtd.pot @@ -2,9 +2,9 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: Evergreen 1.4\n" -"Report-Msgid-Bugs-To: open-ils-dev@list.georgialibraries.org\n" -"POT-Creation-Date: 2007-11-19 13:21-0400\n" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2007-12-11 13:27-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -631,8 +631,8 @@ msgstr "" msgid "Pickup Location" msgstr "" -#: myopac.holds.edit.cancel -msgid "Edit/Cancel" +#: myopac.holds.edit +msgid "Edit" msgstr "" #: myopac.holds.status.none @@ -651,10 +651,6 @@ msgstr "" msgid "Ready for Pickup" msgstr "" -#: myopac.holds.edit -msgid "Edit" -msgstr "" - #: myopac.holds.verify msgid "If you wish to cancel the selected hold, click OK, otherwise click Cancel." msgstr "" @@ -911,7 +907,7 @@ msgid "Username update failed" msgstr "" #: myopac.summary.username.invalid -msgid "Username cannot contain spaces" +msgid "Username cannot contain spaces or have the same format as a barcode" msgstr "" #: myopac.summary.email.error @@ -1668,7 +1664,7 @@ msgid "Sort Results by Author" msgstr "" #: result.sort_by.pubdate -msgid "Sort Results by Publicate Date" +msgid "Sort Results by Publication Date" msgstr "" #: result.limit2avail diff --git a/build/i18n/scripts/basel10n.py b/build/i18n/scripts/basel10n.py index bb816e6a8f..63efb7c106 100755 --- a/build/i18n/scripts/basel10n.py +++ b/build/i18n/scripts/basel10n.py @@ -38,17 +38,17 @@ class BaseL10N: version = 'Evergreen 1.4' if date is None: date = time.strftime("%Y-%m-%d %H:%M:%S") + '-0400' - self.pot.metadata['Project-Id-Version'] = version + self.pot.metadata['Project-Id-Version'] = version + r'\n' self.pot.metadata['Report-Msgid-Bugs-To'] = \ - 'open-ils-dev@list.georgialibraries.org' + 'open-ils-dev@list.georgialibraries.org' + r'\n' # Cheat and hard-code the time zone offset - self.pot.metadata['POT-Creation-Date'] = date - self.pot.metadata['PO-Revision-Date'] = 'YEAR-MO-DA HO:MI+ZONE' - self.pot.metadata['Last-Translator'] = 'FULL NAME ' - self.pot.metadata['Language-Team'] = 'LANGUAGE ' - self.pot.metadata['MIME-Version'] = '1.0' - self.pot.metadata['Content-Type'] = 'text/plain; charset=utf-8' - self.pot.metadata['Content-Transfer-Encoding'] = '8-bit' + self.pot.metadata['POT-Creation-Date'] = date + r'\n' + self.pot.metadata['PO-Revision-Date'] = 'YEAR-MO-DA HO:MI+ZONE' + r'\n' + self.pot.metadata['Last-Translator'] = 'FULL NAME ' + r'\n' + self.pot.metadata['Language-Team'] = 'LANGUAGE ' + r'\n' + self.pot.metadata['MIME-Version'] = '1.0' + r'\n' + self.pot.metadata['Content-Type'] = 'text/plain; charset=utf-8' + r'\n' + self.pot.metadata['Content-Transfer-Encoding'] = '8-bit' + r'\n' def savepot(self, destination): """ diff --git a/build/i18n/tests/data/complex.po b/build/i18n/tests/data/complex.po index 48dc35488c..2cc5c727ba 100644 --- a/build/i18n/tests/data/complex.po +++ b/build/i18n/tests/data/complex.po @@ -1,15 +1,15 @@ # msgid "" msgstr "" -"Project-Id-Version: Evergreen 1.4" -"Report-Msgid-Bugs-To: open-ils-dev@list.georgialibraries.org" -"POT-Creation-Date: 1999-12-31 23:59:59 -0400" -"PO-Revision-Date: 2007-12-08 23:14:20 -0400" -"Last-Translator: Dan Scott " -"Language-Team: fr-CA " -"MIME-Version: 1.0" -"Content-Type: text/plain; charset=utf-8" -"Content-Transfer-Encoding: 8-bit" +"Project-Id-Version: Evergreen 1.4\n" +"Report-Msgid-Bugs-To: open-ils-dev@list.georgialibraries.org\n" +"POT-Creation-Date: 1999-12-31 23:59:59 -0400\n" +"PO-Revision-Date: 2007-12-08 23:14:20 -0400\n" +"Last-Translator: Dan Scott \n" +"Language-Team: fr-CA \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8-bit\n" #: 240:field.aihu.org_unit.label 257:field.ancihu.org_unit.label msgid "Using Library" diff --git a/build/i18n/tests/data/complex.pot b/build/i18n/tests/data/complex.pot index 661f9f9f05..6e1843f9d9 100644 --- a/build/i18n/tests/data/complex.pot +++ b/build/i18n/tests/data/complex.pot @@ -1,15 +1,15 @@ # msgid "" msgstr "" -"Project-Id-Version: Evergreen 1.4" -"Report-Msgid-Bugs-To: open-ils-dev@list.georgialibraries.org" -"POT-Creation-Date: 1999-12-31 23:59:59 -0400" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE" -"Last-Translator: FULL NAME " -"Language-Team: LANGUAGE " -"MIME-Version: 1.0" -"Content-Type: text/plain; charset=utf-8" -"Content-Transfer-Encoding: 8-bit" +"Project-Id-Version: Evergreen 1.4\n" +"Report-Msgid-Bugs-To: open-ils-dev@list.georgialibraries.org\n" +"POT-Creation-Date: 1999-12-31 23:59:59 -0400\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8-bit\n" #: 240:field.aihu.org_unit.label 257:field.ancihu.org_unit.label msgid "Using Library" diff --git a/build/i18n/tests/data/sql2pot.pot b/build/i18n/tests/data/sql2pot.pot index 7bbbc51238..c4606c58cd 100644 --- a/build/i18n/tests/data/sql2pot.pot +++ b/build/i18n/tests/data/sql2pot.pot @@ -1,15 +1,15 @@ # msgid "" msgstr "" -"Project-Id-Version: Evergreen 1.4" -"Report-Msgid-Bugs-To: open-ils-dev@list.georgialibraries.org" +"Project-Id-Version: Evergreen 1.4\n" +"Report-Msgid-Bugs-To: open-ils-dev@list.georgialibraries.org\n" "POT-Creation-Date: -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE" -"Last-Translator: FULL NAME " -"Language-Team: LANGUAGE " -"MIME-Version: 1.0" -"Content-Type: text/plain; charset=utf-8" -"Content-Transfer-Encoding: 8-bit" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8-bit\n" #: config.bib_source:3 msgid "oclc" diff --git a/build/i18n/tests/data/sqlsource.po b/build/i18n/tests/data/sqlsource.po index 4e9b1c99b3..6bed8f70f3 100644 --- a/build/i18n/tests/data/sqlsource.po +++ b/build/i18n/tests/data/sqlsource.po @@ -1,15 +1,15 @@ # msgid "" msgstr "" -"Project-Id-Version: Evergreen 1.4" -"Report-Msgid-Bugs-To: open-ils-dev@list.georgialibraries.org" -"POT-Creation-Date: -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE" -"Last-Translator: FULL NAME " -"Language-Team: LANGUAGE " -"MIME-Version: 1.0" -"Content-Type: text/plain; charset=utf-8" -"Content-Transfer-Encoding: 8-bit" +"Project-Id-Version: Evergreen 1.4\n" +"Report-Msgid-Bugs-To: open-ils-dev@list.georgialibraries.org\n" +"POT-Creation-Date: 1999-12-31 23:59:59 -0400\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8-bit\n" #: config.bib_source:3 msgid "oclc" diff --git a/build/i18n/tests/data/testidl.po b/build/i18n/tests/data/testidl.po index 886c18bec9..a282f0444e 100644 --- a/build/i18n/tests/data/testidl.po +++ b/build/i18n/tests/data/testidl.po @@ -1,15 +1,15 @@ # msgid "" msgstr "" -"Project-Id-Version: Evergreen 1.4" -"Report-Msgid-Bugs-To: open-ils-dev@list.georgialibraries.org" -"POT-Creation-Date: -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE" -"Last-Translator: FULL NAME " -"Language-Team: LANGUAGE " -"MIME-Version: 1.0" -"Content-Type: text/plain; charset=utf-8" -"Content-Transfer-Encoding: 8-bit" +"Project-Id-Version: Evergreen 1.4\n" +"Report-Msgid-Bugs-To: open-ils-dev@list.georgialibraries.org\n" +"POT-Creation-Date: 1999-12-31 23:59:59 -0400\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8-bit\n" #: field.auoi.org_unit.label:29 msgid "Allowed Org Unit" diff --git a/build/i18n/tests/data/testidl.pot b/build/i18n/tests/data/testidl.pot index efb2adb01d..c32f011925 100644 --- a/build/i18n/tests/data/testidl.pot +++ b/build/i18n/tests/data/testidl.pot @@ -1,15 +1,15 @@ # msgid "" msgstr "" -"Project-Id-Version: Evergreen 1.4" -"Report-Msgid-Bugs-To: open-ils-dev@list.georgialibraries.org" +"Project-Id-Version: Evergreen 1.4\n" +"Report-Msgid-Bugs-To: open-ils-dev@list.georgialibraries.org\n" "POT-Creation-Date: -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE" -"Last-Translator: FULL NAME " -"Language-Team: LANGUAGE " -"MIME-Version: 1.0" -"Content-Type: text/plain; charset=utf-8" -"Content-Transfer-Encoding: 8-bit" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8-bit\n" #: 29:field.auoi.org_unit.label msgid "Allowed Org Unit" diff --git a/build/i18n/tests/testbase.py b/build/i18n/tests/testbase.py index 6915367330..47d7178f46 100644 --- a/build/i18n/tests/testbase.py +++ b/build/i18n/tests/testbase.py @@ -59,9 +59,9 @@ class TestBaseL10N(unittest.TestCase): poload.loadpo(self.canonpo) pogen = basel10n.BaseL10N() pogen.pothead('Evergreen 1.4', '1999-12-31 23:59:59 -0400') - pogen.pot.metadata['PO-Revision-Date'] = '2007-12-08 23:14:20 -0400' - pogen.pot.metadata['Last-Translator'] = ' Dan Scott ' - pogen.pot.metadata['Language-Team'] = 'fr-CA ' + pogen.pot.metadata['PO-Revision-Date'] = '2007-12-08 23:14:20 -0400\\n' + pogen.pot.metadata['Last-Translator'] = ' Dan Scott \\n' + pogen.pot.metadata['Language-Team'] = 'fr-CA \\n' for msg in self.poentries: poe = polib.POEntry() for x in msg['occurences']: diff --git a/build/i18n/tests/testpo.py b/build/i18n/tests/testpo.py index d2ecdc671c..b866417013 100644 --- a/build/i18n/tests/testpo.py +++ b/build/i18n/tests/testpo.py @@ -11,29 +11,41 @@ import unittest class TestPOFramework(unittest.TestCase): - po_sources = ('../../Open-ILS/web/opac/locale/en-US/*.dtd', \ - '../../Open-ILS/xul/staff_client/chrome/locale/en-US/*.properties') + po_sources = ('../../Open-ILS/web/opac/locale/en-US/*.dtd', + '../../Open-ILS/xul/staff_client/chrome/locale/en-US/*.properties', + '../../Open-ILS/examples/fm_IDL.xml', + '../../Open-ILS/src/sql/Pg/950.data.seed-values.sql') + + po_tmp_files = ('tests/tmp/po/test.properties.pot', 'tests/tmp/po/ll-LL/temp.properties.po') + pot_dir = 'tests/tmp/po' + locale_dir = 'tests/tmp/po/ll-LL/' + po_tmp_dirs = (locale_dir, locale_dir, pot_dir, 'tests/tmp') def setUp(self): self.tearDown() devnull = open('/dev/null', 'w') - proc = subprocess.Popen(('make', 'LOCALE=ll-LL', 'newpo'), 0, None, None, devnull, devnull).wait() - proc = subprocess.Popen(('make', 'LOCALE=ll-LL', 'newproject'), 0, None, None, devnull, devnull).wait() + os.mkdir('tests/tmp') + proc = subprocess.Popen(('cp', '-r', 'po', 'tests/tmp'), 0, None, None, devnull, devnull).wait() + proc = subprocess.Popen(('make', 'LOCALE=ll-LL', 'POINDIR=tests/tmp/po', 'POOUTDIR=tests/tmp/po', 'newpot'), 0, None, None, devnull, devnull).wait() + proc = subprocess.Popen(('make', 'LOCALE=ll-LL', 'POINDIR=tests/tmp/po', 'POOUTDIR=tests/tmp/po', 'newpo'), 0, None, None, devnull, devnull).wait() + proc = subprocess.Popen(('make', 'LOCALE=ll-LL', 'POINDIR=tests/tmp/po', 'POOUTDIR=tests/tmp/po', 'newproject'), 0, None, None, devnull, devnull).wait() devnull.close() def tearDown(self): - tmpdirs = ('po/ll-LL', 'locale/ll-LL') - tmpfiles = ('po/test.properties.pot', 'locale/ll-LL/temp.properties.po') - for dir in tmpdirs: - if os.access(dir, os.F_OK): - for file in os.listdir(dir): - os.remove(os.path.join(dir, file)) - os.rmdir(dir) - - for file in tmpfiles: + for dir in self.po_tmp_dirs: + for root, dirs, files in os.walk(os.path.join(os.path.dirname(__file__), dir), topdown=False): + for name in files: + os.remove(os.path.join(root, name)) + for name in dirs: + os.rmdir(os.path.join(root, name)) + + for file in self.po_tmp_files: if os.access(file, os.F_OK): os.remove(file) + if os.access('tests/tmp', os.F_OK): + os.rmdir('tests/tmp') + def testnewpofiles(self): # Create a brand new set of PO files from our en-US project files. # Compare the files generated in the po/ll-LL directory with @@ -43,9 +55,9 @@ class TestPOFramework(unittest.TestCase): for path in glob.glob(po_dir): po_files.append(os.path.basename(path) + '.po') po_files.sort() - new_pofiles = os.listdir('po/ll-LL/') + new_pofiles = os.listdir(self.locale_dir) new_pofiles.sort() - self.assertEqual(po_files, new_pofiles) + self.assertEqual(len(po_files), len(new_pofiles)) def testnewprojectfiles(self): # Create a brand new set of project files from PO files. @@ -55,17 +67,17 @@ class TestPOFramework(unittest.TestCase): for path in glob.glob(po_dir): moz_files.append(os.path.basename(path)) moz_files.sort() - new_mozfiles = os.listdir('locale/ll-LL/') + new_mozfiles = os.listdir(self.locale_dir) new_mozfiles.sort() - self.assertEqual(moz_files, new_mozfiles) + self.assertEqual(len(moz_files), len(new_mozfiles)) def testtranslatedfile(self): # "Translate" strings in a PO file, then generate the project # files to ensure that the translated string appears in the output. # Create the "translated" PO file - commonpo = 'po/ll-LL/common.properties.po' - testpo = 'po/ll-LL/test.properties.po' + commonpo = os.path.join(self.locale_dir, 'common.properties.po') + testpo = os.path.join(self.locale_dir, 'test.properties.po') commonfile = open(commonpo) testfile = open(testpo, 'w') for line in commonfile: @@ -77,8 +89,8 @@ class TestPOFramework(unittest.TestCase): os.rename(testpo, commonpo) # Create the "translated" properties file - commonprops = 'locale/ll-LL/common.properties' - testprops = 'locale/ll-LL/test.properties' + commonprops = os.path.join(self.locale_dir, 'common.properties') + testprops = os.path.join(self.locale_dir, 'test.properties') commonfile = open(commonprops) testfile = open(testprops, 'w') for line in commonfile: @@ -89,7 +101,7 @@ class TestPOFramework(unittest.TestCase): # Regenerate the project files to get the translated strings in place devnull = open('/dev/null', 'w') - proc = subprocess.Popen(('make', 'LOCALE=ll-LL', 'updateproject'), 0, None, None, devnull, devnull).wait() + proc = subprocess.Popen(('make', 'LOCALE=ll-LL', 'POINDIR=tests/tmp/po', 'POOUTDIR=tests/tmp/po', 'updateproject'), 0, None, None, devnull, devnull).wait() self.assertEqual(filecmp.cmp(commonprops, testprops), 1) @@ -98,8 +110,8 @@ class TestPOFramework(unittest.TestCase): # include the new strings # Create the "template" PO file - commonpo = 'po/ll-LL/common.properties.po' - testpo = 'po/ll-LL/test.properties.po' + commonpo = os.path.join(self.locale_dir, 'common.properties.po') + testpo = os.path.join(self.locale_dir, 'test.properties.po') commonfile = open(commonpo) testfile = open(testpo, 'w') for line in commonfile: @@ -109,8 +121,8 @@ class TestPOFramework(unittest.TestCase): testfile.close() # Create the test POT file - commonpot = 'po/common.properties.pot' - testpot = 'po/test.properties.pot' + commonpot = os.path.join(self.pot_dir, 'common.properties.pot') + testpot = os.path.join(self.pot_dir, 'test.properties.pot') commonfile = open(commonpot) testfile = open(testpot, 'w') for line in commonfile: @@ -124,11 +136,11 @@ class TestPOFramework(unittest.TestCase): # Update the PO files to get the translated strings in place devnull = open('/dev/null', 'w') - proc = subprocess.Popen(('make', 'LOCALE=ll-LL', 'updatepo'), 0, None, None, devnull, devnull).wait() + proc = subprocess.Popen(('make', 'LOCALE=ll-LL', 'POINDIR=tests/tmp/po', 'POOUTDIR=tests/tmp/po', 'updatepo'), 0, None, None, devnull, devnull).wait() - commonprops = 'po/ll-LL/common.properties.po' - tempprops = 'po/ll-LL/temp.properties.po' - testprops = 'po/ll-LL/test.properties.po' + commonprops = os.path.join(self.locale_dir, 'common.properties.po') + tempprops = os.path.join(self.locale_dir, 'temp.properties.po') + testprops = os.path.join(self.locale_dir, 'test.properties.po') # Munge the common file to make it what we expect it to be commonfile = open(commonprops, 'a+') -- 2.43.2