3 SÉLj{ªã@sädZdZddlZddlZy ddlZWnek r@ddlZYnXddlmZddlm Z ddlm Z ddlm Z ddl m Z dd l mZdd l mZdd l mZdd l mZdd l mZddl mZddlmZddlmZddlmZddlmZddlmZGdd„deƒZGdd„deejƒZGdd„deejƒZGdd„deejƒZGdd„deƒZGdd„deƒZ Gd d!„d!eƒZ!Gd"d#„d#eƒZ"Gd$d%„d%eƒZ#Gd&d'„d'eƒZ$Gd(d)„d)eƒZ%Gd*d+„d+ejƒZ&ed,d-e!e dmdngƒe!e dodpgƒe!d6e dqdrgƒid;e"d/d6d7ƒfdœd;e"d/d6d4ƒfdœd;e"d/d6dKƒfdœd;e"d/d6d^ƒfdgoogle.protobuf.python.internal.Factory2Message.one_more_fieldzprotobuf_unittest.TestServicezgoogle/protobuf/unittest.proto) rÚFindFileContainingSymbolrr rrrrrr)rrr Z file_desc3Z file_desc4Z file_desc5r!r!r"ÚtestFindFileContainingSymbolTs:z3DescriptorPoolTestBase.testFindFileContainingSymbolc Cs&|jtƒ�|jjdƒWdQRXdS)NzDoes not exist)r$r%rr')rr!r!r"Ú#testFindFileContainingSymbolFailureys z:DescriptorPoolTestBase.testFindFileContainingSymbolFailurec Csø|jjdƒ}|j|tjƒ|jd|jƒ|jd|jƒ|jd|jƒ|j |j ƒ|j d}|jd|jƒ|j||jƒ|j d}|jd|jƒ|j||jƒ|j||j djƒ|j||j djƒ|jjdƒ}|j|tjƒ|jd |jƒ|jd|jƒ|j|jƒ|j d}|jd |jƒ|j||jƒ|j d}|jd |jƒ|j||jƒ|j||j d jƒ|j||j d jƒ|j|j djƒ|jd|j djƒ|j|j djƒ|jd|j djƒ|j|j djƒ|jd|j djƒ|j|j djƒ|j |j djƒ|j|j djƒ|jd|j djƒ|jjdƒ}|j||ƒ|j|j djƒ|jd|j djƒ|jdt|jƒƒ|jdt|jƒƒ|jdt|jdjƒƒxBdD]:}|j|jd|j |jƒ|j|j ||jdjƒ�q¶WdS)Nz/google.protobuf.python.internal.Factory1MessagerrZNestedFactory1MessageZNestedFactory1EnumZnested_factory_1_messageZnested_factory_1_enumz/google.protobuf.python.internal.Factory2MessagerZNestedFactory2MessageZNestedFactory2EnumZnested_factory_2_messageZnested_factory_2_enumZint_with_defaultiðZdouble_with_defaultg{®Gáú#@Zstring_with_defaultz hello worldZbool_with_defaultZenum_with_defaultézEgoogle.protobuf.python.internal.Factory2Message.NestedFactory2MessageZbytes_with_defaultsaûcéÚ oneof_intÚ oneof_string)r,r-)rÚFindMessageTypeByNamerr Z DescriptorrrÚ full_nameÚcontaining_typeÚ assertFalseÚ has_optionsZ nested_typesZ enum_typesÚfields_by_nameÚ message_typeÚ enum_typeZ assertIsNoneÚ assertTrueÚhas_default_valueÚ default_valueÚlenZoneofsÚoneofs_by_nameZfieldsZcontaining_oneofr) rZmsg1Z nested_msg1Ú nested_enum1Zmsg2Z nested_msg2Ú nested_enum2Zmsg3rr!r!r"ÚtestFindMessageTypeByName}s‚                 z0DescriptorPoolTestBase.testFindMessageTypeByNamecCsð|jt|jjdƒtjƒdkrH|jt|jjdƒ|jt|jjdƒt}nt}|j||jj dƒ|j||jj dƒ|j||jj dƒ|j||jj dƒ|j||jj dƒ|j||jjdƒ|j||jjdƒtjƒdkrÚt}|j||jjdƒdS)NÚÚcpprÚpython)r$Ú TypeErrorrÚFindExtensionByNumberrÚTypeZFindMethodByNamer%ÚAttributeErrorr.ÚFindFieldByNameÚFindExtensionByNameÚFindEnumTypeByNameÚFindOneofByNameÚFindServiceByNamer'r)rZ error_typer!r!r"ÚtestFindTypeErrorsÏs   z)DescriptorPoolTestBase.testFindTypeErrorsc Cs&|jtƒ�|jjdƒWdQRXdS)NzDoes not exist)r$r%rr.)rr!r!r"Ú testFindMessageTypeByNameFailureäs z7DescriptorPoolTestBase.testFindMessageTypeByNameFailurecCs|jjdƒ}|j|tjƒ|jd|jdjƒ|jd|jdjƒ|j|j ƒ|jjdƒ}|j|tjƒ|jd|jdjƒ|jd|jdjƒ|jjd ƒ}|j|tjƒ|jd|jd jƒ|jd|jd jƒ|jjd ƒ}|j|tjƒ|jd|jd jƒ|jd|jdjƒdS)Nz,google.protobuf.python.internal.Factory1EnumrZFACTORY_1_VALUE_0r*ZFACTORY_1_VALUE_1zBgoogle.protobuf.python.internal.Factory1Message.NestedFactory1EnumZNESTED_FACTORY_1_VALUE_0ZNESTED_FACTORY_1_VALUE_1z,google.protobuf.python.internal.Factory2EnumZFACTORY_2_VALUE_0ZFACTORY_2_VALUE_1zBgoogle.protobuf.python.internal.Factory2Message.NestedFactory2EnumZNESTED_FACTORY_2_VALUE_0ZNESTED_FACTORY_2_VALUE_1) rrGrr ZEnumDescriptorrÚvalues_by_nameÚnumberr1r2)rZenum1r;Zenum2r<r!r!r"ÚtestFindEnumTypeByNameès2 z-DescriptorPoolTestBase.testFindEnumTypeByNamec Cs&|jtƒ�|jjdƒWdQRXdS)NzDoes not exist)r$r%rrG)rr!r!r"ÚtestFindEnumTypeByNameFailures z4DescriptorPoolTestBase.testFindEnumTypeByNameFailurec Csvt|tƒrtjƒdkrdS|jjdƒ}|j|jdƒ|j|j|j ƒ|j |j ƒ|j t ƒ�|jjdƒWdQRXdS)Nr?z:google.protobuf.python.internal.Factory1Message.list_valueZ list_valuezDoes not exist)Ú isinstanceÚ#SecondaryDescriptorFromDescriptorDBrrCrrErrÚlabelZLABEL_REPEATEDr1r2r$r%)rÚfieldr!r!r"ÚtestFindFieldByName s    z*DescriptorPoolTestBase.testFindFieldByNamec CsZt|tƒrtjƒdkrdS|jjdƒ}|j|jdƒ|jt ƒ�|jjdƒWdQRXdS)Nr?z;google.protobuf.python.internal.Factory2Message.oneof_fieldÚ oneof_fieldzDoes not exist) rPrQrrCrrHrrr$r%)rZoneofr!r!r"ÚtestFindOneofByNames   z*DescriptorPoolTestBase.testFindOneofByNamec Cs‚t|tƒrtjƒdkrdS|jjdƒ}|j|jdƒ|jjdƒ}|j|jdƒ|j|jdƒ|j t ƒ�|jj dƒWdQRXdS)Nr?z>google.protobuf.python.internal.Factory2Message.one_more_fieldÚone_more_fieldz-google.protobuf.python.internal.another_fieldÚ another_fieldiêzDoes not exist) rPrQrrCrrFrrrMr$r%rE)rÚ extensionr!r!r"ÚtestFindExtensionByName%s   z.DescriptorPoolTestBase.testFindExtensionByNamecCs¢|jjdƒ}|jjdƒ}|jd}|jj|ƒ|jjdƒ}|jd}|jj|ƒ|jj|ƒ}t||gƒ}|j|t|ƒƒ|jdƒ|jj|ƒ}|j|t|ƒƒdS)Nz/google.protobuf.python.internal.Factory1Messagez/google.protobuf.python.internal.Factory2MessagerWz,google/protobuf/internal/factory_test2.protorXZunexpected_element) rr.Úextensions_by_nameÚAddExtensionDescriptorrZFindAllExtensionsÚsetrÚappend)rÚfactory1_messageÚfactory2_messagerWÚ factory_test2rXÚ extensionsZexpected_extension_numbersr!r!r"ÚtestFindAllExtensions7s         z,DescriptorPoolTestBase.testFindAllExtensionsc Cs°|jjdƒ}|jjdƒ}|jd}|jj|ƒ|jjdƒ}|jd}|jj|ƒ|jj|dƒ}|j|jdƒ|jj|dƒ}|j|jdƒ|jt ƒ�|jj|dƒ}WdQRXdS) Nz/google.protobuf.python.internal.Factory1Messagez/google.protobuf.python.internal.Factory2MessagerWz,google/protobuf/internal/factory_test2.protorXiéiêi‡Ö) rr.r[r\rrBrrr$r%)rr_r`rWrarXrYr!r!r"ÚtestFindExtensionByNumberOs      z0DescriptorPoolTestBase.testFindExtensionByNumbercCsj|jtƒ�|jjdƒWdQRX|jtƒ�|jjdƒWdQRX|jtƒ�|jjdƒWdQRXdS)Nz-google.protobuf.python.internal.another_fieldz>google.protobuf.python.internal.Factory2Message.one_more_fieldz:google.protobuf.python.internal.Factory1Message.list_value)r$r%rrErF)rr!r!r"ÚtestExtensionsAreNotFieldsfs   z1DescriptorPoolTestBase.testExtensionsAreNotFieldsc Cs@|jjdƒ}|j|jdƒ|jtƒ�|jjdƒWdQRXdS)Nzprotobuf_unittest.TestServicezDoes not exist)rrIrr/r$r%)rÚservicer!r!r"ÚtestFindServiceps  z&DescriptorPoolTestBase.testFindServicecCs8tjƒ}tj|ƒ|_|j|jƒ|j|jƒ|jƒdS)N) rÚDescriptorDatabaserÚDescriptorPoolrÚAddÚfactory_test1_fdÚfactory_test2_fdr=)rÚdbr!r!r"ÚtestUserDefinedDBvs    z(DescriptorPoolTestBase.testUserDefinedDBcCsTt|tƒrtjƒdkrdStjƒ|_|jj|jj ƒƒ|jj|j j ƒƒ|j ƒdS)Nr?) rPrQrrCrrirÚAddSerializedFilerkÚSerializeToStringrlr=)rr!r!r"ÚtestAddSerializedFile}s   z,DescriptorPoolTestBase.testAddSerializedFilecsЇfdd„}|tjƒtjƒjjdƒ}ˆj|tjƒ||ƒtˆtƒrVt j ƒdkrVdSt j j tjjƒ}ˆjj|ƒˆjjdƒ}||ƒdS)z:Test the default value of enums which don't start at zero.cs&|jdjdj}ˆj|tjjƒdS)NÚDescriptorPoolTest1Ú nested_enum)rr3r8rrrrÚBETA)Úfile_descriptorr8)rr!r"Ú_CheckDefaultValueŒs zGDescriptorPoolTestBase.testEnumDefaultValue.._CheckDefaultValuez4google/protobuf/internal/descriptor_pool_test1.protor?N)rÚ DESCRIPTORrÚDefaultrrÚassertIsrPrQrrCrÚFileDescriptorProtoÚ FromStringÚ serialized_pbrj)rrvruZdescriptor_protor!)rr"ÚtestEnumDefaultValueŠs       z+DescriptorPoolTestBase.testEnumDefaultValuecs˜‡fdd„‰‡fdd„}|tjƒƒtjƒ}|jtjjtj j ƒƒ|jtjjt j j ƒƒ|jtjjtj j ƒƒt j |ƒj|jtjj jƒƒ}||ƒƒdS)z0Check the value returned by non-existent fields.csˆj||ƒˆj||ƒdS)N)rr)ÚvalueZexpected_valueZ expected_type)rr!r"Ú_CheckValueAndType¬s zTDescriptorPoolTestBase.testDefaultValueForCustomMessages.._CheckValueAndTypecsÆyt}Wntk r t}YnXyt}Wntk rBt}YnXˆ|jdtƒˆ|jd|tfƒˆ|jdttfƒˆ|j dttfƒˆ|j dt ƒˆ|j d|ƒˆ|j dtƒˆ|j|jtƒdS)NrFr>ó)ZlongÚ NameErrorÚintZunicodeÚstrÚoptional_int32Zoptional_uint64Zoptional_floatÚfloatZoptional_doubleZ optional_boolÚboolZoptional_stringZoptional_bytesÚbytesZoptional_nested_enumZFOO)ÚmsgZint64Z unicode_type)rr!r"Ú_CheckDefaultValues°s   zUDescriptorPoolTestBase.testDefaultValueForCustomMessages.._CheckDefaultValuesN)rÚ TestAllTypesrrirjrrzr{rrwr|rrZMessageFactoryZ GetPrototyper.r/)rr‰rZ message_classr!)rrr"Ú!testDefaultValueForCustomMessagesªs          z8DescriptorPoolTestBase.testDefaultValueForCustomMessagescCsFt|tƒrtjƒdkrdStjdd�}|jj|ƒ|jj|j ƒƒdS)Nr?zsome/file.proto)r) rPrQrrCrrzrrjrorp)rÚ file_descr!r!r"ÚtestAddFileDescriptorÐs     z,DescriptorPoolTestBase.testAddFileDescriptorcCsŽt|tƒrtjƒdkrdStjjtjj ƒ}tjjt jj ƒ}tjjt jj ƒ}|j j |ƒ|j j |ƒ|j j |ƒtj||j ƒtj||j ƒdS)Nr?)rPrQrrCrrzr{r rwr|rrrrjÚ TEST1_FILEÚ CheckFileÚ TEST2_FILE)rZmore_messages_descZ test1_descZ test2_descr!r!r"ÚtestComplexNestingÛs        z)DescriptorPoolTestBase.testComplexNestingN)Ú__name__Ú __module__Ú __qualname__r#r&r(r)r=rJrKrNrOrTrVrZrcrdrergrnrqr}r‹r�r‘r!r!r!r"r?s,%R    & rc@seZdZdd„Zdd„ZdS)ÚDefaultDescriptorPoolTestcCs2tjƒ|_tjjtjjƒ|_ tjjt jjƒ|_ dS)N) rrxrrrzr{r rwr|rkr rl)rr!r!r"ÚsetUpñs   zDefaultDescriptorPoolTest.setUpcCs¾|j|jjdƒtjƒ|j|jjdƒtjjƒ|j|jjdƒtjjjdƒ|j|jj dƒtj jƒ|j|jj dƒtjj dƒ|j|jj dƒtjjjd ƒ|j|jjd ƒtjjd ƒdS) Nzgoogle/protobuf/unittest.protozprotobuf_unittest.TestAllTypesz-protobuf_unittest.TestAllTypes.optional_int32r„zprotobuf_unittest.ForeignEnumz*protobuf_unittest.optional_int32_extensionZoptional_int32_extensionz*protobuf_unittest.TestAllTypes.oneof_fieldrUzprotobuf_unittest.TestServiceZ TestService)ryrrrrwr.rŠrEr3rGÚ ForeignEnumrFr[rHr:rIZservices_by_name)rr!r!r"ÚtestFindMethodsøs.       z)DefaultDescriptorPoolTest.testFindMethodsN)r’r“r”r–r˜r!r!r!r"r•ïsr•c@seZdZdd„ZdS)ÚCreateDescriptorPoolTestcCs–tjƒ|_tjjtjjƒ|_ tjjt jjƒ|_ |jj |j ƒ|jj |j ƒ|jj tjjt jjƒƒ|jj tjjtjjƒƒ|jj tjjtjjƒƒdS)N)rrirrrzr{r rwr|rkr rlrjrrr)rr!r!r"r–s        zCreateDescriptorPoolTest.setUpN)r’r“r”r–r!r!r!r"r™sr™c@seZdZdd„ZdS)rQcCs˜tjjtjjƒ|_tjjtjjƒ|_t j ƒ}|j |jƒ|j |jƒ|j tjjt jjƒƒ|j tjjt jjƒƒ|j tjjtjjƒƒtj|d�|_dS)N)Z descriptor_db)rrzr{r rwr|rkr rlrrhrjrrrrrir)rrmr!r!r"r–(s          z)SecondaryDescriptorFromDescriptorDB.setUpN)r’r“r”r–r!r!r!r"rQ%srQc@seZdZddd„Zdd„ZdS)Ú ProtoFileNcCs*||_||_||_|pg|_|p"g|_dS)N)rrÚmessagesÚ dependenciesÚpublic_dependencies)rrrr›rœr�r!r!r"Ú__init__;s  zProtoFile.__init__cCs”|j|jƒ}|j|j|jƒ|j|j|jƒdd„|jDƒ}|j|j|ƒdd„|jDƒ}|j|j|ƒx&|jjƒD]\}}|j|d||ƒqtWdS)NcSsg|] }|j‘qSr!)r)Ú.0Úfr!r!r"ú Gsz'ProtoFile.CheckFile..cSsg|] }|j‘qSr!)r)rŸr r!r!r"r¡Is) rrrrrœr�r›ÚitemsÚ CheckType)rÚtestrrŒZdependencies_namesZpublic_dependencies_namesrZmsg_typer!r!r"r�Cs zProtoFile.CheckFile)NN)r’r“r”ržr�r!r!r!r"rš9s ršc@seZdZdd„Zdd„ZdS)ÚEnumTypecCs ||_dS)N)Úvalues)rr¦r!r!r"ržQszEnumType.__init__c CsÂ|j|}|j||jƒdj|j|gƒ}|j||jƒ|j||jƒ|j||jƒxjt|jƒD]\\}\}} |j |} |j|| jƒ|j|| j ƒ|j| | j ƒ|j|| j ƒ|j ||jƒq^WdS)NÚ.)Úenum_types_by_namerrÚjoinr/r0ÚfileÚ enumerater¦rLÚindexrMÚtyperZenum_values_by_name) rr¤Úmsg_descrrŒÚ enum_descZexpected_enum_full_namer¬r~rMZ value_descr!r!r"r£Ts  zEnumType.CheckTypeN)r’r“r”ržr£r!r!r!r"r¥Osr¥c@seZdZddd„Zdd„ZdS)Ú MessageTypeFNcCs ||_||_||_|pg|_dS)N)Ú type_dictÚ field_listÚ is_extendablerb)rr±r²r³rbr!r!r"ržfszMessageType.__init__c Cs|dkr$|j|}dj|j|gƒ}n|j|}dj|j|gƒ}|j||jƒ|j||jƒ|j||jƒ|j|j|ƒ|j|j |j ƒx&|j j ƒD]\}}|j ||||ƒq’Wx,t |jƒD]\}\}} | j|||||ƒqºWx,t |jƒD]\}\}} | j|||||ƒqèWdS)Nr§)rr©rÚnested_types_by_namer/rrr0rªr³r±r¢r£r«r²Ú CheckFieldrb) rr¤Zcontaining_type_descrrŒZdescZexpected_full_nameÚsubtyper¬rSr!r!r"r£ms   zMessageType.CheckType)FN)r’r“r”ržr£r!r!r!r"r°ds r°c@seZdZdd„Zdd„ZdS)Ú EnumFieldcCs||_||_||_dS)N)rMÚ type_namer8)rrMr¸r8r!r!r"rž†szEnumField.__init__c Csê|j|}|j|j}|j||jƒdj|j|gƒ}|j||jƒ|j||jƒ|j|j|jƒ|jt j j |j ƒ|jt j j |jƒ|j|jƒ|j|j|jj|jƒ|j|j|jjƒ|j||jƒ|j||jƒ|j||jƒdS)Nr§)r3r¨r¸rrr©r/r¬rMr ÚFieldDescriptorZ TYPE_ENUMr­Z CPPTYPE_ENUMÚcpp_typer6r7rLr8r1r2r0r5rª) rr¤r®rr¬rŒÚ field_descr¯Úexpected_field_full_namer!r!r"rµ‹s"    zEnumField.CheckFieldN)r’r“r”ržrµr!r!r!r"r·„sr·c@seZdZdd„Zdd„ZdS)Ú MessageFieldcCs||_||_dS)N)rMr¸)rrMr¸r!r!r"rž¡szMessageField.__init__c CsÚ|j|}|j|j}|j||jƒdj|j|gƒ}|j||jƒ|j||jƒ|j|j|jƒ|jt j j |j ƒ|jt j j |jƒ|j|jƒ|j||jƒ|j||jƒ|j||jƒtjƒdkrÖ|jtt|dƒdS)Nr§r?r8)r3r´r¸rrr©r/r¬rMr r¹Ú TYPE_MESSAGEr­ÚCPPTYPE_MESSAGErºr1r7r0r4rªrrCr$ÚNotImplementedErrorÚgetattr) rr¤r®rr¬rŒr»Zfield_type_descr¼r!r!r"rµ¥s"     zMessageField.CheckFieldN)r’r“r”ržrµr!r!r!r"r½Ÿsr½c@seZdZdd„Zdd„ZdS)Ú StringFieldcCs||_||_dS)N)rMr8)rrMr8r!r!r"rž½szStringField.__init__cCs¦|j|}|j||jƒdj|j|gƒ}|j||jƒ|j||jƒ|j|j|jƒ|jtjj |j ƒ|jtjj |j ƒ|j |jƒ|j|j|jƒ|j||jƒdS)Nr§)r3rrr©r/r¬rMr r¹Z TYPE_STRINGr­ZCPPTYPE_STRINGrºr6r7r8rª)rr¤r®rr¬rŒr»r¼r!r!r"rµÁs   zStringField.CheckFieldN)r’r“r”ržrµr!r!r!r"r»srÂc@seZdZdd„Zdd„ZdS)ÚExtensionFieldcCs||_||_dS)N)rMÚ extended_type)rrMrÄr!r!r"ržÒszExtensionField.__init__cCsÐ|j|}|j||jƒdj|j|gƒ}|j||jƒ|j|j|jƒ|j||jƒ|jtjj |j ƒ|jtjj |j ƒ|j |jƒ|j|jƒ|j||jƒ|j||jƒ|j|j|jjƒ|j||jƒdS)Nr§)r[rrr©r/rMr¬r r¹r¾r­r¿rºr1r7r6Z is_extensionZextension_scoper4rÄr0rª)rr¤r®rr¬rŒr»r¼r!r!r"rµÖs    zExtensionField.CheckFieldN)r’r“r”ržrµr!r!r!r"rÃÐsrÃc@s¬eZdZdd„Zejejƒdkdƒdd„ƒZdd„Z ejejƒdkdƒd d „ƒZ ejejƒdkdƒd d „ƒZ ejejƒdkdƒd d„ƒZ dd„Z dd„Zdd„Zdd„ZdS)ÚAddDescriptorTestc Csªtjƒ}|jtjjƒ|jd|j|dƒjƒ|j t ƒ�|j|dƒWdQRX|jtjj jƒ|jd|j|dƒjƒ|jd|j dƒj ƒ|jd|j|dƒj ƒdS)Nzprotobuf_unittest.TestAllTypesz,protobuf_unittest.TestAllTypes.NestedMessagezgoogle/protobuf/unittest.proto)rriÚ AddDescriptorrrŠrwrr.r/r$r%Ú NestedMessagerrr')rÚprefixrr!r!r"Ú _TestMessageês,  zAddDescriptorTest._TestMessager?z7With the cpp implementation, Add() must be called firstcCs|jdƒ|jdƒdS)Nr>r§)rÉ)rr!r!r"Ú testMessages zAddDescriptorTest.testMessagec Csªtjƒ}|jtjjƒ|jd|j|dƒjƒ|j t ƒ�|j|dƒWdQRX|jtj j jƒ|jd|j|dƒjƒ|jd|j dƒjƒ|jd|j|dƒjƒdS)Nzprotobuf_unittest.ForeignEnumz(protobuf_unittest.ForeignEnum.NestedEnumz)protobuf_unittest.TestAllTypes.NestedEnumzgoogle/protobuf/unittest.proto)rriÚAddEnumDescriptorrr—rwrrGr/r$r%rŠÚ NestedEnumrrr')rrÈrr!r!r"Ú _TestEnums,  zAddDescriptorTest._TestEnumcCs|jdƒ|jdƒdS)Nr>r§)rÍ)rr!r!r"ÚtestEnum,s zAddDescriptorTest.testEnumc CsLtjƒ}|jtƒ�|jdƒWdQRX|jtjƒ|jd|jdƒj ƒdS)Nzprotobuf_unittest.TestService) rrir$r%rIÚAddServiceDescriptorrZ _TESTSERVICErr/)rrr!r!r"Ú testService2s  zAddDescriptorTest.testServicec CsLtjƒ}|jtjƒ|jd|jdƒjƒ|jt ƒ�|j dƒWdQRXdS)Nzgoogle/protobuf/unittest.protozprotobuf_unittest.TestAllTypes) rriÚAddFileDescriptorrrwrrrr$r%r')rrr!r!r"ÚtestFile=s   zAddDescriptorTest.testFilecCsRtjƒ}tjj}|jt|j|ƒtjƒ}tjj |ƒ|j |ƒ|j |j|ƒƒdS)N) rrirrwrr$r%rrzZ CopyToProtorjr6)rrZproto_file_namerur!r!r"ÚtestEmptyDescriptorPoolMs  z)AddDescriptorTest.testEmptyDescriptorPoolcCs tjƒ}tjddd�}|jjdd�|j|ƒ|j|jdƒj dƒ|j|j dƒj dƒtjdd�}|jjdd�}|j jd d tj j tj jd �|jjd d�}|jjd dd�|jjdd�tjƒ}|j|ƒ|jd|j dƒj ƒ|jd |jd ƒj ƒ|jd|jdƒj ƒdS)Nzsome/file.protor)rrZMessage)rzpackage.Messagezsome/filename/container.protoZ TopMessageZbbr*)rrMr­rRZTopEnumZ FOREIGN_FOOé)rrMZ TopService)rrirrzr4Úaddrjrrrr.rSZFieldDescriptorProtoZ TYPE_INT32ZLABEL_OPTIONALr5r~rfrGrI)rrrŒZ file_protoZ message_protoZ enum_protor!r!r"ÚtestCustomDescriptorPoolYs6    z*AddDescriptorTest.testCustomDescriptorPoolcCsptjƒ}d}tj|d�}tj}d|jj|_|j |ƒ|j |ƒ}|j ƒ}|j d|j|jƒ|j ||j ƒƒdS)Nz9file_descriptor_options_with_custom_descriptor_pool.proto)rZfoo)rrirrzr Z foo_optionsÚoptionsZ ExtensionsZfoo_namerjrZ GetOptionsrry)rrÚ file_nameZfile_descriptor_protoZ extension_idrur×r!r!r"Ú1testFileDescriptorOptionsWithCustomDescriptorPoolxs   zCAddDescriptorTest.testFileDescriptorOptionsWithCustomDescriptorPoolc%Cs¬tjƒ}|jtƒ�|jdƒWdQRX|jtƒ�|jdƒWdQRX|jtƒ�|jdƒWdQRX|jtƒ�|jdƒWdQRX|jtƒ�|jdƒWdQRXdS)Nr) rrir$rArÆrËrÏr\rÑ)rrr!r!r"ÚtestAddTypeError‰s     z"AddDescriptorTest.testAddTypeErrorN)r’r“r”rÉÚunittestZskipIfrrCrÊrÍrÎrÐrÒrÓrÖrÙrÚr!r!r!r"rÅès  rÅz4google/protobuf/internal/descriptor_pool_test1.protozgoogle.protobuf.python.internalÚALPHAr*rtr+ÚEPSILONéÚZETAérÌÚETAéÚTHETAérsZ nested_fieldZtheta)rÌÚDeepNestedMessageZbetaZdeep_nested_messageérå)rÌrÇZnested_messagerÇT)r³ÚGAMMAÚDELTArÔÚIOTAé ÚKAPPAé ÚLAMBDAé ÚMUé ÚlambdaZdelta)rrZDescriptorPoolTest2z4google/protobuf/internal/descriptor_pool_test2.protoZDescriptorPoolTest3ÚNUé ÚXIéÚOMICRONéÚPIéÚRHOéÚSIGMAéZsigmaZnuZdescriptor_pool_testiérr)rbz,google/protobuf/internal/more_messages.proto)rœr�Ú__main__)rÜr*)rtr+)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úrû)rürý)+Ú__doc__Ú __author__ÚosÚsysZ unittest2rÛÚ ImportErrorZgoogle.protobufrrrrZgoogle.protobuf.internalrrrr r r r r rrrrÚobjectrZTestCaser•r™rQršr¥r°r·r½rÂrÃrÅrŽr�r’Úmainr!r!r!r"Ú sº                 3#  0