ó SÉLjc@sâdZdZddlZddlZddlZddlZddlZddlZddlZddl Z yddl Z Wne k r›ddl Z nXye Wnek rÀd„Z nXddlmZddlmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZej rÃe!Z"nd„Z#d„Z$d„Z%d„Z&ej'Z'ej(defdefƒde'fd„ƒYƒZ)de'fd„ƒYZ*de'fd„ƒYZ+d e'fd!„ƒYZ,d"e'fd#„ƒYZ-e j.ej/ƒd$kp¦ej0d%d&fkd'ƒd(e'fd)„ƒYƒZ1e2d*krÞe j3ƒndS(+sœTests 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)iÿÿÿÿNcCs||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|dƒS(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 BsˆeZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „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/dFe1d.d/d0d1e2ƒgie3ƒg Z4d2„Z5d3„Z6d4„Z7d5„Z8d6„Z9d7„Z:d8„Z;d9e<fd:„ƒYZ=d;„Z>d<„Z?d=„Z@d>„ZAd?„ZBd@„ZCdA„ZDdB„ZEdC„ZFdD„ZGdE„ZHRS(GcCsvtjƒdkr"|jdƒntjdƒ}|jtƒ�}|jj|ƒWdQX|j dt |j ƒƒdS(NtpythonsŠSkipping 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||jƒƒtj |ƒ}|j||jƒƒdS(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     cCs�tjdƒ}|jƒ}|j|ƒ|jƒ}tj|ƒ|j||ƒ|j||jƒƒtj|ƒ}|j||jƒƒdS(Ntgolden_packed_fields_message( RRtTestPackedTypesR.tSetAllPackedFieldsR0R1R2R3(R'R(R4R5tall_setR6((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestGoldenPackedMessage†s    c Csö|jƒ}|jt|jdƒ|jt|jdƒtjddƒ}tjƒdkr |jt j ƒ�}|j|ƒWdQX|j dt |j ƒƒnRtjdtƒ�>}tjdƒ|j|ƒ|j d t |d j ƒƒWdQXdS( Nit0iiRsUnexpected end-group tag.trecordtalwayss4Unexpected end-group tag: Not all data was convertediÿÿÿÿ(R"R t TypeErrorR#t ExceptionR tTagBytesR RRt DecodeErrorR0R%R&twarningstcatch_warningstTruet simplefilter(R'R(tmsgtend_tagR*tw((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestParseErrors‘s    csád}|jƒ}|jjddddgƒ|j||jddƒƒ|j||jdtƒƒ|j||jdtƒƒdtfd„ƒY‰d t f‡fd †ƒ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.pyRM¼stBadArgcs&eZ‡fd†Z‡fd†ZRS(cs ˆƒ‚dS(N((R'(RM(sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyt __nonzero__Áscs ˆƒ‚dS(N((R'(RM(sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyt__bool__Äs(RNRORQRR((RM(sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyRP¿s( R"trepeated_stringtextendR0R1tNonetFalseRFRAtobjectR (R'R(R4R5RP((RMsI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestDeterminismParameters¦s"      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.pyttestPickleSupportÊs   cCs®|tkrd}nd}|jƒ}|j|ƒ|jt|jƒƒ|jt|jƒƒ|jt|jdƒƒ|jt|jdƒƒ|j ||j ƒƒdS(Ns]€aðÍ€Ñðs ]€aðÊ€Òði( RR"R.t assertTrueRtoptional_floattoptional_doubletrepeated_floattrepeated_doubleR0R1(R'R(R4R5((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestPositiveInfinityÓs    cCs®|tkrd}nd}|jƒ}|j|ƒ|jt|jƒƒ|jt|jƒƒ|jt|jdƒƒ|jt|jdƒƒ|j ||j ƒƒdS(Ns]€ÿaðÿÍ€ÿÑðÿs ]€ÿaðÿÊ€ÿÒðÿi( RR"R.R_RR`RaRbRcR0R1(R'R(R4R5((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestNegativeInfinityçs    cCsd}|jƒ}|j|ƒ|jt|jƒƒ|jt|jƒƒ|jt|jdƒƒ|jt|jdƒƒ|jƒ}|jƒ}|j|ƒ|jt|jƒƒ|jt|jƒƒ|jt|jdƒƒ|jt|jdƒƒdS(Ns]ÀaøÍÀÑøi( R"R.R_RR`RaRbRcR1(R'R(R4R5t serializedR((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestNotANumberûs     cCsmd}|jƒ}|j|ƒ|jt|jdƒƒ|jt|jdƒƒ|j||jƒƒdS(Ns¢€ªði(R9R.R_Rt 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||jƒƒdS(Ns¢€ÿªðÿi(R9R.R_RRhRiR0R1(R'R(R4R5((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestNegativeInfinityPackeds   cCs°d}|jƒ}|j|ƒ|jt|jdƒƒ|jt|jdƒƒ|jƒ}|jƒ}|j|ƒ|jt|jdƒƒ|jt|jdƒƒdS(Ns¢Àªøi(R9R.R_RRhRiR1(R'R(R4R5RfR((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestNotANumberPacked%s     cCsø|jƒ}tjddƒ}||_|j|jƒƒ|j|j|kƒdtjddƒ}||_|j|jƒƒ|j|j|kƒ| |_|j|jƒƒ|j|j| kƒ| |_|j|jƒƒ|j|j| kƒtjddƒ}||_|j|jƒƒ|j|j|kƒdtjddƒ}||_|j|jƒƒ|j|j|kƒ| |_|j|jƒƒ|j|j| kƒ| |_|j|jƒƒ|j|j| kƒdS(Niigø?i�ÿÿÿ(R"tmathtpowR`R.R1R_(R'R(RtkMostPosExponentNoSigBitstkMostPosExponentOneSigBittkMostNegExponentNoSigBitstkMostNegExponentOneSigBit((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestExtremeFloatValues3s:         cCsø|jƒ}tjddƒ}||_|j|jƒƒ|j|j|kƒdtjddƒ}||_|j|jƒƒ|j|j|kƒ| |_|j|jƒƒ|j|j| kƒ| |_|j|jƒƒ|j|j| kƒtjddƒ}||_|j|jƒƒ|j|j|kƒdtjddƒ}||_|j|jƒƒ|j|j|kƒ| |_|j|jƒƒ|j|j| kƒ| |_|j|jƒƒ|j|j| kƒdS(Niiÿgø?iüÿÿ(R"RmRnRaR.R1R_(R'R(RRoRpRqRr((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestExtremeDoubleValues`s:         cCs/|jƒ}d|_|jt|ƒdƒdS(Ng@soptional_float: 2.0 (R"R`R0R%(R'R(R((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestFloatPrinting�s  cCsW|jƒ}d|_tjdkr=|jt|ƒdƒn|jt|ƒdƒdS(Ng^!Á7Ýš¿?is%optional_double: 0.12345678912345678 s optional_double: 0.123456789123 (i(R"Ratsyst version_infoR0R%(R'R(R((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestHighPrecisionFloatPrinting’s   cCsR|jƒ}tj|ƒ|jƒ}|j|jƒƒ|jt|ƒdƒdS(NR(R"RtSetAllNonLazyFieldstTestEmptyMessageR.R1R0R%(R'R(t populatedtempty((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestUnknownFieldPrintingšs    cCs|jƒ}|jjddƒ|jjddƒ|jjddƒ|jjddƒ|jddddgg|jD]}|j^qwƒ|jddddggt|jƒD]}|j^q²ƒ|jddddgg|jddd…D]}|j^qôƒdS(Ntbbiiiiiÿÿÿÿ(R"trepeated_nested_messagetaddR0R~treversed(R'R(RHtm((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyt testRepeatedNestedFieldIteration¡s  &cCs�|jƒ}|jjdƒ|jjdƒ|jjdƒ|jjƒ|j|jddƒ|j|jddƒ|j|jddƒ|jt|jƒtdddgƒƒ|jjdƒ|jjdƒ|jjdƒ|jjƒ|j|jddƒ|j|jddƒ|j|jddƒ|jjdƒ|jjd ƒ|jjd ƒ|jjƒ|j|jddƒ|j|jdd ƒ|j|jdd ƒ|jt|jƒtd d d gƒƒ|j jdƒ|j jd ƒ|j jd ƒ|j jƒ|j|j ddƒ|j|j dd ƒ|j|j dd ƒ|jt|j ƒtdd d gƒƒdS(s7Check some different types with the default comparator.iiiigš™™™™™ñ?gÍÌÌÌÌÌô?g333333ó?tatctbuaubucN( R"trepeated_int32tappendtsortR0R%RbtassertAlmostEqualRStrepeated_bytes(R'R(R((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyt0testSortingRepeatedScalarFieldsDefaultComparator¯s@  (  ( cCs |jƒ}|jjdƒ|jjdƒ|jjdƒ|jjdtƒ|j|jddƒ|j|jddƒ|j|jddƒ|jjdƒ|jjd ƒ|jjd ƒ|jjdtƒ|j|jdd ƒ|j|jdd ƒ|j|jddƒd S( s2Check some different types with custom comparator.iýÿÿÿiþÿÿÿiÿÿÿÿtkeyiiitaaaR~R…N(R"R‡RˆR‰tabsR0RStlen(R'R(R((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyt/testSortingRepeatedScalarFieldsCustomComparator×s 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|jƒd ƒd S( sECheck passing a custom comparator to sort a repeated composite field.iiiiiiR�R~is0[bb: 1 , bb: 2 , bb: 3 , bb: 4 , bb: 5 , bb: 6 ]N( R"RR€R~R‰toperatort attrgetterR0R%(R'R(R((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyt2testSortingRepeatedCompositeFieldsCustomComparatorës  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 R�cSs |jdS(Ni (R~(tz((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyR RN( R"RR€R~R‰R0R1tCleartMergeFromString(R'R(Rtntpb((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyt(testSortingRepeatedCompositeFieldsStableÿs$     cCsë|jƒ}tjdƒ}d„}d|jjƒ_d|jjƒ_d|jjƒ_d|jjƒ_d|jjƒ_d|jjƒ_|jjd |ƒ|jg|jD]}|j^q³ddddddgƒ|jjd |d tƒ|jg|jD]}|j^qddddddgƒt j dkrEd S|jjd |ƒ|jg|jD]}|j^qhddddddgƒ|jjd |d tƒ|jg|jD]}|j^q¼ddddddgƒd S(sECheck sorting a repeated composite field using list.sort() arguments.R~cSst|j|jƒS(N(tcmpR~(R„R†((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyRRiiiiiiR�treverseNt sort_functionR›(i( R"R’R“RR€R~R‰R0RFRvRw(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|jƒdddgƒ|jjdtdtƒ|jt|jƒdddgƒtj dkr7d„}|jjd|ƒ|jt|jƒdddgƒ|jjd |dtƒ|jt|jƒdddgƒn|j jd ƒ|j jd ƒ|j jd ƒ|j jdt ƒ|jt|j ƒd d d gƒ|j jdt dtƒ|jt|j ƒd d d gƒtj dkrbd „}|j jd|ƒ|jt|j ƒd d d gƒ|j jd |dtƒ|jt|j ƒd d d gƒndS(s9Check sorting a scalar field using list.sort() arguments.iýÿÿÿiþÿÿÿiÿÿÿÿR�RœicSstt|ƒt|ƒƒS(N(R›R�(R„R†((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyR>RR�R›RŽR~R…cSstt|ƒt|ƒƒS(N(R›R�(R„R†((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyRLRN(i(i( R"R‡RˆR‰R�R0tlistRFRvRwRSR�(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ƒ|jjdƒd|jjƒ_d|jjƒ_d|jjƒ_d|jjƒ_d|jjƒ_d|jjƒ_tjdkr÷dS||k}|j|jk}|jt ||ƒdƒ|jt |j|jƒdƒ|jt |jdddgƒdƒ|jt |j|jƒdƒ|j t ƒ�t |j|jƒWdQXdS(Niiii(i( R"R‡RˆRR€R~RvRwR0R›R R@(R'R(tm1tm2t_((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestRepeatedFieldsComparableRs2   %cCs<|jƒ}|j|jtjƒ|j|jtjƒdS(N(R"tassertIsInstanceR‡t collectionstMutableSequenceR(R'R(R‚((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestRepeatedFieldsAreSequencesus  cCsV|jƒ}|jtƒ�t|jƒWdQX|jtƒ�t|jƒWdQXdS(N(R"R R@thashR‡R(R'R(R‚((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestRepeatedFieldsNotHashable{s  cCs9|jƒ}|jjjgƒ|j|jdƒƒdS(Ntpayload(tNestedTestAllTypesR°R‡RTR_tHasField(R'R(R‚((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyt$testRepeatedFieldInsideNestedMessage‚s cCs't||ƒ|j|j|ƒƒdS(sÃMake 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'RHt attribute((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pytensureNestedMessageExists‡s cCs<|jƒ}|jt|jdƒ|jt|jdƒdS(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 testOneofGetCaseNonexistingField�s cCsÛ|jƒ}|jd|jdƒƒ|j|jdƒƒd|_|jd|jdƒƒ|j|jdƒƒ|j|jdƒƒd|_ |jd|jdƒƒ|j|jdƒƒ|j|jdƒƒdS(Nt oneof_fieldt oneof_uint32it oneof_stringR( R"tassertIsRURºRµR²R½R0R_R¾(R'R(R‚((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestOneofDefaultValues•s   cCsé|jƒ}|jd|jdƒƒd|_|jd|jdƒƒ|j|jdƒƒd|_|jd|jdƒƒ|j |jdƒƒ|j|jdƒƒ|j |jd|jdƒƒ|j|jdƒƒ|j |jdƒƒ|j j |jd|jdƒƒ|j|jdƒƒ|j |jdƒƒd|j _ |jd|jdƒƒ|j |jdƒƒ|j|jdƒƒd|_ |jd|jdƒƒ|j |jdƒƒ|j|jdƒƒdS( NR¼i R½ufooR¾toneof_nested_messageR~t oneof_bytes( R"R¿RURºR½R0R_R²R¾RµRÁR~RÂ(R'R(R‚((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestOneofSemantics¥s2      cCsU|jƒ}d|_|j|dƒ|jd|jdƒƒ|jd|jƒdS(Ni RÁR½R¼(R"R½R·R0Rº(R'R(R‚((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyt!testOneofCompositeFieldReadAccessÈs   cCs|jƒ}|jd|jdƒƒ|tkrJ|j|jdƒƒnd|_|jd|jdƒƒ|tkr‘|j |jdƒƒnd|_ |jd|jdƒƒ|j dƒ|jd|jdƒƒ|tkrþ|j|jdƒƒndS(NR¼i R½R~RÂ( R"R¿RURºRRµR²R½R0R_RÂt ClearField(R'R(R‚((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestOneofWhichOneofÐs       cCsz|jƒ}d|_|jdƒ|tkrG|j|jdƒƒn|j|jdƒƒ|jd|jdƒƒdS(Ni R¼R½( R"R½RÅRRµR²R¿RURº(R'R(R‚((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestOneofClearFieldãs    cCsz|jƒ}d|_|jdƒ|tkrG|j|jdƒƒn|j|jdƒƒ|jd|jdƒƒdS(Ni R½R¼( R"R½RÅRRµR²R¿RURº(R'R(R‚((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestOneofClearSetFieldìs    cCs�|jƒ}d|_|j|dƒ|jdƒ|jd|jƒ|tkrj|j|jdƒƒn|j|jdƒƒ|jd|jdƒƒdS(Ni RÁR¼R½( R"R½R·RÅR0RR_R²Rº(R'R(R‚((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestOneofClearUnsetFieldõs    cCsQ|jƒ}d|_|jƒ}|j|jƒƒ|jd|jdƒƒdS(Ni R½R¼(R"R½R.R1R0Rº(R'R(R‚R§((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestOneofDeserializes    cCsK|jƒ}d|_|jƒ}|j|ƒ|jd|jdƒƒdS(Ni R½R¼(R"R½tCopyFromR0Rº(R'R(R‚R§((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|jjjdƒƒdS(Ni R~R½R¼RÂ(R±R°R½RÂtchildt MergeFromR0Rº(R'R(R‚R§((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|jjjdƒƒdS(Ni i i RÁR¼( R±R°RÁR~RÍR½RÎR0Rº(R'R(R‚R§((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestOneofMessageMergeFroms      cCs8|jd|jjƒƒ}|jd|jdƒƒdS(NRÁR¼(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|jdƒƒd|_|jd|jdƒƒdS(Ni R¼R~RÂ(R"R½R–t assertIsNoneRºRÂR0(R'R(R‚((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestOneofClear)s     cCs5|jƒ}tdƒ|_|j|jtjƒdS(smAssigning a byte string to a string field should result in the value being converted to a Unicode string.RN(R"R%toptional_stringRªtsixt text_type(R'R(R‚((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyt"testAssignByteStringToUnicodeField1s cCsº|jƒ}|jjdƒ|jtdƒtt|jƒƒ!}|jt|jƒt|ƒƒd|jjƒ_|jtdƒtt|jƒƒ!}|jt|jƒt|ƒƒ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"R‡RˆtlongR�R0RR€R~(R'R(R‚tsl((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestLongValuedSlice8s %%c Cs€|jƒ}|jtƒ�'}|jjd„tdƒDƒƒWdQX|jtƒ�'}|jjd„tdƒDƒƒWdQXdS(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„(RÜRÝ((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pys Ps(R"R t NameErrorR‡RTtrangetrepeated_nested_enum(R'R(R‚R¨((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyt$testExtendShouldNotSwallowExceptionsIs  & igRucCs}|jƒ}|jg|jƒx4tjD])}|jj|ƒ|jg|jƒq)W|jjgƒ|jg|jƒdS(s,Test no-ops extending repeated int32 fields.N(R"tassertSequenceEqualR‡Rt FALSY_VALUESRT(R'R(R‚t falsy_value((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestExtendInt32WithNothingTs cCs}|jƒ}|jg|jƒx4tjD])}|jj|ƒ|jg|jƒq)W|jjgƒ|jg|jƒdS(s,Test no-ops extending repeated float fields.N(R"RâRbRRãRT(R'R(R‚Rä((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestExtendFloatWithNothingas cCs}|jƒ}|jg|jƒx4tjD])}|jj|ƒ|jg|jƒq)W|jjgƒ|jg|jƒdS(s-Test no-ops extending repeated string fields.N(R"RâRSRRãRT(R'R(R‚Rä((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|jƒdS(s7Test extending repeated int32 fields with python lists.iiiiiN(R"RâR‡RT(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|jƒdS(s7Test extending repeated float fields with python lists.ggð?g@g@g@N(R"RâRbRT(R'R(R‚((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestExtendFloatWithPythonList†s cCs¶|jƒ}|jg|jƒ|jjdgƒ|jdg|jƒ|jjddgƒ|jdddg|jƒ|jjddgƒ|jdddddg|jƒdS(s8Test extending repeated string fields with python lists.Rt11t22t33t44N(R"RâRSRT(R'R(R‚((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestExtendStringWithPythonList‘s cCsO|jƒ}|jg|jƒ|jjdƒ|jdddg|jƒdS(sDTest extending repeated string fields with characters from a string.tabcR„R†R…N(R"RâRSRT(R'R(R‚((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestExtendStringWithStringœs t TestIterablecBs5eZdZdd„Zd„Zd„Zd„ZRS(s�This 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|jdƒStdƒ‚dS(NiisTruth value is ambiguous.(R�RòRVtboolR¹(R'tsize((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyRQ­s   cCs t|jƒS(N(R�Rò(R'((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyt__len__µscCs |jjƒS(N(Ròt__iter__(R'((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyRø¸sN(RNROt__doc__RURôRQR÷Rø(((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyRñ£s    cCsý|jƒ}|jg|jƒ|jjtjgƒƒ|jg|jƒ|jjtjdgƒƒ|jdg|jƒ|jjtjddgƒƒ|jdddg|jƒ|jjtjddgƒƒ|jdddddg|jƒdS(s3Test extending repeated int32 fields with iterable.iiiiiN(R"RâR‡RTRRñ(R'R(R‚((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestExtendInt32WithIterable»s cCsý|jƒ}|jg|jƒ|jjtjgƒƒ|jg|jƒ|jjtjdgƒƒ|jdg|jƒ|jjtjddgƒƒ|jdddg|jƒ|jjtjddgƒƒ|jdddddg|jƒdS(s3Test extending repeated float fields with iterable.ggð?g@g@g@N(R"RâRbRTRRñ(R'R(R‚((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestExtendFloatWithIterableÈs cCsý|jƒ}|jg|jƒ|jjtjgƒƒ|jg|jƒ|jjtjdgƒƒ|jdg|jƒ|jjtjddgƒƒ|jdddg|jƒ|jjtjddgƒƒ|jdddddg|jƒdS(s4Test extending repeated string fields with iterable.Rt1t2t3t4N(R"RâRSRTRRñ(R'R(R‚((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestExtendStringWithIterableÕs cCsitjƒdks$tjƒdkr(dS|jƒ}|jtjƒ�}tj|jtj ƒWdQXdS(Ntcppi( R RtVersionR"R RYt PickleErrorRZR‡tHIGHEST_PROTOCOL(R'R(R‚R¨((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyt!testPickleRepeatedScalarContainerâs  cCs|jƒ}|jjƒdS(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'testSortEmptyRepeatedCompositeContainerðs cCs5|jƒ}|jtƒ�}|jdƒWdQXdS(sBUsing HasField on a repeated field should raise an exception. R‡N(R"R R¹R²(R'R(R‚R¨((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestHasFieldOnRepeatedFieldös cCsµ|jƒ}|jtƒ�}|jjƒWdQX|jjtdƒƒ|jd|jjƒƒ|jd|jjdƒƒ|jd|jjdƒƒ|jddg|jƒdS(Niiiiii(R"R t IndexErrorR‡tpopRTRßR0(R'R(R‚R¨((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestRepeatedScalarFieldPopýs cCs|jƒ}|jtƒ�}|jjƒWdQX|jtƒ�}|jjdƒWdQXx,tdƒD]}|jjƒ}||_qfW|j d|jjƒjƒ|j d|jjdƒjƒ|j d|jjdƒjƒ|j ddgg|jD]}|j^qûƒdS(NR=iiiiii( R"R RRR R@RßR€R~R0(R'R(R‚R¨RÝR˜((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestRepeatedCompositeFieldPops  cCs~|jƒ}x?tdƒD]1}|jj||ƒ|jjƒ}||_qW|j|j|jƒ|j|j|jƒdS(Ni( R"RßR‡tinsertRR€R~RâR0(R'R(R‚RÝR˜((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestRepeatedCompareWithSelfs  cCsM|jƒ}|jjƒ}|j}|jjƒ}|j|jjdƒdS(swA case that lead to a segfault when a message detached from its parent container has itself a child container. iN(R±trepeated_childR€RÍR0R°toptional_int32(R'R(R‚((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestReleasedNestedMessagess   cCs’|jƒ}|jtƒ�g|_WdQX|jjdƒtjƒdkro|jtƒ�g|_WdQXn|jtƒ�g|_WdQXdS(NiR(R"R tAttributeErrorR‡RˆR RR@(R'R(R‚((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestSetRepeatedComposite(s N(IRNROR+R7R<RKRXR^RdReRgRjRkRlRsRtRuRxR}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ÛRáRURVt bytearraytsetRãRåRæRçRèRéRîRðRWRñRúRûRRRRR R R RR(((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyRes„   $     - -     (     #      #         *      t Proto2TestcBsYeZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z RS( cCs\tjƒ}|j|jdƒƒ|j|jdƒƒ|j|jdƒƒ|jtƒ�|jdƒWdQX|jtƒ�|jdƒWdQX|jtƒ�|jdƒWdQX|jd|jƒ|jt|j ƒ|jd|j j ƒd|_t|_ d|j _ |j |jdƒƒ|j |jdƒƒ|j |jdƒƒd|_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_existR‡Riii(RR"RµR²R R¹R0RRVRRR~R_RFRÅ(R'R((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestFieldPresence:sD          cCs]tjƒ}|jtƒ�}d|_WdQX|jt|jjdƒ|jjdƒd|jd<|jtƒ�d|jdss%r does end with any of %rt.iÿÿÿÿtfromlist(R%ttypetsplitR_tanytjoint __import__(R'RHt base_namet valid_namestpartst class_namet module_name((RÅsI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pytassertImportFromNameýs  cCs6tjƒ}|j|jdƒ|j|jdƒdS(NtScalart Composite(RR"RÒR‡R(R'R™((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestTypeNamesCanBeImported s (RNRORÒRÕ(((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyRÂûs tPackedFieldTestcBs#eZd„Zd„Zd„ZRS(cCsä|jjdƒ|jjdƒ|jjdƒ|jjdƒ|jjdƒ|jjdƒ|jjdƒ|jjdƒ|j jdƒ|j jdƒ|j jdƒ|j jdƒ|j jtƒ|jjdƒdS(Nigð?(R‡Rˆtrepeated_int64trepeated_uint32trepeated_uint64trepeated_sint32trepeated_sint64trepeated_fixed32trepeated_fixed64trepeated_sfixed32trepeated_sfixed64RbRct repeated_boolRFRà(R'R((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyt setMessagescCs9tjƒ}|j|ƒd}|j||jƒƒdS(NsH "*2:BJRZ€?bð?jr(RR9RáR0R1(R'RR4((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestPackedFields"s  cCs9tjƒ}|j|ƒd}|j||jƒƒdS(Ns: (0=AMQ]€?að?hp(RtTestUnpackedTypesRáR0R1(R'RR4((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestUnpackedFields5s  (RNRORáRâRä(((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyRÖs  Riis;explicit tests of the C++ implementation for PY27 and abovetOversizeProtosTestcBs2eZed„ƒZd„Zd„Zd„ZRS(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(NR…ii@iiii(RítptfieldR°R1t p_serialized(R'((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pytsetUpqscCsmddlm}|tƒ|jƒ}y|j|jƒWn,tjk rh}|jt |ƒdƒnXdS(Niÿÿÿÿ(tSetAllowOversizeProtossError parsing message( tgoogle.protobuf.pyext._messageR÷RVRíR.RõRRCR0R%(R'R÷tqR¨((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestAssertOversizeProtovs  cCsYddlm}|tƒ|jƒ}|j|jƒ|j|jjj |jj ƒdS(Niÿÿÿÿ(R÷( RøR÷RFRíR.RõR0RóRôR°(R'R÷Rù((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyttestSucceedOversizeProtos   (RNROt classmethodRòRöRúRû(((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyRåIs#  t__main__(4Rùt __author__R«R2RmR’RYRÖRvRDt unittest2tunittestt ImportErrorR›RÞtgoogle.protobufRRRRRR R R tgoogle.protobuf.internalR R RRRRRtPY3tintRÙRRRRt BaseTestCasetNamedParametersRRRRRÂRÖtskipIfRRwRåRNtmain(((sI/usr/lib/python2.7/site-packages/google/protobuf/internal/message_test.pyt)st                   ÿÿÿÓðÿÿÕ9 :