Skip to content

Commit

Permalink
Fixed tiki2po/po2tiki convert tests on Python 3
Browse files Browse the repository at this point in the history
  • Loading branch information
claudep committed Sep 14, 2015
1 parent 6305abe commit 2baa1eb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
9 changes: 5 additions & 4 deletions translate/convert/test_po2tiki.py
Expand Up @@ -4,14 +4,15 @@
# Author: Wil Clouser <wclouser@mozilla.com>
# Date: 2008-12-01

from io import BytesIO

from translate.convert import po2tiki, test_convert
from translate.misc import wStringIO


class TestPo2Tiki:

def test_convertpo(self):
inputfile = """
inputfile = b"""
#: translated
msgid "zero_source"
msgstr "zero_target"
Expand All @@ -20,10 +21,10 @@ def test_convertpo(self):
msgid "one_source"
msgstr "one_target"
"""
outputfile = wStringIO.StringIO()
outputfile = BytesIO()
po2tiki.convertpo(inputfile, outputfile)

output = outputfile.getvalue()
output = outputfile.getvalue().decode('utf-8')

assert '"one_source" => "one_target",' in output
assert '"zero_source" => "zero_target",' in output
Expand Down
15 changes: 8 additions & 7 deletions translate/convert/test_tiki2po.py
Expand Up @@ -4,39 +4,40 @@
# Author: Wil Clouser <wclouser@mozilla.com>
# Date: 2008-12-01

from io import BytesIO

from translate.convert import test_convert, tiki2po
from translate.misc import wStringIO


class TestTiki2Po:

def test_converttiki_defaults(self):
inputfile = """
inputfile = b"""
"zero_source" => "zero_target",
// ### Start of unused words
"one_source" => "one_target",
// ### end of unused words
"""
outputfile = wStringIO.StringIO()
outputfile = BytesIO()
tiki2po.converttiki(inputfile, outputfile)

output = outputfile.getvalue()
output = outputfile.getvalue().decode('utf-8')

assert '#: translated' in output
assert 'msgid "zero_source"' in output
assert "one_source" not in output

def test_converttiki_includeunused(self):
inputfile = """
inputfile = b"""
"zero_source" => "zero_target",
// ### Start of unused words
"one_source" => "one_target",
// ### end of unused words
"""
outputfile = wStringIO.StringIO()
outputfile = BytesIO()
tiki2po.converttiki(inputfile, outputfile, includeunused=True)

output = outputfile.getvalue()
output = outputfile.getvalue().decode('utf-8')

assert '#: translated' in output
assert 'msgid "zero_source"' in output
Expand Down

0 comments on commit 2baa1eb

Please sign in to comment.