Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
a3faf080
Commit
a3faf080
authored
Dec 02, 2015
by
Josh Haberman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added JSON support to Python conformance tests.
parent
325392dd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
3 deletions
+8
-3
conformance_python.py
conformance/conformance_python.py
+8
-3
No files found.
conformance/conformance_python.py
View file @
a3faf080
...
...
@@ -39,6 +39,7 @@ import struct
import
sys
import
os
from
google.protobuf
import
message
from
google.protobuf
import
json_format
import
conformance_pb2
sys
.
stdout
=
os
.
fdopen
(
sys
.
stdout
.
fileno
(),
'wb'
,
0
)
...
...
@@ -61,8 +62,11 @@ def do_test(request):
return
response
elif
request
.
WhichOneof
(
'payload'
)
==
'json_payload'
:
response
.
skipped
=
"JSON not supported yet."
return
response
try
:
json_format
.
Parse
(
request
.
json_payload
,
test_message
)
except
json_format
.
ParseError
as
e
:
response
.
parse_error
=
str
(
e
)
return
response
else
:
raise
"Request didn't have payload."
...
...
@@ -74,7 +78,8 @@ def do_test(request):
response
.
protobuf_payload
=
test_message
.
SerializeToString
()
elif
request
.
requested_output_format
==
conformance_pb2
.
JSON
:
response
.
skipped
=
"JSON not supported yet."
response
.
json_payload
=
json_format
.
MessageToJson
(
test_message
)
except
Exception
as
e
:
response
.
runtime_error
=
str
(
e
)
...
...
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