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
ffa050aa
Commit
ffa050aa
authored
Oct 27, 2015
by
Michal Čihař
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #898 from quinox/json_newline
End JSON files with a newline
parents
0cb4a07f
d82da8b8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
2 deletions
+28
-2
weblate/trans/aresource.py
weblate/trans/aresource.py
+2
-2
weblate/trans/tests/test_formats.py
weblate/trans/tests/test_formats.py
+26
-0
No files found.
weblate/trans/aresource.py
View file @
ffa050aa
...
...
@@ -37,7 +37,7 @@ class JsonFile(JsonFileTT):
# simple JSON files.
for
unit
in
self
.
units
:
data
[
unit
.
getid
().
lstrip
(
'.'
)]
=
unit
.
source
return
json
.
dumps
(
return
(
json
.
dumps
(
data
,
sort_keys
=
True
,
separators
=
(
','
,
': '
),
indent
=
4
,
ensure_ascii
=
False
).
encode
(
'utf-8'
)
)
+
'
\
n
'
)
.
encode
(
'utf-8'
)
weblate/trans/tests/test_formats.py
View file @
ffa050aa
...
...
@@ -213,3 +213,29 @@ if 'resx' in FILE_FORMATS:
FIND
=
u'Hello'
FIND_MATCH
=
u''
MATCH
=
'<root></root>'
class
OutputTest
(
TestCase
):
def
test_json_default_output
(
self
):
json_input
=
'{"string_xyz":"Foo Bar","string_abc": "Checkbox? ☑!"}'
# Expected result:
# - Keys sorted alphabetically
# - No trailing spaces
# - Newline at the end of the file
# - Embedded Unicode chars (not replaced by \uxxx versions)
# - UTF-8 file
json_expected_output
=
u'''{
"string_abc": "Checkbox? ☑!",
"string_xyz": "Foo Bar"
}
'''
out
=
tempfile
.
NamedTemporaryFile
()
out
.
write
(
json_input
)
out
.
flush
()
JSONFormat
(
out
.
name
).
save
()
with
open
(
out
.
name
)
as
handle
:
self
.
assertEqual
(
handle
.
read
().
decode
(
'UTF-8'
),
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