
    i>                        d Z dZddlZddlZddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 dd	l	mZ dd
lmZ ddlmZ ddlmZ ddlmZ dZdZ ej$                  de        G d dej(                        Z G d de      Z G d dej(                        Z G d dej(                        Z G d dej(                        Zedk(  r ej6                          yy)z1Unittest for google.protobuf.internal.descriptor.z#robinson@google.com (Will Robinson)    N)unittest_custom_options_pb2)unittest_import_pb2)unittest_pb2)descriptor_pb2)api_implementation)	test_util)
descriptor)descriptor_pool)symbol_database)text_formatz
name: 'TestEmptyMessage'
aO  syntax = "proto2";

package protobuf_unittest;

message NestedMessage {
  enum ForeignEnum {
    FOREIGN_FOO = 4;
    FOREIGN_BAR = 5;
    FOREIGN_BAZ = 6;
  }
  optional int32 bb = 1;
}

message ResponseMessage {
}

service Service {
  rpc CallMethod(.protobuf_unittest.NestedMessage) returns (.protobuf_unittest.ResponseMessage);
}

errorc                      e Zd Zd Zd Zd Zd Zd Zd Z e	j                   ej                         dk(  d      d	        Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Z e	j                   ej                         dk(  d      d        Zd Zy)DescriptorTestc                    t        j                  dd      }|j                  j                  d      }|j                  j                  ddt         j
                  j                  t         j
                  j                         |j                  j                  d	      }|j                  j                  d
d       |j                  j                  dd       |j                  j                  dd       |j                  j                  d       |j                  j                  d      }|j                  j                  ddd      }| j                         | _        | j                  j                  |       | j                  j                  |j                         | _        | j"                  j$                  |j                      | _        | j&                  j(                  |j                      | _        | j"                  j,                  |j                      | _        | j.                  j0                  |j                      | _        y )Nsome/filename/some.protoprotobuf_unittest)namepackageNestedMessage)r   bb   )r   numbertypelabelForeignEnumFOREIGN_FOO   )r   r   FOREIGN_BAR   FOREIGN_BAZ   ResponseMessageService
CallMethodz .protobuf_unittest.NestedMessagez".protobuf_unittest.ResponseMessage)r   
input_typeoutput_type)r   FileDescriptorProtomessage_typeaddfieldFieldDescriptorProto
TYPE_INT32LABEL_OPTIONAL	enum_typevalueservicemethodGetDescriptorPoolpoolAddFindFileByNamer   my_filemessage_types_by_name
my_messageenum_types_by_namemy_enumservices_by_name
my_servicemethods_by_name	my_method)self
file_protomessage_proto
enum_protoservice_protomethod_protos         z/var/www/catia.catastroantioquia-mas.com/valormas/lib/python3.12/site-packages/google/protobuf/internal/descriptor_test.pysetUpzDescriptorTest.setUpR   s   33'#%J ++// 0 M00;;11@@	  B
 ((,, - JmA6mA6mA6%67&&** + M ''++58 , :L &&(DIIIMM*99++JOO<DLll889K9KLDO??55jooFDLll33M4F4FGDO__44\5F5FGDN    c                 >    t        j                         j                  S N)r   Defaultr3   r?   s    rE   r2   z DescriptorTest.GetDescriptorPoolv   s    ""$)))rG   c                    | j                  | j                  j                  dd      d       | j                  | j                  j                  d   j                  d   j
                  | j                  j                  dd             | j                  t              5  | j                  j                  dd       d d d        | j                  t              5  | j                  j                  dd       d d d        | j                  t              5  | j                  j                          d d d        y # 1 sw Y   |xY w# 1 sw Y   NxY w# 1 sw Y   y xY w)Nr   r   r   i  NoneEnum)	assertEqualr8   EnumValueNamer9   values_by_numberr   assertRaisesKeyError	TypeErrorrK   s    rE   testEnumValueNamez DescriptorTest.testEnumValueNamey   s   T__22=!D"$ 	**	++A	//3t%%mQ79 
		8	$ 8
oo##M378			8	$ 5
oo##J45			9	% &
oo##%& &	8 85 5& &s$   D4E E4D= E	Ec                 ~    | j                  | j                  | j                  j                  d   j                         y Nr   )rN   r:   valuesr   rK   s    rE   testEnumFixupszDescriptorTest.testEnumFixups   s+    T\\4<<#6#6q#9#>#>?rG   c                     | j                  | j                  | j                  j                  d   j                         | j                  | j                  | j                  j                         y rV   )rN   r8   fieldscontaining_typer:   rK   s    rE   testContainingTypeFixupsz'DescriptorTest.testContainingTypeFixups   sI    T__doo&<&<Q&?&O&OPT__dll&B&BCrG   c                 d    | j                  | j                  | j                  j                         y rI   )rN   r<   r>   containing_servicerK   s    rE   testContainingServiceFixupsz*DescriptorTest.testContainingServiceFixups   s     T__dnn&G&GHrG   pythonz<GetDebugString is only available with the cpp implementationc                 `    | j                  | j                  j                         t               y rI   )rN   r6   GetDebugStringTEST_FILE_DESCRIPTOR_DEBUGrK   s    rE   testGetDebugStringz!DescriptorTest.testGetDebugString   s"    
 	T\\0024NOrG   c                    | j                  | j                  j                         t        j                                | j                  | j                  j
                  d   j                         t        j                                | j                  | j                  j                         t        j                                | j                  | j                  j                  d   j                         t        j                                | j                  | j                  j                         t        j                                | j                  | j                  j                         t        j                                y rV   )rN   r:   
