Package translate :: Package convert :: Module test_prop2mozfunny
[hide private]
[frames] | no frames]

Source Code for Module translate.convert.test_prop2mozfunny

 1  #!/usr/bin/env python 
 2   
 3  from translate.convert import prop2mozfunny 
 4  from translate.misc import wStringIO 
 5   
6 -class TestPO2Prop:
7 - def merge2inc(self, incsource, posource):
8 """helper that merges po translations to .inc source without requiring files""" 9 inputfile = wStringIO.StringIO(posource) 10 templatefile = wStringIO.StringIO(incsource) 11 outputfile = wStringIO.StringIO() 12 result = prop2mozfunny.po2inc(inputfile, outputfile, templatefile) 13 outputinc = outputfile.getvalue() 14 print outputinc 15 assert result 16 return outputinc
17
18 - def test_no_endlines_added(self):
19 """check that we don't add newlines at the end of file""" 20 posource = '''# converted from #defines file\n#: MOZ_LANG_TITLE\nmsgid "English (US)"\nmsgstr "Deutsch (DE)"\n\n''' 21 inctemplate = '''#define MOZ_LANG_TITLE Deutsch (DE)\n''' 22 incexpected = inctemplate 23 incfile = self.merge2inc(inctemplate, posource) 24 print incfile 25 assert incfile == incexpected
26
28 """check that we handle uncommenting contributors properly""" 29 posource = '''# converted from #defines file 30 #: MOZ_LANGPACK_CONTRIBUTORS 31 msgid "<em:contributor>Joe Solon</em:contributor>" 32 msgstr "<em:contributor>Mr Fury</em:contributor>" 33 ''' 34 inctemplate = '''# #define MOZ_LANGPACK_CONTRIBUTORS <em:contributor>Joe Solon</em:contributor>\n''' 35 incexpected = '''#define MOZ_LANGPACK_CONTRIBUTORS <em:contributor>Mr Fury</em:contributor>\n''' 36 incfile = self.merge2inc(inctemplate, posource) 37 print incfile 38 assert incfile == incexpected
39