Skip to content

Commit

Permalink
Fixed txt storage tests on Python 3
Browse files Browse the repository at this point in the history
  • Loading branch information
claudep committed Sep 10, 2015
1 parent ebe7793 commit 320a1af
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions translate/storage/test_txt.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def txtparse(self, txtsource):

def txtregen(self, txtsource):
"""helper that converts txt source to txtfile object and back"""
return self.txtparse(txtsource).serialize()
return self.txtparse(txtsource).serialize().decode('utf-8')

def test_simpleblock(self):
"""checks that a simple txt block is parsed correctly"""
Expand All @@ -37,5 +37,5 @@ def test_multipleblocks(self):
print(txtsource)
print(txtfile.serialize())
print("*%s*" % txtfile.units[0])
assert txtfile.serialize() == txtsource
assert txtfile.serialize().decode('utf-8') == txtsource
assert self.txtregen(txtsource) == txtsource
6 changes: 3 additions & 3 deletions translate/storage/txt.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ def parse(self, lines):
pretext = ""
posttext = ""
if not isinstance(lines, list):
lines = lines.split("\n")
for linenum in range(len(lines)):
line = lines[linenum].rstrip("\r\n")
lines = lines.split(b"\n")
for linenum, line in enumerate(lines):
line = line.decode(self.encoding).rstrip("\r\n")
for rule, prere, postre in self.flavour:
match = prere.match(line)
if match:
Expand Down

0 comments on commit 320a1af

Please sign in to comment.