6 from translate
.storage
import test_base
7 from translate
.storage
import mo
9 class TestMOUnit(test_base
.TestTranslationUnit
):
16 "PO-Revision-Date: 2006-02-09 23:33+0200\n"
18 "Content-Type: text/plain; charset=UTF-8\n"
19 "Content-Transfer-Encoding: 8-bit\n"
24 "PO-Revision-Date: 2006-02-09 23:33+0200\n"
26 "Content-Type: text/plain; charset=UTF-8\n"
27 "Content-Transfer-Encoding: 8-bit\n"
35 "PO-Revision-Date: 2006-02-09 23:33+0200\n"
37 "Content-Type: text/plain; charset=UTF-8\n"
38 "Content-Transfer-Encoding: 8-bit\n"
51 "PO-Revision-Date: 2006-02-09 23:33+0200\n"
53 "Content-Type: text/plain; charset=UTF-8\n"
54 "Content-Transfer-Encoding: 8-bit\n"
72 "PO-Revision-Date: 2006-02-09 23:33+0200\n"
74 "Content-Type: text/plain; charset=UTF-8\n"
75 "Content-Transfer-Encoding: 8-bit\n"
95 class TestMOFile(test_base
.TestTranslationStore
):
96 StoreClass
= mo
.mofile
98 def get_mo_and_po(self
):
99 return (os
.path
.abspath(self
.filename
+ '.po'),
100 os
.path
.abspath(self
.filename
+ '.msgfmt.mo'),
101 os
.path
.abspath(self
.filename
+ '.pocompile.mo'))
103 def remove_po_and_mo(self
):
104 for file in self
.get_mo_and_po():
105 if os
.path
.exists(file):
108 def setup_method(self
, method
):
109 test_base
.TestTranslationStore
.setup_method(self
, method
)
110 self
.remove_po_and_mo()
112 def teardown_method(self
, method
):
113 test_base
.TestTranslationStore
.teardown_method(self
, method
)
114 self
.remove_po_and_mo()
116 def test_output(self
):
117 for posource
in posources
:
118 PO_FILE
, MO_MSGFMT
, MO_POCOMPILE
= self
.get_mo_and_po()
120 out_file
= open(PO_FILE
, 'w')
121 out_file
.write(posource
)
124 subprocess
.call(['msgfmt', PO_FILE
, '-o', MO_MSGFMT
])
125 subprocess
.call(['pocompile', PO_FILE
, MO_POCOMPILE
])
127 mo_msgfmt_f
= open(MO_MSGFMT
)
128 mo_pocompile_f
= open(MO_POCOMPILE
)
131 assert mo_msgfmt_f
.read() == mo_pocompile_f
.read()
134 mo_pocompile_f
.close()