GetOptionsr   EnumOptionsrW   EnumValueOptionsr8   MessageOptionsrZ   FieldOptionsr>   MethodOptionsr<   ServiceOptionsrK   s    rE   testGetOptionszDescriptorTest.testGetOptions   s   T\\,,.#//13T\\((+668#4468T__//1#2246T__++A.99;#0024T^^..0#1135T__//1#2246rG   c                 \   t         j                  }t         j                  j                  }|j                  d   }|j                  d   }|j
                  d   }|j                  d   }|j                  d   }t         j                  j                  }|j                  d      }	|j                         }
t         j                  }| j                  d|
j                  |          |j                         }t         j                  }| j                  d|j                  |          |j                         }t         j                  }| j                  d	|j                  |          t         j                  }| j                  d
|j                  |          |j                         }t         j                   }| j                  d|j                  |          |j                         }t         j"                  }| j                  d|j                  |          |j                         }t         j$                  }| j                  d|j                  |          |j                         }t         j&                  }| j                  d|j                  |          |	j                         }t         j(                  }| j                  t         j*                  |j                  |          t         j,                  j                  }| j/                  |j0                         | j3                  |j0                         | j/                  |j0                         | j/                  |j0                         | j/                  |j0                         | j/                  |j0                         | j3                  |j0                         y )Nfield1AnOneofAnEnumANENUM_VAL2ANENUM_VAL1Fool   `	 il   -a *   ii{   l`	 )r   
DESCRIPTORTestMessageWithCustomOptionsfields_by_nameoneofs_by_namer9   enum_values_by_nameTestServiceWithCustomOptionsFindMethodByNamerf   	file_opt1rN   
Extensionsmessage_opt1
field_opt1
field_opt2
oneof_opt1	enum_opt1enum_value_opt1service_opt1method_opt1METHODOPT1_VAL2DummyMessageContainingEnum
assertTruehas_optionsassertFalse)r?   file_descriptormessage_descriptorfield_descriptoroneof_descriptorenum_descriptorenum_value_descriptorother_enum_value_descriptorservice_descriptormethod_descriptorfile_optionsr~   message_optionsr   field_optionsr   r   oneof_optionsr   enum_optionsr   enum_value_optionsr   service_optionsr   method_optionsr   s                              rE   testSimpleCustomOptionsz&DescriptorTest.testSimpleCustomOptions   s   1<<O566zz )88B)88C(;;HEO/00@#5#6#6}$F566zz *;;EB"--/L+55IZ!8!8!CD(335O.;;LS/44\BC$//1M,77JZ!9!9*!EF,77JR11*=>$//1M,77JS-22:>?"--/L+55IT<229=>.99;1AAOS,77HI(335O.;;L[/"<"<\"JK&113N-99K0@@#..{;= 	$>>II OOO//0'334OO$001OO$001OOO//0OO)5560<<=rG   c                     t         j                  j                  }t        j                         }|j                  |       | j                  t        |j                  j                               d       y )N   )
r   rx   rw   r   DescriptorProtoCopyToProtorN   lenoptions
ListFields)r?   r   rA   s      rE   testCustomOptionsCopyToz&DescriptorTest.testCustomOptionsCopyTo   sW    566zz "224M""=1S..99;<rG   c                 :   d}d}d}d}d}d}t         j                  j                  }|j                         }| j	                  d|j
                  t         j                            | j	                  ||j
                  t         j                            | j	                  ||j
                  t         j                            | j	                  d|j
                  t         j                            | j	                  d|j
                  t         j                            | j	                  ||j
                  t         j                            | j	                  ||j
                  t         j                            | j	                  d|j
                  t         j                            | j	                  d|j
                  t         j                            | j	                  ||j
                  t         j                            | j	                  ||j
                  t         j                             t         j"                  j                  }|j                         }| j	                  d	|j
                  t         j                            | j	                  ||j
                  t         j                            | j	                  ||j
                  t         j                            | j	                  ||j
                  t         j                            | j	                  ||j
                  t         j                            | j	                  ||j
                  t         j                            | j	                  ||j
                  t         j                            | j	                  ||j
                  t         j                            | j	                  ||j
                  t         j                            | j	                  ||j
                  t         j                            | j	                  ||j
                  t         j                             t         j$                  j                  }|j                         }| j	                  d
|j
                  t         j                            | j'                  d|j
                  t         j(                     d       | j'                  d|j
                  t         j*                            | j	                  d|j
                  t         j,                            | j	                  d|j
                  t         j.                            t         j0                  }	| j	                  |	j2                  |j
                  t         j4                            t         j6                  j                  }|j                         }| j'                  d|j
                  t         j(                     d       | j'                  d|j
                  t         j*                            t         j8                  j                  }|j                         }| j'                  d|j
                  t         j(                     d       | j'                  d|j
                  t         j*                            y )Ni   l         il    l    l    Fr   Tig$(@r!   gYB?zHello, "World"s   Hello World      iif)r   CustomOptionMinIntegerValuesrw   rf   rN   r   bool_opt	int32_opt	int64_opt
uint32_opt
uint64_opt
sint32_opt
sint64_optfixed32_optfixed64_optsfixed32_optsfixed64_optCustomOptionMaxIntegerValuesCustomOptionOtherValuesassertAlmostEqual	float_opt
double_opt
string_opt	bytes_optr   TEST_OPTION_ENUM_TYPE2enum_optSettingRealsFromPositiveIntsSettingRealsFromNegativeInts)
r?   	kint32min	kint64min	kint32max	kint64max
kuint32max
kuint64maxr   r   
dummy_enums
             rE   testDifferentCustomOptionTypesz-DescriptorTest.testDifferentCustomOptionTypes   s   IIIIJJ 	$@@KK (335OUO66#,,. /Y : :#--!/ 0Y : :#--!/ 0Q22#..0 1Q22#..0 1Y : :#..!0 1Y : :#..!0 1Q22#//1 2Q22#//1 2Y : :#00!2 3Y : :#00!2 3 	$@@KK (335OT?55#,,. /Y : :#--!/ 0Y : :#--!/ 0Z!;!;#.."0 1Z!;!;#.."0 1Y : :#..!0 1Y : :#..!0 1Z!;!;#//"1 2Z!;!;#//"1 2Y : :#00!2 3Y : :#00!2 3 	$;;FF (335OT?55#--/ 0:'A'A#--(/013/1K1K#..20 1')C)C#..*0 1_o&@&@#--'/ 0,GGJ))""#>#G#GHJ
 	$@@KK (335O299#-- /0133 : :#..!0 1 	$@@KK (335O3 : :#--!/0134!;!;#.."0 1rG   c                 	   t         j                  j                  } |j                         }| j	                  d|j
                  t         j                     j                         | j	                  d|j
                  t         j                     j
                  t         j                            | j	                  d|j
                  t         j                     j
                  t         j                     j                         | j	                  d|j
                  t         j                     j                         | j	                  d|j
                  t         j                     j
                  t         j                            | j	                  d|j
                  t         j                     j                  j                         | j	                  d|j
                  t         j                     j                  j
                  t         j                            | j	                  d|j
                  t         j                     j                  j
                  t         j                     j                         | j	                  d	|j
                  t         j                     j
                  t         j                     j                         | j	                  d
|j
                  t         j                     j
                  t         j                     j
                  t         j                            | j	                  d|j
                  t         j                     j
                  t         j                     j
                  t         j                     j                         | j	                  d|j
                  t         j                   j"                  j$                     j&                         | j	                  d|j
                  t         j                     j(                  j&                         | j	                  d|j
                  t         j*                     j                         | j	                  d|j
                  t         j*                     j,                  j.                         | j	                  d|j
                  t         j0                     j2                         y )Nru   iD  il  i  i  i  i  i  i  i  iI  i  iA  	         )r   VariousComplexOptionsrw   rf   rN   r   complex_opt1foomooocorgemoocomplex_opt2bazgraultbargarplyComplexOptionType2ComplexOptionType4complex_opt4waldofredcomplex_opt3complexoptiontype5plughcomplexopt6xyzzy)r?   r	   r   s      rE   testComplexExtensionOptionsz*DescriptorTest.testComplexExtensionOptionsC  s   #99DD #j##%GR++#00225#7S',,#0022<*',,. / 	S',,#0022<*'--//2s4 	S',,#00225#7S',,#0022<*'..0 1 	S',,#00225#cc;T7--#00225#jj',,. / 	T7--#00225#jj'--//2s4 	S',,#0022<*'..0035 	T7--#0022<*'..00:
+002 3 	T7--#0022<*'..00:
+113 4738 	T7--#66		LL**/%1 	S',,#00226$uu>Q**#00225#7R++#0022D2DUULR++#//1168rG   c                    t         j                  }t         j                  j                  }|j                  d   }t         j                  j                  }|j
                  d   }t         j                  j                  }|j                  d      }|j                         j                  t         j                     }| j                  d|j                         | j                  d|j                         | j                  d|j                  j                         | j                  d|j                  j                  t         j                     j                         | j                  d|j                   j                  t         j"                  j$                     j                         | j                  d	|j                         j                  t         j&                     j                         | j                  d
|j                         j                  t         j(                     j                         | j                  d|j                         j                  t         j*                     j                         | j                  d|j                         j                  t         j,                     j                         | j                  d|j                         j                  t         j.                     j                         | j                  d|j                         j                  t         j0                     j                         y )N	fieldnameVALUEMethodd   FileAnnotationNestedFileAnnotationFileExtensionAnnotationEmbeddedMessageSetElementMessageAnnotationFieldAnnotationEnumAnnotationEnumValueAnnotationServiceAnnotationMethodAnnotation)r   rw   AggregateMessagery   AggregateEnumvalues_by_nameAggregateServicer}   rf   r   fileoptrN   issubfilemsetAggregateMessageSetElementmessage_set_extensionmsgoptfieldoptenumopt
enumvalopt
serviceopt	methodopt)	r?   r   r   r   r   r   r   r   r   s	            rE   testAggregateOptionsz#DescriptorTest.testAggregateOptionsu  s   1<<O#44?? )88E1??JJO+::7C#44?? *;;HE #--/::#++-LS,..)%|~~6+\-=-=-?-?@.0A0A0L0L#++1--.Q00,2C2C2N2N#>>		3  !#
 	%%'22'..	0013 	##%00'00	223!5 	""$//'//	1124 	((*55'22	445A7 	%%'22'22	445A7 	$$&11'11	33416rG   c                 F   t         j                  j                  j                  }| j	                  d|j                         j                  t         j                            |j                  d   }| j	                  d|j                         j                  t         j                            t         j                  j                  }|j                  d   }| j	                  d|j                         j                  t         j                            |j                  d   }| j	                  d|j                         j                  t         j                            |j                  d   }| j	                  d	|j                         j                  t         j                            y )
