Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
24a0aa54
Commit
24a0aa54
authored
Feb 13, 2016
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix some file format tests for Python 3
Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
a54691b2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
5 deletions
+12
-5
weblate/trans/formats.py
weblate/trans/formats.py
+1
-1
weblate/trans/tests/test_formats.py
weblate/trans/tests/test_formats.py
+11
-4
No files found.
weblate/trans/formats.py
View file @
24a0aa54
...
...
@@ -873,7 +873,7 @@ class PoFormat(FileFormat):
@
classmethod
def
create_new_file
(
cls
,
filename
,
code
,
base
):
"""Handles creation of new translation file."""
with
open
(
base
,
'r'
)
as
handle
:
with
open
(
base
,
'r
b
'
)
as
handle
:
data
=
handle
.
read
()
# Assume input is UTF-8 if not specified
if
b'Content-Type: text/plain; charset=CHARSET'
in
data
:
...
...
weblate/trans/tests/test_formats.py
View file @
24a0aa54
...
...
@@ -22,6 +22,7 @@ File format specific behavior.
'''
from
__future__
import
unicode_literals
import
io
import
tempfile
from
unittest
import
TestCase
,
SkipTest
...
...
@@ -116,7 +117,10 @@ class AutoFormatTest(SimpleTestCase):
testdata
=
handle
.
read
()
# Create test file
testfile
=
tempfile
.
NamedTemporaryFile
(
suffix
=
'.{0}'
.
format
(
self
.
EXT
))
testfile
=
tempfile
.
NamedTemporaryFile
(
suffix
=
'.{0}'
.
format
(
self
.
EXT
),
mode
=
'w+'
)
try
:
# Write test data to file
testfile
.
write
(
testdata
)
...
...
@@ -157,7 +161,10 @@ class AutoFormatTest(SimpleTestCase):
def
test_add
(
self
):
if
self
.
FORMAT
.
supports_new_language
():
self
.
assertTrue
(
self
.
FORMAT
.
is_valid_base_for_new
(
self
.
BASE
))
out
=
tempfile
.
NamedTemporaryFile
(
suffix
=
'.{0}'
.
format
(
self
.
EXT
))
out
=
tempfile
.
NamedTemporaryFile
(
suffix
=
'.{0}'
.
format
(
self
.
EXT
),
mode
=
'w+'
)
self
.
FORMAT
.
add_language
(
out
.
name
,
'cs'
,
self
.
BASE
)
data
=
out
.
read
()
self
.
assertTrue
(
self
.
MATCH
in
data
)
...
...
@@ -314,9 +321,9 @@ class OutputTest(TestCase):
out
.
write
(
json_input
.
encode
(
'utf-8'
))
out
.
flush
()
JSONFormat
(
out
.
name
).
save
()
with
open
(
out
.
name
)
as
handle
:
with
io
.
open
(
out
.
name
)
as
handle
:
self
.
assertEqual
(
handle
.
read
()
.
decode
(
'UTF-8'
)
,
handle
.
read
(),
json_expected_output
)
out
.
close
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment