Your IP : 52.14.150.155
�
Du�ac@s\dZdZddlZddlZddlZyddlZWnek
r_ddlZnXddlm Z ddlm
Z
ddlmZddlmZddlm
Z
dd lmZdd
lmZddlmZddlmZdd
lmZddlmZdejfd��YZdefd��YZedkrXej�ndS(s%Test for google.protobuf.json_format.sjieluo@google.com (Jie Luo)i����N(tany_pb2(tduration_pb2(tfield_mask_pb2(t
struct_pb2(t
timestamp_pb2(twrappers_pb2(tunittest_mset_pb2(tunittest_pb2(twell_known_types(tjson_format(tjson_format_proto3_pb2tJsonFormatBasecBs#eZd�Zd�Zd�ZRS(cCs�d|_d|_d|_d|_td�|_d|_t|_d|_ d|_
d |j_t
j|_|jjd
�|jjd�|jjd�|jjd
�|jjd�|jjd�|jjd�|jjd�|jjd�|jjd�|jjtd��|jjt�|jjt�|jjd�|jjd�|jjd�|jjd�d |jj�_d|jj�_|jjt
j�|jjt
j�||_dS(Nii��l~tl4�?s-infgo���! @tfootbari
i���i�ll����i���i���l����igV瞯�<tinfsFew symbols!#$,;i( tint32_valuetint64_valuetuint32_valuetuint64_valuetfloattfloat_valuetdouble_valuetTruet
bool_valuetstring_valuetbytes_valuet
message_valuetvalueR
tBARt
enum_valuetrepeated_int32_valuetappendtrepeated_int64_valuetrepeated_uint32_valuetrepeated_uint64_valuetrepeated_float_valuetrepeated_double_valuetrepeated_bool_valuetFalsetrepeated_string_valuetrepeated_bytes_valuetrepeated_message_valuetaddtrepeated_enum_valuetFOOtmessage(tselfR-((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt
FillAllFields<sB cCs-tjtj|�|�|j||�dS(N(R tParset
MessageToJsontassertEqual(R.R-tparsed_message((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pytCheckParseBackascCs/tj�}|jtj|tj||�dS(N(R
tTestMessagetassertRaisesRegexpR t
ParseErrorR0(R.ttextt
error_messageR-((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt
CheckErrorfs
(t__name__t
__module__R/R4R:(((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyR:s % tJsonFormatTestcBs�eZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z
d �Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d �Z"d!�Z#d"�Z$d#�Z%d$�Z&d%�Z'd&�Z(d'�Z)d(�Z*d)�Z+d*�Z,d+�Z-d,�Z.d-�Z/d.�Z0d/�Z1RS(0cCsEtj�}|jtj|�d�tj�}|j||�dS(Ns{}(R
R5R2R R1R4(R.R-R3((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyttestEmptyMessageToJsonps
cCsitjdddddg�}|jtjtj|��tjd��tj�}|j||�dS(NRttestRiYis6{"stringValue": "test", "repeatedInt32Value": [89, 4]}(R
R5R2tjsontloadsR R1R4(R.R-R3((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyttestPartialMessageToJsonws cCsztj�}d}|j|�|jtjtj|��tj|��tj�}tj||�|j||�dS(Ns�{"int32Value": 20, "int64Value": "-20", "uint32Value": 3120987654,"uint64Value": "12345678900","floatValue": "-Infinity","doubleValue": 3.1415,"boolValue": true,"stringValue": "foo","bytesValue": "YmFy","messageValue": {"value": 10},"enumValue": "BAR","repeatedInt32Value": [2147483647, -2147483648],"repeatedInt64Value": ["9007199254740992", "-9007199254740992"],"repeatedUint32Value": [268435455, 134217727],"repeatedUint64Value": ["9007199254740992", "9007199254740991"],"repeatedFloatValue": [0],"repeatedDoubleValue": [1e-15, "Infinity"],"repeatedBoolValue": [true, false],"repeatedStringValue": ["Few symbols!#$,;", "bar"],"repeatedBytesValue": ["Zm9v", "YmFy"],"repeatedMessageValue": [{"value": 10}, {"value": 11}],"repeatedEnumValue": ["FOO", "BAR"]}( R
R5R/R2R@RAR R1R0(R.R-R8R3((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyttestAllFieldsToJson�s
cCsdd}tj�}d|_|jtj|�|�tj�}tj||�|j||�dS(Ns{
"enumValue": 999
}i�(R
R5RR2R R1R0(R.R8R-R3((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyttestUnknownEnumToJsonAndBack�s cCs�tj�}tjj}tjj}d|jj|_d|jj|_t j
|�}tj�}t j||�|j||�dS(NiR(
RtTestMessageSetContainertTestMessageSetExtension1tmessage_set_extensiontTestMessageSetExtension2tmessage_sett
ExtensionstitstrR R1R0R2(R.R-text1text2tmessage_textR3((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyttestExtensionToJsonAndBack�s cCs|jdd�dS(Ns{"[extensionField]": {}}s8Message type proto3.TestMessage does not have extensions(R:(R.((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyttestExtensionErrors�s cCs�tj�}tjj}tjj}d|jj|_d|jj|_t j
|�}tj�}t j||�|j||�dS(NiR(
RRERFRGRHRIRJRKRLR t
MessageToDictt ParseDictR2(R.R-RMRNtmessage_dictR3((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyttestExtensionToDictAndBack�s cCs�tj�}tjj}tjj}d|jj|_d|jj|_t j
|�}iiidd6d6idd6d6d6}|j||�d S(
s&See go/proto3-json-spec for spec.
iRRKs@[protobuf_unittest.TestMessageSetExtension1.messageSetExtension]ufooRLs@[protobuf_unittest.TestMessageSetExtension2.messageSetExtension]t
messageSetN(RRERFRGRHRIRJRKRLR RRR2(R.R-RMRNRTtgolden_dict((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt/testExtensionSerializationDictMatchesProto3Spec�s cCs�tj�}tjj}tjj}d|jj|_d|jj|_t j
|�}d}d}d||f}|jtj
|�tj
|��dS(s&See go/proto3-json-spec for spec.
iRs>protobuf_unittest.TestMessageSetExtension1.messageSetExtensions>protobuf_unittest.TestMessageSetExtension2.messageSetExtensionsZ{"messageSet": { "[%s]": { "i": 23 }, "[%s]": { "str": "foo" }}}N(RRERFRGRHRIRJRKRLR R1R2R@RA(R.R-RMRNROt ext1_textt ext2_texttgolden_text((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt/testExtensionSerializationJsonMatchesProto3Spec�s
cCs�tj�}tjddkr+d|_n!d|_|jdjd�7_|jtj|�d�tj�}|j ||�d}tj
||�|j|jd �dS(
Niis&
<"
> \/
s&
<"
> \/s
sutf-8s;{
"stringValue": "&\n<\"\r>\b\t\f\\\u0001/\u2028\u2029"
}u{"int32Value": "1"}i(R
R5tsystversion_infoRtdecodeR2R R1R4R0R(R.R-R3R8((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyttestJsonEscapeString�s cCs`tjdd�}|jtjtj|t��tjd��tj�}|j||�dS(NRRs�{"repeatedStringValue": [],"stringValue": "foo","repeatedBoolValue": [],"repeatedUint32Value": [],"repeatedInt32Value": [],"enumValue": "FOO","int32Value": 0,"floatValue": 0,"int64Value": "0","uint32Value": 0,"repeatedBytesValue": [],"repeatedUint64Value": [],"repeatedDoubleValue": [],"bytesValue": "","boolValue": false,"repeatedEnumValue": [],"uint64Value": "0","doubleValue": 0,"repeatedFloatValue": [],"repeatedInt64Value": [],"repeatedMessageValue": []}( R
R5R2R@RAR R1RR4(R.R-R3((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyttestAlwaysSeriliazes cCsytj�}tjd|�|j|jd�tjd|�|j|jd�tjd|�|j|jd�dS(Ns{"int32Value": -2.147483648e9}i�s{"int32Value": 1e5}i��s{"int32Value": 1.0}i(R
R5R R0R2R(R.R-((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyttestIntegersRepresentedAsFloat-scCs8tj�}|jtjtj|t��tjd��d|jt<d|jt <d|j
d<d|j
d<d|jd<d|jd<d|jd<d|jd<d|j
d<d|j
d<d|jd<d|jd<d|jdjt<|jtjtj|t ��tjd��tj�}|j||�dS(Nsj{"boolMap": {},"int32Map": {},"int64Map": {},"uint32Map": {},"uint64Map": {},"stringMap": {},"mapMap": {}}iiit1tnulls�{"boolMap": {"false": 2, "true": 1},"int32Map": {"1": 2, "2": 3},"int64Map": {"1": 2, "2": 3},"uint32Map": {"1": 2, "2": 3},"uint64Map": {"1": 2, "2": 3},"stringMap": {"1": 2, "null": 3},"mapMap": {"1": {"boolMap": {"true": 3}}}}(R
t
TestNestedMapR2R@RAR R1Rtbool_mapR&t int32_mapt int64_mapt
uint32_mapt
uint64_mapt
string_maptmap_mapR4(R.R-R3((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt
testMapFields6s,
cCsmtj�}|jtj|t�d�d|_|jtj|t�d�tj�}|j||�dS(Ns{}is{
"oneofInt32Value": 0
}(R
t TestOneofR2R R1Rtoneof_int32_valueR4(R.R-R3((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyttestOneofFields^s cCs_tj�}tjd|�|j|jdjdd��|jdd�|jdd�dS(Ns{"stringValue": "\uD83D\uDE01"}s😁sutf-8tstricts{"stringValue": "\uD83D"}s*Invalid \\uXXXX escape|Unpaired.*surrogates{"stringValue": "\uDE01"}(R
R5R R0R2RR_R:(R.R-((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyttestSurrogatesmscCs�tj�}d|j_d|j_d|jj�_d|jd_d|jj�_d|jd_d|jj�_d|jd_d|jj�_d|jd _d
|jj�_d|jd_|jtj t
j|t��tj d��tj�}|j
||�d
}t
j||�|j|jjd�|j|jjd�|j|jdjd�|j|jdjdd�dS(Niiii'i�ilA��i�ɚ;il����w#o9is�{"value": "1970-01-01T00:00:00Z","repeatedValue": [ "1970-01-01T00:00:20.000000001Z", "1970-01-01T00:00:00.000010Z", "1973-03-03T09:46:40Z", "9999-12-31T23:59:59.999999999Z", "0001-01-01T00:00:00Z"]}s}{"value": "1970-01-01T00:00:00.01+08:00","repeatedValue":[ "1970-01-01T00:00:00.01+08:30", "1970-01-01T00:00:00.01-01:23"]}i����ii���g!�ii<i����g��id(R
t
TestTimestampRtsecondstnanostrepeated_valueR*R2R@RAR R1RR4R0(R.R-R3R8((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyttestTimestampMessage~s0
cCs�tj�}d|j_d|jj�_d|jd_d|jj�_d|jd_d|jj�_d|jd_d|jj�_d |jj�_|jtj t
j|t��tj d
��tj�}|j
||�dS(Niii
i����i���i�اil�����s%l�s%ss{"value": "1s","repeatedValue": [ "0.000000010s", "-1.000001s", "10.011s", "-315576000000s", "315576000000s"]}(R
tTestDurationRRtRvR*RuR2R@RAR R1RR4(R.R-R3((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyttestDurationMessage�s
cCsntj�}|jjjd�|jjjd�|jtj|t�d�tj�}|j ||�dS(Nsfoo.barR
s{
"value": "foo.bar,bar"
}(
R
t
TestFieldMaskRtpathsRR2R R1RR4(R.R-R3((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyttestFieldMaskMessage�scCs�tj�}t|j_d|j_d|j_d|j_t|j j
�_t|j j
�_|jj
�|jt
jtj|t��t
jd��tj�}|j||�dS(NitsR{
"int32Value": 0, "boolValue": false, "stringValue": "", "bytesValue": "", "repeatedBoolValue": [true, false], "repeatedInt32Value": [0], "repeatedUint32Value": [], "repeatedFloatValue": [], "repeatedDoubleValue": [], "repeatedBytesValue": [], "repeatedInt64Value": [], "repeatedUint64Value": [], "repeatedStringValue": []}(R
tTestWrapperR&RRRRRRR%R*RR2R@RAR R1R4(R.R-R3((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyttestWrapperMessage�s
cCstj�}d|jd<d|jd<t|jd<d|jd<d|jjd�d <d
|jdd<|jjd�}|jd
dttdg�d|j �d<d|j
j�d<|j
j�|jt
jtj|t��t
jd��tj�}|j||�dS(NtJimtnamei
tagetattendtemailtSFOtaddresstcityithouse_numbertlistitseveni tsubkey2is{ "value": { "address": { "city": "SFO", "house_number": 1024 }, "age": 10, "name": "Jim", "attend": true, "email": null, "list": [6, "seven", true, false, null, {"subkey2": 9}] }, "repeatedValue": [{"age": 11}, {}]}(R
t
TestStructRRtNonetget_or_create_structtget_or_create_listtextendR&t
add_structRvR*R2R@RAR R1R4(R.R-tstruct_listR3((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyttestStructMessage�s$
cCs
tj�}d|j_d|jj�_t|jj�_d|jj�_ |j
tjt
j|t��tjd��tj�}|j||�|jj�|j
tjt
j|t��tjd��|j�t
jd|�|j
|jjd�d�dS( Nthellog333333&@is;{ "value": "hello", "repeatedValue": [11.1, false, null]}sA{ "value": "hello", "repeatedValue": [11.1, false, null, null]}s{"value": null}tkindt
null_value(R
t TestValueRRRvR*tnumber_valueR&RR�R2R@RAR R1R4tClearR0t
WhichOneof(R.R-R3((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyttestValueMessage
s&
cCs�tj�}d|jjj�_d|jjj�_t|jjj�_d|jjj�_ d|jjj�j
d<d|jj�jj�_|jj�|jt
jtj|t��t
jd��tj�}|j||�dS(Ng333333&@iR�R�R�isS{"value": [11.1, null, true, "hello", {"name": "Jim"}]
,"repeatedValue": [[1], []]}(R
t
TestListValueRtvaluesR*R�R�RRRtstruct_valueRvR2R@RAR R1R&R4(R.R-R3((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyttestListValueMessage&s
cCs@tj�}tj�}tj�}d|_d|_|jj|�|jj�j|�|jj�j|�|jj�|jtj t
j|t��tj d��tj�}|j
||�tjdtddddd dd
dddd
d�}|j�|jj|�|jt
j|t�dd!d�dS(Ni�i.s{
"repeatedValue": [ {
"@type": "type.googleapis.com/proto3.MessageType",
"value": 1234
}, {
"@type": "type.googleapis.com/proto3.MessageType",
"value": 5678
},
{}],
"value": {
"@type": "type.googleapis.com/proto3.MessageType",
"value": 1234
}
}
RRiRi��RRRg��Q� @RRiiDsD{
"value": {
"@type": "type.googleapis.com/proto3.TestMessage"(R
tTestAnytMessageTypeRtPackRvR*R2R@RAR R1RR4R5R�R&(R.R-tvalue1tvalue2R3ttest_message((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyttestAnyMessage7s8
c Csxtj�}tj�}d|_|j|�|jtjt j
|t��tjd��tj�}|j||�t
j�}|j|�|jtjt j
|t��tjd��|j||�tj�}d|_|j|�|jtjt j
|t��tjd��|j||�tj�}|jjd�|jjd�|j|�|jtjt j
|t��tjd��|j||�tj�}d |d
<|j|�|jtjt j
|t��tjd��|j||�tj�}d|_|j|�|j|�|jtjt j
|t��tjd
��|j||�dS(Ni�sQ{
"@type": "type.googleapis.com/google.protobuf.Int32Value",
"value": 1234
}
sb{
"@type": "type.googleapis.com/google.protobuf.Timestamp",
"value": "1970-01-01T00:00:00Z"
}
isO{
"@type": "type.googleapis.com/google.protobuf.Duration",
"value": "1s"
}
sfoo.barR
sY{
"@type": "type.googleapis.com/google.protobuf.FieldMask",
"value": "foo.bar,bar"
}
R�R�sX{
"@type": "type.googleapis.com/google.protobuf.Struct",
"value": {"name": "Jim"}
}
i.s�{
"@type": "type.googleapis.com/google.protobuf.Any",
"value": {
"@type": "type.googleapis.com/google.protobuf.Int32Value",
"value": 5678
}
}
(RtAnyRt
Int32ValueRR�R2R@RAR R1RR4Rt TimestampRtDurationRtRt FieldMaskR{RRtStruct( R.R-RR3t timestamptdurationt
field_masktstruct_messaget
nested_any((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyttestWellKnownInAnyMessageesf
cCs�tj�}tj�}|j|�tjd|�|j||�|j|jd��tjd|�|j|jd��|j tj
dtjd|�|jdd�dS(Ns{"int32Value": null, "int64Value": null, "uint32Value": null,"uint64Value": null,"floatValue": null,"doubleValue": null,"boolValue": null,"stringValue": null,"bytesValue": null,"messageValue": null,"enumValue": null,"repeatedInt32Value": null,"repeatedInt64Value": null,"repeatedUint32Value": null,"repeatedUint64Value": null,"repeatedFloatValue": null,"repeatedDoubleValue": null,"repeatedBoolValue": null,"repeatedStringValue": null,"repeatedBytesValue": null,"repeatedMessageValue": null,"repeatedEnumValue": null}Rs{"messageValue": {}}skFailed to parse repeatedInt32Value field: null is not allowed to be used as an element in a repeated field.s {"repeatedInt32Value":[1, null]}s{"repeatedMessageValue":[null]}smFailed to parse repeatedMessageValue field: null is not allowed to be used as an element in a repeated field.(R
R5R/R R0R2tassertFalsetHasFieldt
assertTrueR6R7R:(R.R-R3((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt
testParseNull�s"
cCsstj�}td�|_d}|jtj|�|�tj�}tj||�|jt j
|j��dS(Ntnans{
"floatValue": "NaN"
}(R
R5RRR2R R1R0R�tmathtisnan(R.R-R8R3((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyttestNanFloat�scCs|jdd�dS(NR}s1Failed to load JSON: (Expecting value)|(No JSON).(R:(R.((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyttestParseEmptyText�s cCs�tj�}d}tj||�d}tj||�|jdd�d}tj||�tj�}|jtjdtjd|�dS(Ns{"enumValue": 0}s{"enumValue": 1}s{"enumValue": "baz"}sVFailed to parse enumValue field: Invalid enum value baz for enum type proto3.EnumType.s{"enumValue": 12345}s{Failed to parse optionalNestedEnum field: Invalid enum value 12345 for enum type protobuf_unittest.TestAllTypes.NestedEnum.s{"optionalNestedEnum": 12345}( R
R5R R0R:RtTestAllTypesR6R7(R.R-R8((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyttestParseEnumValue�scCs$|jdd�|jdd�dS(Ns{int32Value: 1}sQFailed to load JSON: Expecting property name( enclosed in double quotes)?: line 1s{"unknownName": 1}sCMessage type "proto3.TestMessage" has no field named "unknownName".(R:(R.((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyttestParseBadIdentifers cCsTd}tj�}tj||dt�d}tj�}tj||dt�dS(Ns{"unknownName": 1}tignore_unknown_fieldssl{
"repeatedValue": [ {
"@type": "type.googleapis.com/proto3.MessageType",
"unknownName": 1
}]
}
(R
R5R R0RR�(R.R8R3((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyttestIgnoreUnknownFieldscCs'tjdkrdS|jdd�dS(Niis!{"int32Value": 1,
"int32Value":2}s.Failed to load JSON: duplicate key int32Value.(ii(R]R^R:(R.((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyttestDuplicateFields cCs$|jdd�|jdd�dS(Ns{"boolValue": 1}sGFailed to parse boolValue field: Expected true or false without quotes.s{"boolValue": "true"}(R:(R.((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyttestInvalidBoolValues cCs�tj�}d}|jtjtj||�|jdd�|jdd�|jdd�|jdd �|jd
d�|jdd
�dS(Ns{"int32Value": 0x12345}s{"int32Value": 1.5}s>Failed to parse int32Value field: Couldn't parse integer: 1.5.s{"int32Value": 012345}s9Failed to load JSON: Expecting \'?,\'? delimiter: line 1.s{"int32Value": " 1 "}s@Failed to parse int32Value field: Couldn't parse integer: " 1 ".s{"int32Value": "1 "}s?Failed to parse int32Value field: Couldn't parse integer: "1 ".s${"int32Value": 12345678901234567890}sKFailed to parse int32Value field: Value out of range: 12345678901234567890.s{"uint32Value": -1}s:Failed to parse uint32Value field: Value out of range: -1.(R
R5tassertRaisesR R7R0R:(R.R-R8((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyttestInvalidIntegerValue's cCs|jdd�dS(Ns{"floatValue": "nan"}sPFailed to parse floatValue field: Couldn't parse float "nan", use "NaN" instead.(R:(R.((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyttestInvalidFloatValue?s cCs$|jdd�|jdd�dS(Ns{"bytesValue": "AQI"}s4Failed to parse bytesValue field: Incorrect padding.s{"bytesValue": "AQI*"}(R:(R.((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyttestInvalidBytesValueDs cCs|jdd�dS(Ns{"repeatedInt32Value": 12345}skFailed to parse repeatedInt32Value field: repeated field repeatedInt32Value must be in \[\] which is 12345.(R:(R.((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyttestInvalidRepeatedJs cCs�tj�}d}|jtjdtj||�d}|jtjdtj||�d}|jtjdtj||�tjd
kr�dSd }|jtjd
tj||�d}|jtjdtj||�dS(Ns!{"int32Map": {"null": 2, "2": 3}}s/Failed to parse int32Map field: invalid literals{"int32Map": {1: 2, "2": 3}}sQFailed to load JSON: Expecting property name( enclosed in double quotes)?: line 1s{"boolMap": {"null": 1}}sDFailed to parse boolMap field: Expected "true" or "false", not null.iis${"stringMap": {"a": 3, "\u0061": 2}}s$Failed to load JSON: duplicate key as{"stringMap": 0}sSFailed to parse stringMap field: Map field string_map must be in a dict which is 0.(ii(R
tTestMapR6R R7R0R]R^(R.R-R8((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyttestInvalidMapOs8cCs�tj�}d}|jtjdtj||�d}|jtjdtj||�d}|jtjdtj||�d}|jtjdtj||�d |j_|jt d
tj
|�dS(Ns%{"value": "10000-01-01T00:00:00.00Z"}sKtime data '10000-01-01T00:00:00' does not match format '%Y-%m-%dT%H:%M:%S'.s/{"value": "1970-01-01T00:00:00.0123456789012Z"}s2nanos 0123456789012 more than 9 fractional digits.s&{"value": "1972-01-01T01:00:00.01+08"}s$Invalid timezone offset value: \+08.s!{"value": "0000-01-01T00:00:00Z"}s7Failed to parse value field: year (0 )?is out of range.l�A��sdate value out of range(R
RsR6R R7R0RRRtt
OverflowErrorR1(R.R-R8((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyttestInvalidTimestampos4cCs5tj�}d}|jtjdtj||�dS(Ns/{"oneofInt32Value": 1, "oneofStringValue": "2"}sTMessage type "proto3.TestOneof" should not have multiple "oneof_value" oneof fields.(R
RnR6R R7R0(R.R-R8((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyttestInvalidOneof�scCs5tj�}d}|jtjdtj||�dS(Ns{"value": 1234}sDFailed to parse value field: ListValue must be in \[\] which is 1234(R
R�R6R R7R0(R.R-R8((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyttestInvalidListValue�scCs5tj�}d}|jtjdtj||�dS(Ns{"value": 1234}sCFailed to parse value field: Struct must be in a dict which is 1234(R
R�R6R R7R0(R.R-R8((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyttestInvalidStruct�scCs�tj�}d}|jtdtj||�d}|jtjdtj||�d}|jtdtj||�d}tj||�dS(Ns;{"@type": "type.googleapis.com/google.protobuf.Int32Value"}Rs{"value": 1234}s*@type is missing when parsing any message.s?{"@type": "type.googleapis.com/MessageNotExist", "value": 1234}sQCan not find message descriptor by type_url: type.googleapis.com/MessageNotExist.sN{"@type": "incorrect.googleapis.com/google.protobuf.Int32Value","value": 1234}(RR�R6tKeyErrorR R0R7t TypeError(R.R-R8((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyttestInvalidAny�s$cCs�tj�}d|_|jdtj|��|jdtj|tt��tj�}|jdtj|tt��|jdtj|tt��tj�}tj d|�|jd|j�tj d|�|jd|j�dS( Ni90s{
"int32Value": 12345
}s{
"int32_value": 12345
}s{
"repeatedValue": []
}s{
"repeated_value": []
}s{"int32Value": 54321}i1�s{"int32_value": 12345}(
R
R5RR2R R1R&RRsR0(R.R-((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyttestPreservingProtoFieldNames�s cCs8tj�}d|_|jdtj|dd��dS(Ni90s{
"int32Value": 12345
}tindenti(R
R5RR2R R1(R.R-((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt
testIndent�s cCsFd}i|d6}tj�}tj||�|j||j�dS(Ni90t
int32Value(R
R5R RSR2R(R.texpectedtjs_dictR-((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt
testParseDict�s
cCs?tj�}d|_idd6}|j|tj|��dS(Ni90R�(R
R5RR2R RR(R.R-R�((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyttestMessageToDict�s
cCsNtj�}d|_|jdtj|��tj�}|j||�dS(Ni90s{
"@value": 12345
}(R
tTestCustomJsonNameRR2R R1R4(R.R-R3((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyttestJsonName�s cCs�tjdtdddddddd �}|jtj|d
t�tjitd6dd6d
d6dd6d d6ddd
t��dS(NRRiRiRiRtblat sort_keyst boolValueR�t3t
int64Valuetuint32ValuetstringValueR�i(R
R5RR2R R1R@tdumps(R.R-((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyttestSortKeys�s (2R;R<R>RBRCRDRPRQRURXR\R`RaRbRmRpRrRwRyR|RR�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�(((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyR=ns`
!
( ( ! . O -
t__main__(t__doc__t
__author__R@R�R]t unittest2tunittesttImportErrortgoogle.protobufRRRRRRRRtgoogle.protobuf.internalRR tgoogle.protobuf.utilR
tTestCaseRR=R;tmain(((sM/usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt<module> s4
4����
?>