Duac@sdZdZddlZddlZddlZddlZddlZddlZddlZddl Z yddl Z Wne k rddl Z nXye Wnek rdZ nXddlmZddlmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZej re!Z"ndZ#dZ$dZ%dZ&ej'Z'ej(defdefde'fdYZ)de'fdYZ*de'fdYZ+d e'fd!YZ,d"e'fd#YZ-e j.ej/d$kpej0d%d&fkd'd(e'fd)YZ1e2d*kre j3ndS(+sTests python protocol buffers against the golden message. Note that the golden messages exercise every known field type, thus this test ends up exercising and verifying nearly all of the parsing and serialization code in the whole library. TODO(kenton): Merge with wire_format_test? It doesn't make a whole lot of sense to call this a test of the "message" module, which only declares an abstract interface. s!gps@google.com (Gregory P. Smith)iNcCs||k||kS(N((txty((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyt>t(tmap_proto2_unittest_pb2(tmap_unittest_pb2(t unittest_pb2(tunittest_proto3_arena_pb2(tdescriptor_pb2(tdescriptor_pool(tmessage_factory(t text_format(tapi_implementation(tencoder(tpacked_field_test_pb2(t test_util(ttesting_refleaks(tmessage(t_parameterizedcCs ||kS(N((tval((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pytisnanVscCst| ot|dS(Ni(R(R((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pytisinfYscCst|o|dkS(Ni(R(R((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pytIsPosInf\scCst|o|dkS(Ni(R(R((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pytIsNegInf^st_proto2t_proto3t MessageTestc BseZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!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/dFe1d.d/d0d1e2gie3g Z4d2Z5d3Z6d4Z7d5Z8d6Z9d7Z:d8Z;d9e<fd:YZ=d;Z>d<Z?d=Z@d>ZAd?ZBd@ZCdAZDdBZEdCZFdDZGdEZHRS(GcCsvtjdkr"|jdntjd}|jt}|jj|WdQX|j dt |j dS(NtpythonsSkipping testBadUtf8String, currently only the python api implementation raises UnicodeDecodeError when a string field contains bad utf-8.tbad_utf8_stringsTestAllTypes.optional_string( R tTypetskipTestRtGoldenFileDatat assertRaisestUnicodeDecodeErrort TestAllTypest FromStringtassertIntstrt exception(tselftmessage_modulet bad_utf8_datatcontext((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestBadUtf8Stringjs cCs|tkrtjd}ntjd}|j}|j||tkretj||n|j||jtj |}|j||jdS(Nt golden_message_oneof_implementedtgolden_message_proto3( RRRR"tParseFromStringtExpectAllFieldsSett assertEqualtSerializeToStringtcopytdeepcopy(R'R(t golden_datatgolden_messaget golden_copy((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestGoldenMessagets     cCstjd}|j}|j||j}tj||j|||j||jtj|}|j||jdS(Ntgolden_packed_fields_message( RRtTestPackedTypesR.tSetAllPackedFieldsR0R1R2R3(R'R(R4R5tall_setR6((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestGoldenPackedMessages    c Cs*|j}|jt|jd|jt|jdtjdd}tjdkr|jt j }|j|WdQX|j dt |j ntjdtr}tjd|j|t|dkstt|d jtst|j d t |d j WdQXdS( Nit0iiRsUnexpected end-group tag.trecordtalwaysis4Unexpected end-group tag: Not all data was converted(R"R t TypeErrorR#t ExceptionR tTagBytesR RRt DecodeErrorR0R%R&twarningstcatch_warningstTruet simplefiltertlentAssertionErrort issubclasstcategorytRuntimeWarning(R'R(tmsgtend_tagR*tw((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestParseErrorss    csd}|j}|jjddddg|j||jdd|j||jdt|j||jdtdtfdYd t ffd Y}|j |jd|WdQXdS( Ns5 One string Two string Red string Blue strings One strings Two strings Red strings Blue stringt deterministict BadArgErrorcBseZRS((t__name__t __module__(((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyRRstBadArgcs&eZfdZfdZRS(cs dS(N((R'(RR(sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyt __nonzero__scs dS(N((R'(RR(sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyt__bool__s(RSRTRVRW((RR(sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyRUs( R"trepeated_stringtextendR0R1tNonetFalseRFRAtobjectR (R'R(R4R5RU((RRsI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestDeterminismParameterss"      cCsZtjd}|j}|j|tj|}tj|}|j||dS(NR5(RRR"R.tpickletdumpstloadsR0(R'R(R4R5tpickled_messagetunpickled_message((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestPickleSupports   cCs|tkrd}nd}|j}|j||jt|j|jt|j|jt|jd|jt|jd|j ||j dS(Ns]as ]ai( RR"R.t assertTrueRtoptional_floattoptional_doubletrepeated_floattrepeated_doubleR0R1(R'R(R4R5((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestPositiveInfinitys    cCs|tkrd}nd}|j}|j||jt|j|jt|j|jt|jd|jt|jd|j ||j dS(Ns]as ]ai( RR"R.RdRReRfRgRhR0R1(R'R(R4R5((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestNegativeInfinitys    cCsd}|j}|j||jt|j|jt|j|jt|jd|jt|jd|j}|j}|j||jt|j|jt|j|jt|jd|jt|jddS(Ns]ai( R"R.RdRReRfRgRhR1(R'R(R4R5t serializedR((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestNotANumbers     cCsmd}|j}|j||jt|jd|jt|jd|j||jdS(Nsi(R9R.RdRt packed_floatt packed_doubleR0R1(R'R(R4R5((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestPositiveInfinityPackeds   cCsmd}|j}|j||jt|jd|jt|jd|j||jdS(Nsi(R9R.RdRRmRnR0R1(R'R(R4R5((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestNegativeInfinityPackeds   cCsd}|j}|j||jt|jd|jt|jd|j}|j}|j||jt|jd|jt|jddS(Nsi(R9R.RdRRmRnR1(R'R(R4R5RkR((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestNotANumberPacked%s     cCs|j}tjdd}||_|j|j|j|j|kdtjdd}||_|j|j|j|j|k| |_|j|j|j|j| k| |_|j|j|j|j| ktjdd}||_|j|j|j|j|kdtjdd}||_|j|j|j|j|k| |_|j|j|j|j| k| |_|j|j|j|j| kdS(Niig?i(R"tmathtpowReR.R1Rd(R'R(RtkMostPosExponentNoSigBitstkMostPosExponentOneSigBittkMostNegExponentNoSigBitstkMostNegExponentOneSigBit((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestExtremeFloatValues3s:         cCs|j}tjdd}||_|j|j|j|j|kdtjdd}||_|j|j|j|j|k| |_|j|j|j|j| k| |_|j|j|j|j| ktjdd}||_|j|j|j|j|kdtjdd}||_|j|j|j|j|k| |_|j|j|j|j| k| |_|j|j|j|j| kdS(Niig?i(R"RrRsRfR.R1Rd(R'R(RRtRuRvRw((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestExtremeDoubleValues`s:         cCs/|j}d|_|jt|ddS(Ng@soptional_float: 2.0 (R"ReR0R%(R'R(R((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestFloatPrintings  cCsW|j}d|_tjdkr=|jt|dn|jt|ddS(Ng^!7ݚ?is%optional_double: 0.12345678912345678 s optional_double: 0.123456789123 (i(R"Rftsyst version_infoR0R%(R'R(R((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestHighPrecisionFloatPrintings   cCsR|j}tj||j}|j|j|jt|ddS(NR(R"RtSetAllNonLazyFieldstTestEmptyMessageR.R1R0R%(R'R(t populatedtempty((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestUnknownFieldPrintings    cCs|j}|jjdd|jjdd|jjdd|jjdd|jddddgg|jD]}|j^qw|jddddggt|jD]}|j^q|jddddgg|jdddD]}|j^qdS(Ntbbiiiii(R"trepeated_nested_messagetaddR0Rtreversed(R'R(RMtm((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyt testRepeatedNestedFieldIterations  &cCs|j}|jjd|jjd|jjd|jj|j|jdd|j|jdd|j|jdd|jt|jtdddg|jjd|jjd|jjd|jj|j|jdd|j|jdd|j|jdd|jjd|jjd |jjd |jj|j|jdd|j|jdd |j|jdd |jt|jtd d d g|j jd|j jd |j jd |j j|j|j dd|j|j dd |j|j dd |jt|j tdd d gdS(s7Check some different types with the default comparator.iiiig?g?g333333?tatctbuaubucN( R"trepeated_int32tappendtsortR0R%RgtassertAlmostEqualRXtrepeated_bytes(R'R(R((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyt0testSortingRepeatedScalarFieldsDefaultComparators@  (  ( cCs |j}|jjd|jjd|jjd|jjdt|j|jdd|j|jdd|j|jdd|jjd|jjd |jjd |jjdt|j|jdd |j|jdd |j|jddd S( s2Check some different types with custom comparator.iiitkeyiiitaaaRRN(R"RRRtabsR0RXRH(R'R(R((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyt/testSortingRepeatedScalarFieldsCustomComparators cCsM|j}d|jj_d|jj_d|jj_d|jj_d|jj_d|jj_|jjdtjd|j|jd jd|j|jdjd|j|jdjd|j|jdjd|j|jdjd|j|jdjd|jt|jd d S( sECheck passing a custom comparator to sort a repeated composite field.iiiiiiRRis0[bb: 1 , bb: 2 , bb: 3 , bb: 4 , bb: 5 , bb: 6 ]N( R"RRRRtoperatort attrgetterR0R%(R'R(R((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyt2testSortingRepeatedCompositeFieldsCustomComparators  cCsC|j}d|jj_d|jj_d|jj_d|jj_d|jj_d|jj_d|jj_|jjdd |jdddddddgg|jD]}|j^q|j}|j|j||jdddddddgg|jD]}|j^q)d S( sECheck passing a custom comparator to sort a repeated composite field.iii i!i ii RcSs |jdS(Ni (R(tz((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyR RN( R"RRRRR0R1tCleartMergeFromString(R'R(Rtntpb((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyt(testSortingRepeatedCompositeFieldsStables$     cCs|j}tjd}d}d|jj_d|jj_d|jj_d|jj_d|jj_d|jj_|jjd ||jg|jD]}|j^qddddddg|jjd |d t|jg|jD]}|j^qddddddgt j dkrEd S|jjd ||jg|jD]}|j^qhddddddg|jjd |d t|jg|jD]}|j^qddddddgd S(sECheck sorting a repeated composite field using list.sort() arguments.RcSst|j|jS(N(tcmpR(RR((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyRRiiiiiiRtreverseNt sort_functionR(i( R"RRRRRRR0RFR{R|(R'R(Rtget_bbtcmp_bbtk((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyt'testRepeatedCompositeFieldSortArgumentss.  """"cCsf|j}|jjd|jjd|jjd|jjdt|jt|jdddg|jjdtdt|jt|jdddgtj dkr7d}|jjd||jt|jdddg|jjd |dt|jt|jdddgn|j jd |j jd |j jd |j jdt |jt|j d d d g|j jdt dt|jt|j d d d gtj dkrbd }|j jd||jt|j d d d g|j jd |dt|jt|j d d d gndS(s9Check sorting a scalar field using list.sort() arguments.iiiRRicSstt|t|S(N(RR(RR((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyR>RRRRRRcSstt|t|S(N(RRH(RR((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyRLRN(i(i( R"RRRRR0tlistRFR{R|RXRH(R'R(Rtabs_cmptlen_cmp((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyt$testRepeatedScalarFieldSortArguments2s6 "" "%"" "cCs|j}|j}|jjd|jjd|jjd|jjd|jjd|jjdd|jj_d|jj_d|jj_d|jj_d|jj_d|jj_tjdkrdS||k}|j|jk}|jt ||d|jt |j|jd|jt |jdddgd|jt |j|jd|j t t |j|jWdQXdS(Niiii(i( R"RRRRRR{R|R0RR R@(R'R(tm1tm2t_((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestRepeatedFieldsComparableRs2   %cCs<|j}|j|jtj|j|jtjdS(N(R"tassertIsInstanceRt collectionstMutableSequenceR(R'R(R((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestRepeatedFieldsAreSequencesus  cCsV|j}|jtt|jWdQX|jtt|jWdQXdS(N(R"R R@thashRR(R'R(R((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestRepeatedFieldsNotHashable{s  cCs9|j}|jjjg|j|jddS(Ntpayload(tNestedTestAllTypesRRRYRdtHasField(R'R(R((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyt$testRepeatedFieldInsideNestedMessages cCs't|||j|j|dS(sMake sure that a nested message object exists. As soon as a nested message attribute is accessed, it will be present in the _fields dict, without being marked as actually being set. N(tgetattrt assertFalseR(R'RMt attribute((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pytensureNestedMessageExistss cCs<|j}|jt|jd|jt|jddS(Ntno_such_oneof_fieldi(R"R t ValueErrort WhichOneofRA(R'R(R((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyt testOneofGetCaseNonexistingFields cCs|j}|jd|jd|j|jdd|_|jd|jd|j|jd|j|jdd|_ |jd|jd|j|jd|j|jddS(Nt oneof_fieldt oneof_uint32it oneof_stringR( R"tassertIsRZRRRRR0RdR(R'R(R((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestOneofDefaultValuess   cCs|j}|jd|jdd|_|jd|jd|j|jdd|_|jd|jd|j |jd|j|jd|j |jd|jd|j|jd|j |jd|j j |jd|jd|j|jd|j |jdd|j _ |jd|jd|j |jd|j|jdd|_ |jd|jd|j |jd|j|jddS( NRi RufooRtoneof_nested_messageRt oneof_bytes( R"RRZRRR0RdRRRRRR(R'R(R((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestOneofSemanticss2      cCsU|j}d|_|j|d|jd|jd|jd|jdS(Ni RRR(R"RRR0R(R'R(R((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyt!testOneofCompositeFieldReadAccesss   cCs|j}|jd|jd|tkrJ|j|jdnd|_|jd|jd|tkr|j |jdnd|_ |jd|jd|j d|jd|jd|tkr|j|jdndS(NRi RRR( R"RRZRRRRRR0RdRt ClearField(R'R(R((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestOneofWhichOneofs       cCsz|j}d|_|jd|tkrG|j|jdn|j|jd|jd|jddS(Ni RR( R"RRRRRRRZR(R'R(R((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestOneofClearFields    cCsz|j}d|_|jd|tkrG|j|jdn|j|jd|jd|jddS(Ni RR( R"RRRRRRRZR(R'R(R((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestOneofClearSetFields    cCs|j}d|_|j|d|jd|jd|j|tkrj|j|jdn|j|jd|jd|jddS(Ni RRR( R"RRRR0RRdRR(R'R(R((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestOneofClearUnsetFields    cCsQ|j}d|_|j}|j|j|jd|jddS(Ni RR(R"RR.R1R0R(R'R(RR((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestOneofDeserializes    cCsK|j}d|_|j}|j||jd|jddS(Ni RR(R"RtCopyFromR0R(R'R(RR((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestOneofCopyFroms     cCs|j}d|j_|j}d|j_d|jj_|j||jd|jjd|jd|jjjddS(Ni RRRR(RRRRtchildt MergeFromR0R(R'R(RR((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestOneofNestedMergeFroms     cCs|j}d|jj_d|jjj_|j}d|j_|j||jd|jjd|jd|jjjddS(Ni i i RR( RRRRRRRR0R(R'R(RR((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestOneofMessageMergeFroms      cCs8|jd|jj}|jd|jddS(NRR(R"t NestedMessageR0R(R'R(R((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestOneofNestedMessageInit$s cCs[|j}d|_|j|j|jdd|_|jd|jddS(Ni RRR(R"RRt assertIsNoneRRR0(R'R(R((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestOneofClear)s     cCs5|j}td|_|j|jtjdS(smAssigning a byte string to a string field should result in the value being converted to a Unicode string.RN(R"R%toptional_stringRtsixt text_type(R'R(R((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyt"testAssignByteStringToUnicodeField1s cCs|j}|jjd|jtdtt|j!}|jt|jt|d|jj_|jtdtt|j!}|jt|jt|dS(s|It should be possible to use long-valued indicies in slices This didn't used to work in the v2 C++ implementation. iiiN( R"RRtlongRHR0RRR(R'R(Rtsl((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestLongValuedSlice8s %%c Cs|j}|jt'}|jjdtdDWdQX|jt'}|jjdtdDWdQXdS(s5This didn't use to work in the v2 C++ implementation.css|] }tVqdS(N(R(t.0ti((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pys Msi Ncss|] }tVqdS(N(R(RR((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pys Ps(R"R t NameErrorRRYtrangetrepeated_nested_enum(R'R(RR((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyt$testExtendShouldNotSwallowExceptionsIs  & igRucCs}|j}|jg|jx4tjD])}|jj||jg|jq)W|jjg|jg|jdS(s,Test no-ops extending repeated int32 fields.N(R"tassertSequenceEqualRRt FALSY_VALUESRY(R'R(Rt falsy_value((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestExtendInt32WithNothingTs cCs}|j}|jg|jx4tjD])}|jj||jg|jq)W|jjg|jg|jdS(s,Test no-ops extending repeated float fields.N(R"RRgRRRY(R'R(RR((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestExtendFloatWithNothingas cCs}|j}|jg|jx4tjD])}|jj||jg|jq)W|jjg|jg|jdS(s-Test no-ops extending repeated string fields.N(R"RRXRRRY(R'R(RR((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestExtendStringWithNothingns cCs|j}|jg|j|jjdg|jdg|j|jjddg|jdddg|j|jjddg|jdddddg|jdS(s7Test extending repeated int32 fields with python lists.iiiiiN(R"RRRY(R'R(R((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestExtendInt32WithPythonList{s cCs|j}|jg|j|jjdg|jdg|j|jjddg|jdddg|j|jjddg|jdddddg|jdS(s7Test extending repeated float fields with python lists.gg?g@g@g@N(R"RRgRY(R'R(R((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestExtendFloatWithPythonLists cCs|j}|jg|j|jjdg|jdg|j|jjddg|jdddg|j|jjddg|jdddddg|jdS(s8Test extending repeated string fields with python lists.Rt11t22t33t44N(R"RRXRY(R'R(R((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestExtendStringWithPythonLists cCsO|j}|jg|j|jjd|jdddg|jdS(sDTest extending repeated string fields with characters from a string.tabcRRRN(R"RRXRY(R'R(R((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestExtendStringWithStrings t TestIterablecBs5eZdZddZdZdZdZRS(sThis iterable object mimics the behavior of numpy.array. __nonzero__ fails for length > 1, and returns bool(item[0]) for length == 1. cCs|p g|_dS(N(t_list(R'tvalues((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyt__init__scCsLt|j}|dkrtS|dkr<t|jdStddS(NiisTruth value is ambiguous.(RHRR[tboolR(R'tsize((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyRVs   cCs t|jS(N(RHR(R'((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyt__len__scCs |jjS(N(Rt__iter__(R'((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyRsN(RSRTt__doc__RZRRVRR(((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyRs    cCs|j}|jg|j|jjtjg|jg|j|jjtjdg|jdg|j|jjtjddg|jdddg|j|jjtjddg|jdddddg|jdS(s3Test extending repeated int32 fields with iterable.iiiiiN(R"RRRYRR(R'R(R((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestExtendInt32WithIterables cCs|j}|jg|j|jjtjg|jg|j|jjtjdg|jdg|j|jjtjddg|jdddg|j|jjtjddg|jdddddg|jdS(s3Test extending repeated float fields with iterable.gg?g@g@g@N(R"RRgRYRR(R'R(R((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestExtendFloatWithIterables cCs|j}|jg|j|jjtjg|jg|j|jjtjdg|jdg|j|jjtjddg|jdddg|j|jjtjddg|jdddddg|jdS(s4Test extending repeated string fields with iterable.Rt1t2t3t4N(R"RRXRYRR(R'R(R((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestExtendStringWithIterables cCsitjdks$tjdkr(dS|j}|jtj}tj|jtj WdQXdS(Ntcppi( R RtVersionR"R R^t PickleErrorR_RtHIGHEST_PROTOCOL(R'R(RR((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyt!testPickleRepeatedScalarContainers  cCs|j}|jjdS(s?Exercise a scenario that has led to segfaults in the past. N(R"RR(R'R(R((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyt'testSortEmptyRepeatedCompositeContainers cCs5|j}|jt}|jdWdQXdS(sBUsing HasField on a repeated field should raise an exception. RN(R"R RR(R'R(RR((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestHasFieldOnRepeatedFields cCs|j}|jt}|jjWdQX|jjtd|jd|jj|jd|jjd|jd|jjd|jddg|jdS(Niiiiii(R"R t IndexErrorRtpopRYRR0(R'R(RR((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestRepeatedScalarFieldPops cCs|j}|jt}|jjWdQX|jt}|jjdWdQXx,tdD]}|jj}||_qfW|j d|jjj|j d|jjdj|j d|jjdj|j ddgg|jD]}|j^qdS(NR=iiiiii( R"R R RR R@RRRR0(R'R(RRRR((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestRepeatedCompositeFieldPops  cCs~|j}x?tdD]1}|jj|||jj}||_qW|j|j|j|j|j|jdS(Ni( R"RRtinsertRRRRR0(R'R(RRR((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestRepeatedCompareWithSelfs  cCsM|j}|jj}|j}|jj}|j|jjddS(swA case that lead to a segfault when a message detached from its parent container has itself a child container. iN(Rtrepeated_childRRR0Rtoptional_int32(R'R(R((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestReleasedNestedMessagess   cCs|j}|jtg|_WdQX|jjdtjdkro|jtg|_WdQXn|jtg|_WdQXdS(NiR(R"R tAttributeErrorRRR RR@(R'R(R((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestSetRepeatedComposite(s N(IRSRTR+R7R<RPR]RcRiRjRlRoRpRqRxRyRzR}RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRZR[t bytearraytsetRRRRRRRRR\RRRRR R R RRRRR(((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyRes   $     - -     (     #      #         *      t Proto2TestcBsYeZdZdZdZdZdZdZdZdZ dZ RS( cCs\tj}|j|jd|j|jd|j|jd|jt|jdWdQX|jt|jdWdQX|jt|jdWdQX|jd|j|jt|j |jd|j j d|_t|_ d|j _ |j |jd|j |jd|j |jdd|_t |_ d |j _ |j |jd|j |jd|j |jd|jd|jd|jd|j|jd|j|jd|j|jd|jd|j|jt|j |jd|j j dS( NRt optional_booltoptional_nested_messagetfield_doesnt_existRRiii(RR"RRR RR0RR[RRRRdRFR(R'R((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestFieldPresence:sD          cCs]tj}|jt}d|_WdQX|jt|jjd|jjdd|jd<|jtd|jdss%r does end with any of %rt.itfromlist(R%ttypetsplitRdtanytjoint __import__(R'RMt base_namet valid_namestpartst class_namet module_name((RsI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pytassertImportFromNames  cCs6tj}|j|jd|j|jddS(NtScalart Composite(RR"RRR(R'R((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestTypeNamesCanBeImported s (RSRTRR(((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyRs tPackedFieldTestcBs#eZdZdZdZRS(cCs|jjd|jjd|jjd|jjd|jjd|jjd|jjd|jjd|j jd|j jd|j jd|j jd|j jt|jjddS(Nig?(RRtrepeated_int64trepeated_uint32trepeated_uint64trepeated_sint32trepeated_sint64trepeated_fixed32trepeated_fixed64trepeated_sfixed32trepeated_sfixed64RgRht repeated_boolRFR(R'R((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyt setMessagescCs9tj}|j|d}|j||jdS(NsH "*2:BJRZ?b?jr(RR9RR0R1(R'RR4((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestPackedFields"s  cCs9tj}|j|d}|j||jdS(Ns: (0=AMQ]?a?hp(RtTestUnpackedTypesRR0R1(R'RR4((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestUnpackedFields5s  (RSRTRRR(((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyRs  Riis;explicit tests of the C++ implementation for PY27 and abovetOversizeProtosTestcBs2eZedZdZdZdZRS(cCscd}tj}tj}tj|||j|tj|j |j d|_ dS(Ns name: "f/f.msg2" package: "f" message_type { name: "msg1" field { name: "payload" number: 1 label: LABEL_OPTIONAL type: TYPE_STRING } } message_type { name: "msg2" field { name: "field" number: 1 label: LABEL_OPTIONAL type: TYPE_MESSAGE type_name: "msg1" } } sf.msg2( R tDescriptorPoolRtFileDescriptorProtoR tParsetAddR tMessageFactoryt GetPrototypetFindMessageTypeByNamet proto_cls(tclst file_desctpooltdesc((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyt setUpClassNs   cCs8|j|_dd|jj_|jj|_dS(NRii@iiii(RtptfieldRR1t p_serialized(R'((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pytsetUpqscCsmddlm}|t|j}y|j|jWn,tjk rh}|jt |dnXdS(Ni(tSetAllowOversizeProtossError parsing message( tgoogle.protobuf.pyext._messageRR[RR.RRRCR0R%(R'RtqR((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestAssertOversizeProtovs  cCsYddlm}|t|j}|j|j|j|jjj |jj dS(Ni(R( RRRFRR.RR0RRR(R'RR((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestSucceedOversizeProtos   (RSRTt classmethodRRRR(((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyRIs#  t__main__(4Rt __author__RR2RrRR^RR{RDt unittest2tunittestt ImportErrorRRtgoogle.protobufRRRRRR R R tgoogle.protobuf.internalR R RRRRRtPY3tintRRRRRt BaseTestCasetNamedParametersRRRVRRtskipIfRR|RRStmain(((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyt)st                   9 :