Duac@stdZddlZddlZddlZddlZddlZyddlZWnek rqddlZnXddl m Z ddl m Z ddl m Z ddl m Z ddl mZddl mZdd l mZdd l mZdd lmZdd lmZdd lmZddlmZddlmZddlmZddlmZddlmZejZdefdYZdefdYZdefdYZdefdYZ defdYZ!defdYZ"defd YZ#d!efd"YZ$d#efd$YZ%d%efd&YZ&e'd'krpej(ndS((siUnittest for reflection.py, which also indirectly tests the output of the pure-Python protocol compiler. iN(tunittest_import_pb2(tunittest_mset_pb2(t unittest_pb2(tdescriptor_pb2(t descriptor(tmessage(t reflection(t text_format(tapi_implementation(tmore_extensions_pb2(tmore_messages_pb2(tmessage_set_extensions_pb2(t wire_format(t test_util(ttesting_refleaks(tdecodert _MiniDecodercBskeZdZdZdZeZeZeZeZdZ e Z dZ dZ dZ dZRS(sDecodes a stream of values from a string. Once upon a time we actually had a class called decoder.Decoder. Then we got rid of it during a redesign that made decoding much, much faster overall. But a couple tests in this file used it to check that the serialized form of a message was correct. So, this class implements just the methods that were used by said tests, so that we don't have to rewrite the tests. cCs||_d|_dS(Ni(t_bytest_pos(tselftbytes((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyt__init__Os cCs%tj|j|j\}|_|S(N(Rt _DecodeVarintRR(Rtresult((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyt ReadVarintSs!cCstj|jS(N(R t ZigZagDecodeR(R((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyt ReadSInt64\scCstj|jS(N(R t UnpackTagR(R((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pytReadFieldNumberAndWireTypeascCs=tjd|j|j|jd!d}|jd7_|S(Nsd=Z?d>Z@d?ZAd@ZBdAZCdBZDdCZEdDZFdEZGdFZHdGZIdHZJdIZKdJZLdKZMdLZNdMZOdNZPd[dOZRdPZSeTjUeVjWdQkp eVjXdRkdSdTZYdUZZdVZ[dWZ\dXZ]dYZ^dZZ_RS(\cCsU|jt|t|x2tt|D]}|j||||q/WdS(N(t assertEqualR!trange(Rtvaluestothersti((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pytassertListsEqualtsc Cswtjdddddddd}|jd|j|jd|j|jd|j|j|jddS(Ntoptional_int32itoptional_doubleg +)K@toptional_stringtoptional_float( Rt TestAllTypestNoneR,R2R3R4t assertFalsetHasField(Rtproto((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyttestScalarConstructorys  c Cstjdddddgdddgd tttgd d gd d}|jddddgt|j|jddgt|j|jtttgt|j |jd gt|j |jgt|j dS( Ntrepeated_int32iiiitrepeated_doublegGz?g +)K@t repeated_booltrepeated_stringR4trepeated_float( RR6tTruetFalseR7R,tlistR<R=R>R?R@(RR:((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyttestRepeatedScalarConstructors    %"c Cstjdtjjdtjjtjjdtjjgdtjddtjddtjddgdtjjtjjd d tjjd d g}|jtjjdtjjtjjdtjjgt|j |jtjddtjddtjddgt|j |jtjjtjjd d tjjd d gt|j dS( Ntrepeated_nested_messagetbbtrepeated_foreign_messagetcii i t repeatedgrouptaii( RR6t NestedMessagetFOOtBARtForeignMessaget RepeatedGroupR,RCRERGRI(RR:((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyt testRepeatedCompositeConstructors6         cCstjdddddddgdtttgdtjjd tjjtjjd tjjgd tjd d tjd d tjd dgdd}|j d|j |j d|j |j ddgt |j |j tttgt |j|j tjjd tjjtjjd tjjgt |j|j tjd d tjd d tjd dgt |j|j|jddS(NR2iR4R=gGz?g +)K@R>RERFRGRHii i toptional_nested_message(RR6RARBRKRLRMRNR7R,R2R4RCR=R>RERGR8R9(RR:((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyttestMixedConstructors:      "   cCs|jttjdd|jttjdd|jttjdd|jttjdd|jttjddg|jttjdd|jttjddg|jttjdd|jttjddgdS( NR2tfooR4iRQR<R?RE(t assertRaisest TypeErrorRR6(R((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyttestConstructorTypeErrors$cCstjdd}|jd|jtjdtjj}|jd|jtjddg}|jd|jtjdtjjg}|jd|jdS(NR2i iRQiR<RE(RR6R,tByteSizeRK(RR((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyt(testConstructorInvalidatesCachedByteSizes  cCstj}|j|jd |jd|j|j|jd d|_|j|jd|jd|j|jd dS(NR2ii(RR6t assertTrueR9R,R2t ClearField(RR:((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyttestSimpleHasBitss   csGfd}|dd|dd|dd|dd dS( Ncstj}t||}t||}jd|j|j| j|j| d}t|||j|t|||}j|j|j|j||j|t||}j|j| j|j| jdt||j||k t|||j|j| j|j| jdt||dS(Nii(RR6tgetattrR,RYR9tsetattrRZ(tcomposite_field_nametscalar_field_nameR:tcomposite_fieldtoriginal_scalar_valuetnew_valtold_composite_field(R(sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pytTestCompositeHasBits.s,  t optionalgroupRJRQRFtoptional_foreign_messageRHtoptional_import_messagetd((RRd((RsL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyt!testHasBitsWithSinglyNestedScalar s "*   cCs%tj}|j}~d|_dS(Ni(RR6RQRF(RR:tnested((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyttestReferencesToNestedMessage]s  cCsrtj}|j}|jd|j||jk d|_|j|jd |jd|jjdS(NRQii(RR6RQRZRYRFR9R,(RR:Rj((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyt0testDisconnectingNestedMessageBeforeSettingFieldes    cCsKtj}|j}|jd~~tjtj}|j}dS(NRQ(RR6RQRZtgctcollect(RR:Rj((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyt5testGetDefaultMessageAfterDisconnectingDefaultMessagens     cCstj}|j}d|_|j|jd|jd|jd|j|jd|jj|j||jk d|_|j|jd |jd|jjdS(NiRQii(RR6RQRFRYR9RZR,(RR:Rj((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyt/testDisconnectingNestedMessageAfterSettingField{s     cCsKtj}|j|jd |jd|j|jd dS(NRQ(RR6RYR9RZ(RR:((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyt0testDisconnectingNestedMessageBeforeGettingFields  cCsotj}tj}d|j_|j||j|jd|jd|j|jd dS(NiRQ(RR6RQRFt MergeFromRYR9RZ(Rtproto1tproto2((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyt(testDisconnectingNestedMessageAfterMerges     cCsLtjdkrdStj}d|j_|jd~tjdS(Ntpythonitoptional_lazy_message( RtTypeRR6RwRFRZRmRn(RR:((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyt"testDisconnectingLazyNestedMessages   cCstj}|jjjd|jdg|jj|j|jd|jd|j|jd |jj j |j|jddS(NiRQ( RtTestNestedMessageHasBitsRQtnestedmessage_repeated_int32tappendR,RYR9RZt%nestedmessage_repeated_foreignmessagetadd(RR:((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyt&testHasBitsWhenModifyingRepeatedFieldss  cCsqtj}|j|jd |jd|jjjjjj|j|jd d|jjjjj_|jd|jjjjjj|j|jd|j|jjd|j|jjjd|j|jjjjd|j|jjjjjd|j|jjjjjjd |j|jjjjjjddS(NRFiiRJR2(RtTestMutualRecursionARYR9R,RFRJR2(Rtrecursive_proto((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyt!testHasBitsForManyLevelsOfNestings """&cCstj}d|_d|_d|_|j}|j|jjddf|jjddf|jjddfg|j d|j_ |j|jjddf|jjddf|jjddf|jjd|fg|j dS( NiiRSR2toptional_fixed32R4i{RQ( RR6RR2R4RQR,t DESCRIPTORtfields_by_namet ListFieldsRF(RR:tnested_message((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyttestSingularListFieldss$         c Cs tj}|jjd|jjd|jjd|jjddg|jjg|jjd|jjdtdDd |_|j |j |j j d d f|j j d ddgf|j j d dgf|j j d dddddgfg|j dS(Niii RStbartbazcss|]}t|VqdS(N(tstr(t.0tx((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pys siiR2R<trepeated_fixed32R?t0t1(RR6RR|R<R?textendR-R2R>R,RRR(RR:((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyttestRepeatedListFieldss"    cCsztj}d|jtjQR(RtTestRequiredForeignR-RR~tCopyFromRTt IndexError(RR0Rt((R:sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyttestClearRemovesChildrenHs    cCstj}|jtt|dd|jtt|ddg|jtt|dd|jtt|jdd|jtt|jdd|jtt|dddS( NR<i RQiRFi"tsome_attributeR(RR6RTtAttributeErrorR]RER@(RR:((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyttestDisallowedAssignmentsSs    cCstj}|jtt|dd|jtt|dd|jtt|dd|jtt|dd|jtt|dd|jtt|dd|jtt|d dtjd kr|jtt|ddn d|_dS( NR2g?RSR4i RRR5R3Rv(RR6RTRUR]RRxR(RR:((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyttestSingleScalarTypeSafetyhs csfd}|ddt|dd t|ddty t}Wntk ret}nXtjddkr|dd|n|ddt|d d||d d||d d||d d|d S(s}Verifies setting of scalar integers. Args: integer_fn: A function to wrap the integers that will be assigned. cs}tj}|}t|||jt|||tj}|j|jjt|||dS(N(RR6R]tassertIsInstanceR\tParseFromStringtSerializeToString(t field_nametvaluet expected_typeR:Rt(t integer_fnR(sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pytTestGetAndDeserialize}s   R2iiRtLiiRi<RNi@i@lli@li@l(tinttlongt NameErrorRtcalcsize(RRRt integer_64((RRsL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pytassertIntegerTypesws    cCs|jddS(NcSs|S(N((R((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyRR(R(R((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyttestIntegerTypesscCs|jtjdS(N(RR tNonStandardInteger(R((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyttestNonStandardIntegerTypesscCs]tj}|jtd|_WdQX|jtdtjdd|_WdQXdS(Nt2tmy_errori( RR6RTRURtassertRaisesRegexpt RuntimeErrorR R(Rtpb((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyttestIllegalValuesForIntegerss  csfd}|ddd|ddd|ddd|d dd tj}jttfd|_Wd QXtj}d|_jd|jd S(sVerifies bounds checking for scalar integer fields. Args: integer_fn: A function to wrap the integers that will be assigned. cstj}|}|}t|||j|t||t|||j|t||jttft|||djttft|||ddS(Ni(RR6R]R,R\RTRRU(Rt expected_mint expected_maxR(RR(sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pytTestMinAndMaxIntegerss    R2iiRilRi?RlNllllllllll(RR6RTRRURtoptional_nested_enumR,(RRRR((RRsL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pytassetIntegerBoundsCheckings   cCs|jddS(NcSs|S(N((R((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyRR(R(R((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyttestSingleScalarBoundsCheckingscCs|jtjdS(N(RR R(R((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyt)testNonStandardSingleScalarBoundsCheckingscCs'tj}|jt|jjd|jt|jjd|jt|jd|jt|jd|jjdd|jd<|jt|jj dd|jt|jj dd|jt|jj dg|jt|jj dd|jjd |jt|jj dddS( Ng?RSi iiitabctindexR( RR6RTRUR<R|R?trepeated_bytesRt __setitem__(RR:((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyttestRepeatedScalarTypeSafetys   cCswtj}|jd|jd|_|jd|jd|_|jd|jd|_|jd|jdS(Niill(RR6R,R2R(RR:((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyt!testSingleScalarGettersAndSetterss    cCsstj}|jdd|_|j|jd|jd|jd|j|j|jd dS(NR2ii(RR6RZR2RYR9R,(RR:((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyttestSingleScalarClearFields    cCstj}|jd|j|jdtjj|jd|j|jdtjj|jd|j|jdtjjdS(Niii(RR6R,RLRMtBAZ(RR:((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyt testEnumss cCs~|jdtjjtj|jdtjjtj|jdtjjtj|jttjjdtj }|jd|j j|j |jdtj j j|j |jd|j j|j |jdtj j j|j |jd|j j|j |jdtj j j|j |jt|j jd|jttj j jddS(Nt FOREIGN_FOORt FOREIGN_BAZi0,RLRMR(R,Rt ForeignEnumtNameRRRRTRR6t NestedEnumRLRMR(RR:((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyt testEnum_Names2             cCs~|jtjtjjd|jtjtjjd|jtjtjjd|jttjjdtj }|j|j |j jd|j|j tj j jd|j|j |j jd|j|j tj j jd|j|j |j jd|j|j tj j jd|jt|j jd|jttj j jddS( NRRRtFORLRMRtFoo(R,RRRtValueRRRTRR6RLRRMR(RR:((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyttestEnum_Value"s2             cCs |jdddgttjj|jdddgttjj|jdddgttjjtj}|jddd d gt|jj|jd d d dgt|jj|jddddgt|jjdS(NRRRiiiRLRMRtNEGiiii(Ri(Ri(Ri(RLi(RMi(Ri(R i( R,RCRRtkeysR.titemsR6R(RR:((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyttestEnum_KeysAndValues>s  ++cCstj}|j|j |jdt|j|jjd|jjd|jjd|j|j|jdt|j|jdddg|j|jd|jd|jd|jd|jt|jj d|jt|jj d|jt |jj d |jt |jj dd |jd <|jdd dg|j|jj d d |jdd d dg|j|jjd |jd d dg|jd d!|jdd d dd g|jdt dD|jd d+|jddd dd g|jdddg|jd d+|jddddd g|jg}x|jD]}|j|q{W|jddddd g||jd=|jdddd g|j|jd3|jddg|j|jjddg|jddddg|j|jd|j|j |jdt|j|jjd |jd |jdd|jd<|jd|jddd ddg|j(|jd=|jdd dg|j|jd=|jddg|j|jt|jjd|jt|jjd|jdd5|jdg|j|jdd5|jdg|jdS(Niii iiiii.RSiiiiicss|] }|VqdS(N((RR0((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pys rsii#i(i-i R<iii,idi'(RR6RYR<R,R!R|RTRt __getitem__RUR7tinsertR-RRZt __delitem__(RR:RR0((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyttestRepeatedScalarsMsl  ## ""        cCstj}|j|j |jdt|j|jjd|jjd|jjd|jjd|jdt|j|jjd|jdt|j|jd|jd|jd|jd|jd|jd|jjd|jdt|j|jd|jd|jd|jd|jjd|jdt|j|jd|jd|jt |jjddS( Niii iiiii{( RR6RYR<R,R!R|tremoveRTR(RR:((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyttestRepeatedScalarsRemoves* c Cs$tj}|j|j |jdt|j|jj}|jj}|j|j|jdt|j|j||g|j|j|tjj |j t |jj d|j t |jj d|j t |jj d|j t |jj d|jj}|jj}|jj}|j|||g|jdd!|j|||||g|j|j||g|jd |j|||g|jd|j||jd|j|g|jd g}x|jD]}|j|qW|j|||||g||jd=|j||||g|j|jd3|j||g|jtjj dd} tjj dd} |jj| | g|jdt|j|j| |jd|j| |jd |j t |jj| |j t |jjdgtj} |j t |jj| g|jd |j|j |jdt|j|jjdd |jdt|j|jd |jdj|j t |jjd |j td |jdRR?RJRARKRLRMRRt ParseMessageR,(Rt desc_prototfdpRGRNRPtserialized_priust new_prius((RHROsL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyttestDescriptorProtoSupportQsN       .      cCstj}tj}|j|j| |jd|j||j|j| d|j|<|jd|j||j|j||j||jd|j||j|j| dS(Nii(RRRRYt HasExtensionR,RtClearExtension(Rtextendee_protot extension((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyt'testTopLevelExtensionsForOptionalScalars    cCstj}tj}|jdt|j||j|jd|jdg|j||j|}|j||jdt|j||j||j|k |j t t j |j|ddS(NiRSRJ( RRRR,R!RR|R`RYRTRUtoperatortsetitem(RRaRbt string_list((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyt'testTopLevelExtensionsForRepeatedScalars    cCs=tj}tj}|j|j| |jd|j|j|j|j| d|j|_|jd|j|j|j|j||j|}|j||j||j|k d|_|jd|j|j|j d|j|j| |j t t j |j|ddS(Niii*RHRJ(RRt"optional_foreign_message_extensionRYR_R,RRHR`R9RTRURdRe(RRaRbtforeign_message((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyt(testTopLevelExtensionsForOptionalMessages"     cCstj}tj}|jdt|j||j|j}d|_|jd|j|djd|_|jd|j|dj|j|}|j||jdt|j||j ||j|k |j t t j |j|ddS(Niii*RJ(RRtrepeatedgroup_extensionR,R!RR~RJR`RYRTRURdRe(RRaRbtgroupt group_list((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyt(testTopLevelExtensionsForRepeatedMessages      cCstj}tjj}|j|j| |j|}|jd|j|j|j| d|_|jd|j|j|j|j||j ||j||j|k |j|j| dS(Nii( RRt TestRequiredtsingleRYR_RR,RJR`(RRaRbtrequired((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyttestNestedExtensionss     cCsvtjj}|j|jtjjd|j|jdjtjj|j dt |j tj jdS(Nis*protobuf_unittest.optional_int32_extensioni( RRtpoolRYtFindExtensionByNumberRtassertIstFindExtensionByNameR&R,R!tFindAllExtensionsR6(RRs((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyttestRegisteredExtensionss    cCstj}|j|jd |jd|jjtj|j|jd d|jjtj<|jd|jjtj|j|jdtj}|j|jd |jg|jjtj|j|jd |jjtjj d|jdg|jjtj|j|jdtj}|j|jd |jd|jjtj j |j|jd d|jjtj _ |jd|jjtj j |j|jdtj}|j|jd |jdt |jjtj |j|jd |jjtj j}|j||jjtj d|j|jddS(Nt submessageii(R tTopLevelMessageRYR9R,RyRtoptional_int_extensiontrepeated_int_extensionR|toptional_message_extensiontforeign_message_intR!trepeated_message_extensionR~(Rttopleveltforeign((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyt(testHasBitsForAncestorsOfExtendedMessagesL          cCs_tj}|j}tj}|j|}|j|d|_|j||j|k dS(Ni(R RzRyR}RR`R~RY(RRRaRbtextension_proto((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyt*testDisconnectionAfterClearingEmptyMessage*s      cCstj}|jt|jd|jt|jd|jt|jjd|jt|jjddxt j t j t j t j fD]g}|jt|j||jt|j||jt|jj||jt|jj|dqW|jt|jtjdS(Nii(RRRTtKeyErrorR_R`RR RR R{R}R|RR(RRatunknown_handle((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyttestExtensionFailureModes4s&  cCsKtj}tj||j}tjj|}|j||dS(N(RR6R t SetAllFieldsRt FromStringR,(RRststring1Rt((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyttestStaticParseFromSs    cCsatj}d|_tj}d|_|j||jd|j|jd|jdS(NiR(RR6R2R4RrR,(RRsRt((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyttestMergeFromSingularField]s     cCstj}|jjd|jjdtj}|jjd|j||jd|jd|jd|jd|jd|jddS(Niii(RR6R<R|RrR,(RRsRt((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyttestMergeFromRepeatedFieldjs   cCsKtj}d|j_tj}|j||jd|jjdS(Ni (RR6ReRJRrR,(RRsRt((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyttestMergeFromOptionalGroupxs     cCs,tj}|jj}d|_|jj}d|_tj}|jj}d|_|j||jd|jdj|jd|jdj|jd|jdjtj}|jj|j|jd|jdj|jd|jdj|jd|jdjdS(Ni{iAiiii(RR6RER~RFRrR,(RRstmRttproto3((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyt"testMergeFromRepeatedNestedMessages"       cCsntj}tj|tj}|j||j|||j}|j}|j||dS(N(RR6R RRrR,R(RRsRtRtstring2((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyttestMergeFromAllFieldss      cCsStj}d|jtjd|qNW|dd|d d|d ddS( Ncs7jj|j_j|djdS(Ni(R:RRR,R(R0texpected_varint_size(R(sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pytTest#s  iiii?i'ii ill(tzipR-(RRR0t num_bytes((RsL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyt testVarints"s  1  cCsd|j_|jd|jd|j_|jdt|jj|jdd|j_|jdt|jj|jdS(NRiRRii(R:R4R,RR!(R((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyt testStrings1s   &cCsd|j_|jd|jtj|_d|j_|jd|jtj|_d|j_|jd|jtj|_d|j_|jd|jtj|_d|j_ |jd|jtj|_dS(Niii gX9v?i@i( R:RR,RRR6RR5R3R(R((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyttestOtherNumerics>s     cCs)d|jj_|jd|jdS( Niiiii@iii(R:RQRFR,R(R((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyttestCompositesXscCs-d|jj_|jdd|jdS(Niiiii ii(R:ReRJR,R(R((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyt testGroups`scCsD|jjjd|jjjd|jdd|jdS(Ni iiiii(R:R<R|R,R(R((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyRgscCs7|jjjddg|jdd|jdS(Ni iiiii(R:R<RR,R(R((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyttestRepeatedScalarsExtendmscCsm|jjjd|jjjd|jdd|j|jjjd|jd|jdS(Ni iiiiii(R:R<R|R,RR(R((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyRrs cCsG|jjj}|jjj}d|_|jd|jdS( Niiiiiiii(R:RER~RFR,R(Rtforeign_message_0tforeign_message_1((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyRzs cCss|jjj}|jjj}d|_|jd |jtj|jj}|jjd=|jd|j|jjj}d|_|jd|j|jjd=|jd|j|jjd=|jd|j|jdt||dd5t j dkr=|jdt|n|d=t j dkro|jdt|ndS(Ni iiii Rviiiiiiiiiiiiiii i iii( R:RER~RFR,RRRR!RRx(RR'R(REtforeign_message_2((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyttestRepeatedCompositesDeletes,      cCsG|jjj}|jjj}d|_|jd|jdS( Niiiiiii i (R:RIR~RJR,R(Rtgroup_0tgroup_1((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyttestRepeatedGroupss cCstj}|jd|jtj}d|j|<|jd|jtjjjd}|j t d|j|D s8      6 )  3 !       t OptionsTestcBseZdZdZRS(cCsTtj}|jt|jjjtj}|jt |jjjdS(N( R RR,RARRYRZRR6RB(RR:((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyttestMessageOptionsw s     cCstj}d|_d|_x3|jD]%\}}|jt|jjq+Wtj }|j j d|j j dxL|jD]>\}}|jt |jj|jtjj|jqWdS(Nig@(RR6R2R3RR,RBRYRyRR7R|R8RARR5RWR$(RR:tfield_descriptort_((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyttestPackedOptions s    (R#R$RR(((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyRu s t ClassAPITestcBseZejejdko-ejdkddZdZe j ddZ e j ddZ e j ddZ RS( Ris6C++ implementation requires a call to MakeDescriptor()cCs$tjddddddgdgdgdg}tjd d ddddgd|gdgdg}tjd d ddddgdgdgdg}tjd dddddgd||gdgdg}tj|}|jd |j|jd |j|jd|jjdS(Ntleafspackage.parent.child.leafRR&R1R/R0R2R2spackage.parent.childtsiblingspackage.parent.siblingtparentspackage.parent(RR:R7Rt MakeClassRt__dict__R2(Rt leaf_desct child_desct sibling_desct parent_desct message_class((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyt!testMakeClassWithNestedDescriptor s(          cCs4d|d}tj}tj|||jS(s Get a serialized representation of a test FileDescriptorProto. Args: name: All calls to this must use a unique message name, to avoid collisions in the cpp descriptor pool. Returns: A string containing the serialized form of a test FileDescriptorProto. smessage_type { name: "si" field { name: "flat" number: 1 label: LABEL_REPEATED type: TYPE_UINT32 } field { name: "bar" number: 2 label: LABEL_OPTIONAL type: TYPE_MESSAGE type_name: "Bar" } nested_type { name: "Bar" field { name: "baz" number: 3 label: LABEL_OPTIONAL type: TYPE_MESSAGE type_name: "Baz" } nested_type { name: "Baz" enum_type { name: "deep_enum" value { name: "VALUE_A" number: 0 } } field { name: "deep" number: 4 label: LABEL_OPTIONAL type: TYPE_UINT32 } } }}(RRRtMergeR(RRtfile_descriptor_strtfile_descriptor((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyt_GetSerializedFileDescriptor s ) s MakeDescriptor is not repeatablecstjdkrdStj}|j|jdtj|jddt j t j t jffdY}|}d}tj|||j|jddd gdS( s7Test that the generated class can parse a flat message.RvNtAit MessageClasscseZZRS((R#R$R((tmsg_descriptor(sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyR ssflat: 0 flat: 1 flat: 2 ii(RRxRRRRRRXR'R<R=RR>RR?RRR,tflat(RRRRtmsg_str((RsL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyt0testParsingFlatClassWithExplicitClassDeclaration s  . cCstj}|j|jdtj|jd}tj|}|}d}t j |||j |j dddgdS(s7Test that the generated class can parse a flat message.tBisflat: 0 flat: 1 flat: 2 iiN( RRRRRRXR'RRRRR,R(RRRt msg_classRR((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyttestParsingFlatClass s  cCstj}|j|jdtj|jd}tj|}|}d}t j |||j |j j jddS(s9Test that the generated class can parse a nested message.tCisbar { baz { deep: 4 }}iN(RRRRRRXR'RRRRR,RRtdeep(RRRRRR((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyttestParsingNestedClass s  (R#R$RRRRxRRRRtSkipReferenceLeakCheckerRRR(((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyR s! 8t__main__()R%RRmRdR<Rt unittest2Rt ImportErrortgoogle.protobufRRRRRRRRRRR R R R R RRt BaseTestCasetobjectRR+RRRRRR>RRR#tmain(((sL/usr/lib/python2.7/site-packages/google/protobuf/internal/reflection_test.pyt#s`       -V! 93