Ni  nested_fieldi  
NestedEnumi  NESTED_ENUM_VALUEi  nested_extensioni  )r   NestedOptionTyper   rw   rN   rf   r   r   ry   r   r9   r   r{   r   extensions_by_namer   )r?   nested_messager  outer_messagenested_enumnested_enum_valuer	  s          rE   testNestedOptionsz DescriptorTest.testNestedOptions  sc   #44BBMM T>446AA#002 3!00@LT<224??#..0 1 	$44?? 22<@KT;113>>#--/ 0%99:MNT,779DD#335 6$778JKT+668CC#..0 1rG   c                     | j                  | j                  j                  | j                         | j                  | j                  j                  | j                         y rI   )rN   r:   r   r6   r8   rK   s    rE   testFileDescriptorReferencesz+DescriptorTest.testFileDescriptorReferences  s>    T\\&&5T__))4<<8rG   c                    | j                  | j                  j                  d       | j                  | j                  j                  d       | j                  | j                  j                  | j                         | j                  | j                  j                         | j                  d| j                  j                         t        j                         }| j                  j                  |       | j                  | j                  j                  |j                                | j                  t        j                  j                  t        j                                 y )Nr   r   proto2)rN   r6   r   r   r3   r   r   syntaxr   r'   r   serialized_pbSerializeToStringr   rw   r
   rJ   )r?   r@   s     rE   testFileDescriptorz!DescriptorTest.testFileDescriptor  s    T\\&&(BCT\\))+>?T\\&&		2T\\--.Xt||223335JLLZ(T\\//1135 	\,,11?3J3J3LMrG   zAImmutability of descriptors is only enforced in v2 implementationc                    t         j                  }t         j                  j                  }|j                  d   }|j                  d   }|j
                  d   }| j                  t              5  d |_        d d d        | j                  t              5  d |j                  d<   d d d        | j                  t              5  |j                  j                  d        d d d        | j                  t              5  ||_        d d d        | j                  t              5  d|_        d d d        | j                  t              5  d|_        d d d        | j                  t              5  d|_        d d d        | j                  t              5  d|_        d d d        | j                  t              5 }d|_        d d d        | j                  dt        j                               y # 1 sw Y   txY w# 1 sw Y   TxY w# 1 sw Y   (xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w)Noptional_int32r  oneof_fieldAnotherFTz&attribute is not writable: has_options)r   rw   TestAllTypesry   r9   rz   rQ   AttributeErrorrS   rZ   appendr[   r   rN   str	exception)r?   r   r   r   r   r   es          rE   testImmutableCppDescriptorz)DescriptorTest.testImmutableCppDescriptor  s    #--O%22==)889IJ(;;LIO)88G			>	* /*.'/			9	% :59''	2:			9	% -&&t,-			>	* <);&<			>	* *$)o!*			>	* +%*"+			>	* +%*"+			>	* *$)o!*			>	* ,a'+$,=%'%/ /: :- -< <* *+ ++ +* *, ,sl   -G'G4?H8HHH''H3H?1I'G14G>HHH$'H03H<?IIc                    t         j                  j                  }|j                  d   }| j	                  |j
                  g        |j                  d   }| j	                  |j
                  g        |j                  d   }| j	                  |j
                  d        |j                  d   }| j	                  |j
                  d        y )Nrepeated_int32repeated_nested_messageoptionalgroupoptional_nested_message)r   r  rw   ry   rN   default_value)r?   r   r*   s      rE   testDefaultzDescriptorTest.testDefault  s    %22==--.>?EU(("---.GHEU(("---o>EU(($/--.GHEU(($/rG   N)__name__
__module____qualname__rF   r2   rT   rX   r\   r_   unittestskipIfr   Typerd   rm   r   r   r   r   r  r  r  r  r#  r*   rG   rE   r   r   P   s    "HH*&@DI 8??8+DP	P64>l\1|.8d/6b1(9N 8??8+IK'K'6	0rG   r   c                       e Zd ZdZd Zy)NewDescriptorTestzARedo the same tests as above, but with a separate DescriptorPool.c                 *    t        j                         S rI   )r
   DescriptorPoolrK   s    rE   r2   z#NewDescriptorTest.GetDescriptorPool  s    ))++rG   N)r+  r,  r-  __doc__r2   r1  rG   rE   r3  r3    s
    I,rG   r3  c                   L    e 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y)GeneratedDescriptorTestz:Tests for the properties of descriptors in generated code.c                 :   | j                  |j                  d       | j                  |j                  d       | j                  ||       | j                  |j                  d   j                  |       | j                  ||g       | j                  ||d i       | j                  |j                         | j                  |j                         | j                  |j                         | j                  |j                         | j                  |j                         | j                  |j                         | j                  |j                         | j                  |j                  d   j                         | j                  |j                   g        y )Nr  zprotobuf_unittest.TestAllTypesr   )rN   r   	full_namerZ   r[   assertInCheckDescriptorSequenceCheckDescriptorMappingry   fields_by_numberfields_by_camelcase_namer9   r{   rz   
enum_typesr   extension_ranges)r?   r   s     rE   CheckMessageDescriptorz.GeneratedDescriptorTest.CheckMessageDescriptor  s^   ',,n='1157 	');<'..q1AA')MM$'9&:;MM$'94&@A  !3!:!:; 2 A AB 2 C CD 2 K KL 2 E EF 2 F FG 2 A AB 2 = =a @ O OP'88"=rG   c                    | j                  |j                  d       | j                  |j                  d       | j                  |j                  d       | j                  |j                  j                  d       | j                  |j
                  t        j                         | j                  ||       | j                  |j                  j                  d   |       | j                  |j                  j                  d   |       | j                  ||g       | j                  ||d i       | j                  d |j                         | j                  d |j                         | j                  |j                         t        j                          dk(  r'| j                  |j"                  |j"                         y y )Nr  optionalInt32z-protobuf_unittest.TestAllTypes.optional_int32r  cpp)rN   r   camelcase_namer:  r[   r   r   rw   ry   r?  r;  extension_scoper.   r   has_presencer   r0  id)r?   r   s     rE   CheckFieldDescriptorz,GeneratedDescriptorTest.CheckFieldDescriptor  s   %**,<=%44oF%//DF%55::NK%**L,C,CD%'78((778HI 	((AA	 	MM"%5$67MM"%5t$<=T+;;<T+556OO$112 E)
'**,<,?,?@ *rG   c                    | j                  |t        j                  j                  j                         | j                  |g        | j                  |d       | j                  |dk(         | j                  ||       t        |      }| j                  ||       | j                  t        |      d       | j                  t        |      t        |             | j                  |t        |      dz
     |d          |d   }| j                  ||d          | j                  ||       | j                  |j                  |      d       | j                  |j                  |      d       t        j                  j                  j                  d   }| j                  ||       | j                  |j                  |      d       | j                  t         |j                  |       | j                  t         |j                  g        t#        |      }| j                  t        |      t        |      d d d          | j                  t$        t&        |       d|d<   | j                  ||       t)        j*                         dk(  r.| j                  t-        t        |            t-        |             y | j                  t-        |      d   d       y )Nr   r   change valuer`   <)assertNotEqualr   TestAllExtensionsrw   rZ   r   rN   listassertGreaterr   r;  indexcountNestedTestAllTypesassertNotInrQ   
ValueErrorreversedStopIterationnextr   r0  r   )r?   sequenceexpected_listitem
other_itemreversed_iterators         rE   r<  z/GeneratedDescriptorTest.CheckDescriptorSequence0  sD    	$66AAHHJ"%!$X]#Xx(NM]H-s8}a(S]C$67Xc(mQ./">A;DT8A;'MM$!X^^D)1-X^^D)1-00;;BB1EJZ*X^^J/3j(..*=j(.."5 *T+,d8nTrT.BCmT+<=%M!x0 H,
s4>*CM:
s8}Q'-rG   c           
         | j                  |t        j                  j                  j                         | j                  |i        | j                  |d       | j                  |dk(         t        |j                               }| j                  ||       | j                  ||       | j                  t        |      d       | j                  t        |      t        |             t        t        |j                                     \  }}| j                  ||       | j                  |j                  |      |       | j                  t               5  |j                          d d d        t#        j$                         dk(  r"| j                  t         |j                  g        n!| j                  d |j                  g              t        t        |j'                                     t        t        |j)                                     f}| j                  |t        t        |j                                            d||<   | j                  ||       ||= d|d<   | j                  ||       | j                  t*        |j,                  d       | j                  t*        |j,                  t        |      dz          t#        j$                         dk(  rN| j                  t        t/        t        |j                                           t        t/        |                   y | j                  t/        |      d   d       y # 1 sw Y   xY w)	Nr   r   r`   rM  newnew_key	key_errorrN  )rO  r   rP  rw   ry   r   dictitemsrN   rR  r   rZ  iterr;  getrQ   rS   r   r0  keysrW   rR   __getitem__r   )r?   mappingexcepted_dictkeyr]  s        rE   r=  z.GeneratedDescriptorTest.CheckDescriptorMappingS  s}    	//::IIK$#W\")MWm,Wg&s7|Q'S\3}#56T'--/*+ICMM#wW[[%t,			9	% kkm  H,
	7;;3
tW[[_-glln%&T'..2B-C(DEDT4W]]_ 567'M#/c$M)/h 3 3[Ah 3 3S\A5EF H,
s3tGMMO456CL8IJ
s7|A,+ s   MMc                 "   t         j                  j                  }| j                  |       |j                  d   }| j                  |       |j                  d   }| j                  |       t         j                  j                  d   }| j                  d |j                         | j                  t         j                  j                  j                  dg       | j                  t         j                  j                  j                  g d       y )Nr  rD  r   )r       ))ru   +   )i/  i  )i   rn  )r   r  rw   rB  ry   rJ  r?  r9   rN   r[   rP  rA  TestMultipleExtensionRanges)r?   r   r   r   s       rE   testDescriptorz&GeneratedDescriptorTest.testDescriptorz  s    %22== 23)889IJ./)BB./"--@@OT?::;&&11BB	 	00;;LL46rG   c                    t         j                  }| j                  |j                         | j	                  |j
                         | j	                  |j                         | j	                  |j                         | j	                  |j                         | j	                  t         j                  j                  j                         y rI   )
r   rw   r<  dependenciesr=  r7   r9   r;   r  TestNestedExtension)r?   containing_files     rE   testCppDescriptorContainerz2GeneratedDescriptorTest.testCppDescriptorContainer  s    "--O  !=!=> E EF B BC @ @A B BC((33FFHrG   c                     t         j                  j                  j                  d   }t	        |j
                        }~| j                  dt        |      j                         y )Nr  FOO)	r   r  rw   r9   rf  rW   rN   rZ  r   )r?   enumvalues_iters      rE   #testCppDescriptorContainer_Iteratorz;GeneratedDescriptorTest.testCppDescriptorContainer_Iterator  sJ    $$//BB<PDt{{#KUD-223rG   c                 >   t         j                  j                  }t         j                  j                  j                  }| j	                  t        |j                        d       | j                  d |j                  v        | j                  ||j                  v        y )N   )	r   r  rw   r   rN   r   nested_typesr   r   )r?   r   nested_message_descriptors      rE   "testDescriptorNestedTypesContainerz:GeneratedDescriptorTest.testDescriptorNestedTypesContainer  s~    %22== , 9 9 G G R RS+8891=T/<<<=OO!%7%D%DDFrG   c                    t         j                  j                  d   }| j                  |j                  d       | j                  |j
                  d   j                  d       | j                  |j                  t         j                         | j                  |j                  d       | j                  |j                         y )NTestServicer   rt   )r   rw   r;   rN   r   methodsassertIsr   rS  r=  r=   )r?   r   s     rE   testServiceDescriptorz-GeneratedDescriptorTest.testServiceDescriptor  s    %00AA-P',,m<'//277?MM$))<+B+BC'--q1 2 B BCrG   c                 l   t         j                  j                  }|j                  d   }| j	                  |j
                         | j                  ||j                         | j                  d|j                         | j                  d|j                         | j                  d|j                         y )Nr  z*protobuf_unittest.TestAllTypes.oneof_fieldr   )r   r  rw   rz   r   r   rN   r[   r   r:  rS  )r?   r   r   s      rE   testOneofDescriptorz+GeneratedDescriptorTest.testOneofDescriptor  s    %22==)88G%112')9)I)IJ]$4$9$9:A%//1Q(../rG   N)r+  r,  r-  r6  rB  rJ  r<  r=  rq  rv  r{  r  r  r  r1  rG   rE   r8  r8    s=    B>.A4!.F%-N6&H4FD0rG   r8  c                       e 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 ej"                   ej&                         dk(  d      d        Zy)DescriptorCopyToProtoTestz)Tests for CopyTo functions of Descriptor.c           
           |       }t        j                  ||       | j                  ||dt        |      dt        |      d       y )NzNot equal,
Actual:
z
Expected:

)r   MergerN   r   )r?   actual_protoexpected_classexpected_asciiexpected_protos        rE   _AssertProtoEqualz+DescriptorCopyToProtoTest._AssertProtoEqual  sA    #%Nnn5n|c.1	34rG   c                 Z     |       }|j                  |       | j                  |||       y rI   )r   r  )r?   descexpected_proto_classexpected_proto_asciiactuals        rE   _InternalTestCopyToProtoz2DescriptorCopyToProtoTest._InternalTestCopyToProto  s/    !#FV$&:<rG   c                 ~    | j                  t        j                  j                  t        j
                  t               y rI   )r  r   TestEmptyMessagerw   r   r   #TEST_EMPTY_MESSAGE_DESCRIPTOR_ASCIIrK   s    rE   testCopyToProto_EmptyMessagez6DescriptorCopyToProtoTest.testCopyToProto_EmptyMessage  s+    !!%%00&&+-rG   c                     d}| j                  t        j                  j                  j                  t
        j                  |       y )Nz
      name: 'NestedMessage'
      field: <
        name: 'bb'
        number: 1
        label: 1  # Optional
        type: 5  # TYPE_INT32
      >
      )r  r   r  r   rw   r   r   )r?   TEST_NESTED_MESSAGE_ASCIIs     rE   testCopyToProto_NestedMessagez7DescriptorCopyToProtoTest.testCopyToProto_NestedMessage  s;    !
 	!!!!//::&&!#rG   c                 z    d}| j                  t        j                  j                  t        j
                  |       y )Nz
      name: 'TestForeignNested'
      field: <
        name: 'foreign_nested'
        number: 1
        label: 1  # Optional
        type: 11  # TYPE_MESSAGE
        type_name: '.protobuf_unittest.TestAllTypes.NestedMessage'
      >
      )r  r   TestForeignNestedrw   r   r   )r?   TEST_FOREIGN_NESTED_ASCIIs     rE   $testCopyToProto_ForeignNestedMessagez>DescriptorCopyToProtoTest.testCopyToProto_ForeignNestedMessage  s5    	!
 	!!&&11&&!#rG   c                 z    d}| j                  t        j                  j                  t        j
                  |       y )Nz
      name: 'ForeignEnum'
      value: <
        name: 'FOREIGN_FOO'
        number: 4
      >
      value: <
        name: 'FOREIGN_BAR'
        number: 5
      >
      value: <
        name: 'FOREIGN_BAZ'
        number: 6
      >
      )r  r   r   rw   r   EnumDescriptorProto)r?   TEST_FOREIGN_ENUM_ASCIIs     rE   testCopyToProto_ForeignEnumz5DescriptorCopyToProtoTest.testCopyToProto_ForeignEnum  s5    
  	!!  ++**!rG   c                 z    d}| j                  t        j                  j                  t        j
                  |       y )Na  
      name: 'TestDeprecatedFields'
      field: <
        name: 'deprecated_int32'
        number: 1
        label: 1  # Optional
        type: 5  # TYPE_INT32
        options: <
          deprecated: true
        >
      >
      field {
        name: "deprecated_int32_in_oneof"
        number: 2
        label: LABEL_OPTIONAL
        type: TYPE_INT32
        options {
          deprecated: true
        }
        oneof_index: 0
      }
      oneof_decl {
        name: "oneof_fields"
      }
      )r  r   TestDeprecatedFieldsrw   r   r   )r?   TEST_DEPRECATED_FIELDS_ASCIIs     rE   testCopyToProto_Optionsz1DescriptorCopyToProtoTest.testCopyToProto_Options	  s5    $
 4 	!!))44&&$&rG   c                 z    d}| j                  t        j                  j                  t        j
                  |       y )Nz}
      name: 'TestEmptyMessageWithExtensions'
      extension_range: <
        start: 1
        end: 536870912
      >
      )r  r   TestEmptyMessageWithExtensionsrw   r   r   )r?   (TEST_EMPTY_MESSAGE_WITH_EXTENSIONS_ASCIIs     rE   testCopyToProto_AllExtensionsz7DescriptorCopyToProtoTest.testCopyToProto_AllExtensions)  s5    0
, 	!!33>>&&02rG   c                 z    d}| j                  t        j                  j                  t        j
                  |       y )Na  
      name: 'TestMultipleExtensionRanges'
      extension_range: <
        start: 42
        end: 43
      >
      extension_range: <
        start: 4143
        end: 4244
      >
      extension_range: <
        start: 65536
        end: 536870912
      >
      )r  r   rp  rw   r   r   )r?   *TEST_MESSAGE_WITH_SEVERAL_EXTENSIONS_ASCIIs     rE   !testCopyToProto_SeveralExtensionsz;DescriptorCopyToProtoTest.testCopyToProto_SeveralExtensions7  s5    2
.  	!!00;;&&24rG   c                 f    d}| j                  t        j                  t        j                  |       y )Na7  
      name: 'google/protobuf/unittest_import.proto'
      package: 'protobuf_unittest_import'
      dependency: 'google/protobuf/unittest_import_public.proto'
      message_type: <
        name: 'ImportMessage'
        field: <
          name: 'd'
          number: 1
          label: 1  # Optional
          type: 5  # TYPE_INT32
        >
      >
      enum_type: <
        name: 'ImportEnum'
        value: <
          name: 'IMPORT_FOO'
          number: 7
        >
        value: <
          name: 'IMPORT_BAR'
          number: 8
        >
        value: <
          name: 'IMPORT_BAZ'
          number: 9
        >
      >
      enum_type: <
        name: 'ImportEnumForMap'
        value: <
          name: 'UNKNOWN'
          number: 0
        >
        value: <
          name: 'FOO'
          number: 1
        >
        value: <
          name: 'BAR'
          number: 2
        >
      >
      options: <
        java_package: 'com.google.protobuf.test'
        optimize_for: 1  # SPEED
      
        cc_enable_arenas: true
      >
      public_dependency: 0
    )r  r   rw   r   r'   )r?   %UNITTEST_IMPORT_FILE_DESCRIPTOR_ASCIIs     rE   testCopyToProto_FileDescriptorz8DescriptorCopyToProtoTest.testCopyToProto_FileDescriptorM  s0    4.)j 	!!&&**-/rG   c                 z    d}| j                  t        j                  j                  t        j
                  |       y )NaM  
      name: 'TestService'
      method: <
        name: 'Foo'
        input_type: '.protobuf_unittest.FooRequest'
        output_type: '.protobuf_unittest.FooResponse'
      >
      method: <
        name: 'Bar'
        input_type: '.protobuf_unittest.BarRequest'
        output_type: '.protobuf_unittest.BarResponse'
      >
      )r  r   r  rw   r   ServiceDescriptorProto)r?   TEST_SERVICE_ASCIIs     rE   !testCopyToProto_ServiceDescriptorz;DescriptorCopyToProtoTest.testCopyToProto_ServiceDescriptor  s5    
 	!!  ++--rG   c                     d}t         j                  j                  j                  d      }| j	                  |t
        j                  |       y )Nz}
      name: 'Foo'
      input_type: '.protobuf_unittest.FooRequest'
      output_type: '.protobuf_unittest.FooResponse'
    rt   )r   r  rw   r}   r  r   MethodDescriptorProto)r?   r  r   s      rE    testCopyToProto_MethodDescriptorz:DescriptorCopyToProtoTest.testCopyToProto_MethodDescriptor  sH    N
 %00;;LL!!,,rG   r`   z!Pure python does not raise error.c                    t        j                         }| j                  t        t        j
                  j                  j                  |       | j                  t        t        j                  j                  j                  |       | j                  t        t        j                  j                  j                  |       t        j                         }| j                  t        t        j                  j                  |       y rI   )r   r'   rQ   rS   r   r  rw   r   r   r  r   r   )r?   r@   protos      rE   testCopyToProto_TypeErrorz3DescriptorCopyToProtoTest.testCopyToProto_TypeError  s    
  335Ji"33>>JJ " 	i"..99EE " 	i"..99EE " **,Ei)44@@rG   N)r+  r,  r-  r6  r  r  r  r  r  r  r  r  r  r  r  r  r.  r/  r   r0  r  r1  rG   rE   r  r    sy    14<-# #"!,&@24,9/v& 8??8+)+	+rG   r  c                   *    e Zd Zd Zd Zd Zd Zd Zy)MakeDescriptorTestc                    t        j                         }d|_        |j                  j	                         }|j                  |_        |j
                  j	                         }d|_        |j                  j	                         }d|_        |j                  j	                         }d|_        d|_        |j                  j	                         }d|_        d|_        t        j                  j                  |_        t        j                  j                  |_        |j                  j	                         }d|_        d	|_        t        j                  j                  |_        t        j                  j                   |_        d|_        |j                  j	                         }d|_        d
|_        t        j                  j                  |_        t        j                  j$                  |_        d|_        t        j&                  |      }| j)                  |j*                  d   j,                  t        j                  j.                         | j)                  |j*                  d   j,                  t        j                  j0                         | j)                  |j*                  d   j                  j2                  |       | j)                  |j4                  d   j*                  d   j6                  d       | j)                  |j4                  d   j*                  d   j                  |j4                  d   j8                  d          | j;                  |j<                         | j;                  |j*                  d   j<                         t?        j@                         dk(  r3| jC                  tD              5  d|j*                  d   _        d d d        y y # 1 sw Y   y xY w)NFoo2Subrx  BARr}  r   uint64_fieldr   nested_message_field	bar_fieldzFoo2.Sub.FOOr   zFoo2.Sub.bar_fieldrE  F)#r   r'   r   r(   r)   nested_typer.   r/   r   r*   r	   FieldDescriptorLABEL_REQUIREDr   TYPE_UINT64r   TYPE_MESSAGE	type_name	TYPE_ENUMMakeDescriptorrN   rZ   cpp_typeCPPTYPE_UINT64CPPTYPE_MESSAGEr[   r~  r:  r@  r   r   r   r0  rQ   r  )	r?   file_descriptor_protor(   r  r.   enum_type_valr*   
enum_fieldresults	            rE   "testMakeDescriptorWithNestedFieldsz5MakeDescriptorTest.testMakeDescriptorWithNestedFields  s   *>>@!'(5599;L-22L**..0KK%%))+IINOO'')MMM""$EELEJ,,;;EK++77EJ""$EEL'EJ,,;;EK++88EJEO""&&(JJ!JO!11@@J 00::JO)J&&|4FV]]1%..//>>@V]]1%..//??AV]]1%22BBV((+2215??)+V((+2215??((+66q9;V''(V]]1%112 E)^, -',a$- - *- -s   0OOc                 t   t        j                         }d|_        |j                  j	                         }|j                  |_        |j
                  j	                         }d|_        |j                  j	                         }d|_        d|_        |j                  j	                         }d|_        d|_        t        j                  j                  |_        t        j                  j                  |_        |j                  j	                         }d|_        d|_        t        j                  j                  |_        t        j                  j                  |_        d	|_        t        j"                  |      }| j%                  |j&                  d
   j(                  t        j                  j*                         y )Nrt   rx  r  r}  r   r  r   r  zFoo.FOOr   )r   r'   r   r(   r)   r.   r/   r   r*   r	   r  r  r   r  r   r  r  r  rN   rZ   r  r  )r?   r  r(   r.   r  r*   r  r  s           rE   &testMakeDescriptorWithUnsignedIntFieldz9MakeDescriptorTest.testMakeDescriptorWithUnsignedIntField  sR   *>>@!&(5599;L-22L&&**,IINOO'')MMM""$EELEJ,,;;EK++77EJ##'')JJ!JO!11@@J 00::JO$J&&|4FV]]1%..//>>@rG   c                 :   t        j                         }t        j                  }|j                  j                  |       t        j                  |      }|j                         }| j                  d|j                  t        j                     j                         y )Ne   )r   r   r   r   rw   r   r	   r  rf   rN   r   r   r   )r?   descriptor_protoaggregate_messagereformed_descriptorr   s        rE   testMakeDescriptorWithOptionsz0MakeDescriptorTest.testMakeDescriptorWithOptions	  s~    %5573DD  ,,-=>$334DE!,,.GS(()D)K)KLNNPrG   c                    t        j                         }d|_        g d}g d}t        t	        |            D ]0  }|j
                  j                         }|dz   |_        ||   |_        2 t        j                  |      }t        t	        |            D ].  }| j                  |j                  |   j                  ||          0 y )NBar)foo_fooFooBarfooBazfooFoofoobar)r  fooBarr  r  r  r   )r   r   r   ranger   r*   r)   r   r	   r  rN   rZ   rF  )r?   r  namescamelcase_namesrS  r*   r  s          rE   testCamelcaseNamez$MakeDescriptorTest.testCamelcaseName  s    %557!?EHOs5z"  $$((*eQYel<ej  &&'78Fs?+, /
v}}U+::&u-//rG   c                    t        j                         }d|_        g d}g d}t        t	        |            D ]0  }|j
                  j                         }|dz   |_        ||   |_        2 d_        t        j                  |      }t        t	        |            D ].  }| j                  |j                  |   j                  ||          0 y )NTestJsonName)
field_name	fieldName	FieldName_field_name
FIELD_NAME	json_name)r  r  r  r  	FIELDNAME@typer   r  )r   r   r   r  r   r*   r)   r   r  r	   r  rN   rZ   )r?   r  r  
json_namesrS  r*   r  s          rE   testJsonNamezMakeDescriptorTest.testJsonName!  s    %557*7E5Js5z"  $$((*eQYel<ej  EO&&'78Fs:' *
v}}U+55!%(**rG   N)r+  r,  r-  r  r  r  r  r  r1  rG   rE   r  r    s    --^@6P/*rG   r  __main__)r6  
__author__r.  warningsgoogle.protobufr   r   r   r   google.protobuf.internalr   r   r	   r
   r   r   r  rc   simplefilterDeprecationWarningTestCaser   r3  r8  r  r  r+  mainr1  rG   rE   <module>r     s   > 82
   7 / ( * 7 . & + + '' # .   g1 2b0X&& b0J, ,z0h// z0zA 1 1 AHs*** s*l z(--/ rG   