HEX
Server: LiteSpeed
System: Linux server334.web-hosting.com 4.18.0-553.124.4.lve.el8.x86_64 #1 SMP Fri May 15 13:02:13 UTC 2026 x86_64
User: richfield (1256)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: //lib/python3.6/site-packages/google/protobuf/internal/__pycache__/descriptor_test.cpython-36.pyc
3

���h1��@s$dZdZddlZyddlZWnek
r8ddlZYnXddlmZddlmZddlm	Z	ddlm
Z
ddlmZdd	lm
Z
dd
lmZddlmZddlmZdd
lmZdZGdd�dej�ZGdd�de�ZGdd�dej�ZGdd�dej�ZGdd�dej�Zedk�r ej�dS)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'
c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zejej�dkp�ej�dkd�d d!��Zd"S)#�DescriptorTestcCstjddd�}|jjdd�}|jjddtjjtjjd�|jjd	d�}|j	jd
dd�|j	jd
dd�|j	jddd�|jjdd�|j
jdd�}|jjdddd�}|j�|_
|j
j|�|j
j|j�|_|jj|j|_|jj|j|_|jj|j|_|jj|j|_dS)Nzsome/filename/some.proto�protobuf_unittest)�name�package�
NestedMessage)rZbb�)r�number�type�label�ForeignEnum�FOREIGN_FOO�)rrZFOREIGN_BAR�ZFOREIGN_BAZ�ZResponseMessageZServiceZ
CallMethodz .protobuf_unittest.NestedMessagez".protobuf_unittest.ResponseMessage)rZ
input_typeZoutput_type)r�FileDescriptorProto�message_type�add�fieldZFieldDescriptorProtoZ
TYPE_INT32ZLABEL_OPTIONAL�	enum_type�valueZservice�method�GetDescriptorPool�poolZAddZFindFileByNamer�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_protoZ
message_protoZ
enum_protoZ
service_protoZmethod_proto�r.�%/usr/lib/python3.6/descriptor_test.py�setUp>s:
zDescriptorTest.setUpcCs
tj�jS)N)r
�Defaultr")r,r.r.r/r!bsz DescriptorTest.GetDescriptorPoolcCs�|j|jjdd�d�|j|jjdjdj|jjdd��|jt��|jjdd�WdQRX|jt��|jjdd�WdQRX|jt��|jj�WdQRXdS)Nrrri�ZNoneEnum)	�assertEqualr%Z
EnumValueNamer&Zvalues_by_numberr�assertRaises�KeyError�	TypeError)r,r.r.r/�testEnumValueNameesz DescriptorTest.testEnumValueNamecCs|j|j|jjdj�dS)Nr)r2r'�valuesr)r,r.r.r/�testEnumFixupstszDescriptorTest.testEnumFixupscCs.|j|j|jjdj�|j|j|jj�dS)Nr)r2r%�fields�containing_typer')r,r.r.r/�testContainingTypeFixupswsz'DescriptorTest.testContainingTypeFixupscCs|j|j|jj�dS)N)r2r)r+Zcontaining_service)r,r.r.r/�testContainingServiceFixups{sz*DescriptorTest.testContainingServiceFixupscCs�|j|jj�tj��|j|jjdj�tj��|j|jj�tj��|j|jj	dj�tj
��|j|jj�tj��|j|j
j�tj��dS)Nr)r2r'�
GetOptionsrZEnumOptionsr7ZEnumValueOptionsr%ZMessageOptionsr9ZFieldOptionsr+Z
MethodOptionsr)ZServiceOptions)r,r.r.r/�testGetOptions~s




zDescriptorTest.testGetOptionscCs�tj}tjj}|jd}|jd}|jd}|jd}|jd}tjj}|jd�}	|j	�}
tj
}|jd|
j|�|j	�}tj
}
|jd|j|
�|j	�}tj}|jd	|j|�tj}|jd
|j|�|j	�}tj}|jd|j|�|j	�}tj}|jd|j|�|j	�}tj}|jd
|j|�|j	�}tj}|jd|j|�|	j	�}tj}|jtj|j|�tjj}|j|j�|j|j�|j|j�|j|j�|j|j�|j|j�|j|j�dS)NZfield1ZAnOneofZAnEnumZANENUM_VAL2ZANENUM_VAL1�Fool�`	�8l-a��*�ci�{i���i����i��l�����`	)r�
DESCRIPTORZTestMessageWithCustomOptions�fields_by_name�oneofs_by_namer&�enum_values_by_nameZTestServiceWithCustomOptions�FindMethodByNamer=�	file_opt1r2�
Extensions�message_opt1�
field_opt1�
field_opt2�
oneof_opt1�	enum_opt1�enum_value_opt1�service_opt1�method_opt1ZMETHODOPT1_VAL2�DummyMessageContainingEnumZ
assertTrue�has_options�assertFalse)r,�file_descriptor�message_descriptor�field_descriptor�oneof_descriptor�enum_descriptor�enum_value_descriptorZother_enum_value_descriptor�service_descriptor�method_descriptor�file_optionsrI�message_optionsrKZ
field_optionsrLrMZ
oneof_optionsrNZenum_optionsrOZenum_value_optionsrPZservice_optionsrQZmethod_optionsrRr.r.r/�testSimpleCustomOptions�s\



z&DescriptorTest.testSimpleCustomOptionsc
Cs�d}d}d}d}d}d}tjj}|j�}|jd|jtj�|j||jtj�|j||jtj�|jd|jtj	�|jd|jtj
�|j||jtj�|j||jtj�|jd|jtj
�|jd|jtj�|j||jtj�|j||jtj�tjj}|j�}|jd	|jtj�|j||jtj�|j||jtj�|j||jtj	�|j||jtj
�|j||jtj�|j||jtj�|j||jtj
�|j||jtj�|j||jtj�|j||jtj�tjj}|j�}|jd|jtj�|jd|jtjd�|jd
|jtj�|jd|jtj�|jd|jtj�tj}	|j|	j|jtj�tjj}|j�}|jd|jtjd�|jd|jtj�tjj}|j�}|jd|jtjd�|jd |jtj�dS)!N���?r� �@FrT�dg��$��(@rg�Y�B��?zHello, "World"sHelloWorld��li�ll����li���ll����ll��ll����i����i�if���)rZCustomOptionMinIntegerValuesrDr=r2rJZbool_optZ	int32_optZ	int64_optZ
uint32_optZ
uint64_optZ
sint32_optZ
sint64_optZfixed32_optZfixed64_optZsfixed32_optZsfixed64_optZCustomOptionMaxIntegerValuesZCustomOptionOtherValuesZassertAlmostEqualZ	float_optZ
double_optZ
string_optZ	bytes_optrSZTEST_OPTION_ENUM_TYPE2Zenum_optZSettingRealsFromPositiveIntsZSettingRealsFromNegativeInts)
r,Z	kint32minZ	kint64minZ	kint32maxZ	kint64maxZ
kuint32maxZ
kuint64maxrWr_Z
dummy_enumr.r.r/�testDifferentCustomOptionTypes�s�

























































z-DescriptorTest.testDifferentCustomOptionTypescCs�tjj}|j�}|jd|jtjj�|jd|jtjjtj�|jd|jtjjtj	j
�|jd|jtjj�|jd|jtjjtj
�|jd|jtjjj�|jd|jtjjjtj�|jd|jtjjjtj	j
�|jd	|jtjjtjj�|jd
|jtjjtjjtj�|jd|jtjjtjjtj	j
�|jd|jtjjjj�|jd
|jtjjj�|jd|jtjj
�|jd|jtjjj�|jd|jtjj�dS)NrAiDili�i�i�i�i�i�i�iIi�iA�	��)rZVariousComplexOptionsrDr=r2rJZcomplex_opt1ZfooZquuxZcorgeZquxZcomplex_opt2ZbazZgraultZbarZgarplyZComplexOptionType2ZComplexOptionType4Zcomplex_opt4ZwaldoZfredZcomplex_opt3Zcomplexoptiontype5ZplughZcomplexopt6Zxyzzy)r,r�optionsr.r.r/�testComplexExtensionOptions sX





















z*DescriptorTest.testComplexExtensionOptionsc	CsJtj}tjj}|jd}tjj}|jd}tjj}|jd�}|j�j	tj
}|jd|j�|jd|j
�|jd|jj
�|jd|jj	tj
j
�|jd|jj	tjjj
�|jd	|j�j	tjj
�|jd
|j�j	tjj
�|jd|j�j	tjj
�|jd|j�j	tjj
�|jd
|j�j	tjj
�|jd|j�j	tjj
�dS)NZ	fieldnameZVALUEZMethodrfZFileAnnotationZNestedFileAnnotationZFileExtensionAnnotationZEmbeddedMessageSetElementZMessageAnnotationZFieldAnnotationZEnumAnnotationZEnumValueAnnotationZServiceAnnotationZMethodAnnotation)rrD�AggregateMessagerEZ
AggregateEnum�values_by_nameZAggregateServicerHr=rJZfileoptr2�i�s�sub�fileZmsetZAggregateMessageSetElementZmessage_set_extension�msgoptZfieldoptZenumoptZ
enumvaloptZ
serviceoptZ	methodopt)	r,rVrWrXrZr[r\r]r^r.r.r/�testAggregateOptionsRsP


z#DescriptorTest.testAggregateOptionscCs�tjjj}|jd|j�jtj�|jd}|jd|j�jtj	�tjj}|j
d}|jd|j�jtj�|jd}|jd|j�jtj
�|jd}|jd	|j�jtj�dS)
Ni��nested_fieldi��
NestedEnumi�ZNESTED_ENUM_VALUEi��nested_extensioni�)rZNestedOptionTyperrDr2r=rJrKrErLr&rOrGrP�extensions_by_namerM)r,Znested_messagerwZ
outer_messageZnested_enumZnested_enum_valueryr.r.r/�testNestedOptions�s 








z DescriptorTest.testNestedOptionscCs(|j|jj|j�|j|jj|j�dS)N)r2r'rtr#r%)r,r.r.r/�testFileDescriptorReferences�sz+DescriptorTest.testFileDescriptorReferencescCs�|j|jjd�|j|jjd�|j|jj|j�|j|jj�|jd|jj�tj	�}|jj
|�|j|jj|j��|jt
jjtj��dS)Nzsome/filename/some.protor
Zproto2)r2r#rrr"rUrTZsyntaxrr�CopyToProtoZ
serialized_pbZSerializeToStringrrDr	r1)r,r-r.r.r/�testFileDescriptor�s

z!DescriptorTest.testFileDescriptor�cpprazAImmutability of descriptors is only enforced in v2 implementationcCCsHtj}tjj}|jd}|jd}|jd}|jt��d|_WdQRX|jt��d|jd<WdQRX|jt��|j	j
d�WdQRX|jt��||_WdQRX|jt��d|_WdQRX|jt��d|_WdQRX|jt��d|_WdQRX|jt��d|_WdQRX|jt��}d|_WdQRX|j
dt|j��dS)N�optional_int32rx�oneof_fieldZAnotherFTz&attribute is not writable: has_options)rrD�TestAllTypesrEr&rFr3�AttributeErrorr5r9�appendr:rTr2�strZ	exception)r,rVrWrXrZrY�er.r.r/�testImmutableCppDescriptor�s2


z)DescriptorTest.testImmutableCppDescriptorN)�__name__�
__module__�__qualname__r0r!r6r8r;r<r>r`rirnrvr{r|r~�unittest�skipIfr�TypeZVersionr�r.r.r.r/r<s"$6^21
rc@seZdZdZdd�ZdS)�NewDescriptorTestzARedo the same tests as above, but with a separate DescriptorPool.cCstj�S)N)r	ZDescriptorPool)r,r.r.r/r!�sz#NewDescriptorTest.GetDescriptorPoolN)r�r�r��__doc__r!r.r.r.r/r��sr�c@sXeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�ZdS)�GeneratedDescriptorTestz:Tests for the properties of descriptors in generated code.cCs�|j|jd�|j|jd�|j||�|j|jdj|�|j||g�|j||di�|j|j�|j|j�|j|j	�|j|j
�|j|j�|j|j�|j|j
�|j|jdj�|j|jg�dS)Nr�zprotobuf_unittest.TestAllTypesr)r2r�	full_namer9r:�assertIn�CheckDescriptorSequence�CheckDescriptorMappingrEZfields_by_number�fields_by_camelcase_namer&rGrF�
enum_typesrp�extension_ranges)r,rWr.r.r/�CheckMessageDescriptor�s"z.GeneratedDescriptorTest.CheckMessageDescriptorcCs�|j|jd�|j|jd�|j|jd�|j|jjd�|j|jtj�|j||�|j|jjd|�|j|jj	d|�|j
||g�|j
||di�|jd|j�|jd|j�t
j�dkr�|j|j|j�dS)Nr��
optionalInt32z-protobuf_unittest.TestAllTypes.optional_int32r�r)r2r�camelcase_namer�r:rtrrDrEr�r�Zextension_scoperrr��id)r,rXr.r.r/�CheckFieldDescriptor�s(
z,GeneratedDescriptorTest.CheckFieldDescriptorcCs�|j|tjjj�|j|g�|j|d�|j|dk�|j||�t|�}|j||�|jt	|�d�|jt	|�t	|��|j|t	|�d|d�|d}|j||d�|j
||�|j|j|�d�|j|j|�d�tj
jjd}|j||�|j|j|�d�|jt|j|�|jt|jg�t|�}|jt|�t|�ddd��|jtt|�d|d<|j||�tj�dk�r�|jtt|��t|��n|jt|�dd�dS)Nrrzchange value�python�<���r�)�assertNotEqualr�TestAllExtensionsrDr9rUr2�list�
assertGreater�lenr��index�countZNestedTestAllTypesZassertNotInr3�
ValueError�reversed�
StopIteration�nextrr�r�)r,ZsequenceZ
expected_list�itemZ
other_itemZreversed_iteratorr.r.r/r�s:z/GeneratedDescriptorTest.CheckDescriptorSequencec
sz�j|tjjj��j|i��j|d��j|dk�tt|j���}�j	||��j	||��j
t|�d��j	t|�t|��tj
dkr�ttt|j����\}}nt|j��d\}}�j||��j	|j|�|��jt��|j�WdQRXtj�dk�r�jt|jg�n�j	d|jg��ttt|j����ttt|j����f}�j	|ttt|j�����tj
d
k�rԇfdd�}|t|j��t|j���|t|j��t|j���|t|j��t|j���d||<�j||�||=d|d	<�j||��jt|jd
��jt|jt|�d�tj�dk�rb�j	tttt|j�����tt|���n�j	t|�dd�dS)Nrr�r�cs0�jt|�|d��jt|�|dd��dS)Nrr)r2r�r�)�seq�iterator)r,r.r/�
CheckItemsBszBGeneratedDescriptorTest.CheckDescriptorMapping.<locals>.CheckItemszchange value�newZnew_keyZ	key_errorr�)r�)r�)r�rr�rDrErU�dictr��itemsr2r�r��sys�version_infor��iterr��getr3r5rr��keysr7r4�__getitem__r�)r,�mappingZ
excepted_dict�keyr�r�r.)r,r/r�$sJ
(*z.GeneratedDescriptorTest.CheckDescriptorMappingcCs�tjj}|j|�|jd}|j|�|jd}|j|�tjjd}|jd|j	�|jtj
jjdg�|jtjjjdd
dg�dS)Nr�r�rr� rA�+�/��)rr�)rAr�)r�r�)r�r�)
rr�rDr�rEr�r�r&r2r:r�r��TestMultipleExtensionRanges)r,rWrXrZr.r.r/�testDescriptorUs 



z&GeneratedDescriptorTest.testDescriptorcCsVtj}|j|j�|j|j�|j|j�|j|j�|j|j�|jtj	jj�dS)N)
rrDr�Zdependenciesr�r$r&r(rzZTestNestedExtension)r,Zcontaining_filer.r.r/�testCppDescriptorContainerhsz2GeneratedDescriptorTest.testCppDescriptorContainercCs0tjjjd}t|j�}~|jdt|�j�dS)Nrx�FOO)	rr�rDr&r�r7r2r�r)r,�enumZvalues_iterr.r.r/�#testCppDescriptorContainer_Iteratorrs
z;GeneratedDescriptorTest.testCppDescriptorContainer_IteratorcCs\tjjd}|j|jd�|j|jdjd�|j|jtj�|j|jd�|j	|j
�dS)N�TestServicerr?)rrDr(r2r�methodsZassertIsrtr�r�r*)r,r\r.r.r/�testServiceDescriptorysz-GeneratedDescriptorTest.testServiceDescriptorcCsZtjj}|jd}|j|j�|j||j�|jd|j�|jd|j	�|jd|j
�dS)Nr�z*protobuf_unittest.TestAllTypes.oneof_fieldr)rr�rDrFrUrTr2r:rr�r�)r,rWrYr.r.r/�testOneofDescriptor�s
z+GeneratedDescriptorTest.testOneofDescriptorN)
r�r�r�r�r�r�r�r�r�r�r�r�r�r.r.r.r/r��s#1
r�c@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zejej�dkd�dd��Zejej�dkd�dd��ZdS) �DescriptorCopyToProtoTestz)Tests for CopyTo functions of Descriptor.cCs4|�}tj||�|j||dt|�t|�f�dS)Nz#Not equal,
Actual:
%s
Expected:
%s
)rZMerger2r�)r,Zactual_protoZexpected_class�expected_asciiZexpected_protor.r.r/�_AssertProtoEqual�sz+DescriptorCopyToProtoTest._AssertProtoEqualcCs"|�}|j|�|j|||�dS)N)r}r�)r,ZdescZexpected_proto_classZexpected_proto_ascii�actualr.r.r/�_InternalTestCopyToProto�s
z2DescriptorCopyToProtoTest._InternalTestCopyToProtocCs|jtjjtjt�dS)N)r�r�TestEmptyMessagerDr�DescriptorProto�#TEST_EMPTY_MESSAGE_DESCRIPTOR_ASCII)r,r.r.r/�testCopyToProto_EmptyMessage�sz6DescriptorCopyToProtoTest.testCopyToProto_EmptyMessagecCsd}|jtjjjtj|�dS)Nz�
      name: 'NestedMessage'
      field: <
        name: 'bb'
        number: 1
        label: 1  # Optional
        type: 5  # TYPE_INT32
      >
      )r�rr�rrDrr�)r,ZTEST_NESTED_MESSAGE_ASCIIr.r.r/�testCopyToProto_NestedMessage�s
	z7DescriptorCopyToProtoTest.testCopyToProto_NestedMessagecCsd}|jtjjtj|�dS)Nz�
      name: 'TestForeignNested'
      field: <
        name: 'foreign_nested'
        number: 1
        label: 1  # Optional
        type: 11  # TYPE_MESSAGE
        type_name: '.protobuf_unittest.TestAllTypes.NestedMessage'
      >
      )r�rZTestForeignNestedrDrr�)r,ZTEST_FOREIGN_NESTED_ASCIIr.r.r/�$testCopyToProto_ForeignNestedMessage�s

z>DescriptorCopyToProtoTest.testCopyToProto_ForeignNestedMessagecCsd}|jtjjtj|�dS)Nz�
      name: 'ForeignEnum'
      value: <
        name: 'FOREIGN_FOO'
        number: 4
      >
      value: <
        name: 'FOREIGN_BAR'
        number: 5
      >
      value: <
        name: 'FOREIGN_BAZ'
        number: 6
      >
      )r�rrrDrZEnumDescriptorProto)r,ZTEST_FOREIGN_ENUM_ASCIIr.r.r/�testCopyToProto_ForeignEnum�s
z5DescriptorCopyToProtoTest.testCopyToProto_ForeignEnumcCsd}|jtjjtj|�dS)Nz�
      name: 'TestDeprecatedFields'
      field: <
        name: 'deprecated_int32'
        number: 1
        label: 1  # Optional
        type: 5  # TYPE_INT32
        options: <
          deprecated: true
        >
      >
      )r�rZTestDeprecatedFieldsrDrr�)r,ZTEST_DEPRECATED_FIELDS_ASCIIr.r.r/�testCopyToProto_Options�s
z1DescriptorCopyToProtoTest.testCopyToProto_OptionscCsd}|jtjjtj|�dS)Nz}
      name: 'TestEmptyMessageWithExtensions'
      extension_range: <
        start: 1
        end: 536870912
      >
      )r�rZTestEmptyMessageWithExtensionsrDrr�)r,Z(TEST_EMPTY_MESSAGE_WITH_EXTENSIONS_ASCIIr.r.r/�testCopyToProto_AllExtensions�s
z7DescriptorCopyToProtoTest.testCopyToProto_AllExtensionscCsd}|jtjjtj|�dS)Na
      name: 'TestMultipleExtensionRanges'
      extension_range: <
        start: 42
        end: 43
      >
      extension_range: <
        start: 4143
        end: 4244
      >
      extension_range: <
        start: 65536
        end: 536870912
      >
      )r�rr�rDrr�)r,Z*TEST_MESSAGE_WITH_SEVERAL_EXTENSIONS_ASCIIr.r.r/�!testCopyToProto_SeveralExtensions�s
z;DescriptorCopyToProtoTest.testCopyToProto_SeveralExtensionscCsd}|jtjtj|�dS)Nad
      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
        >
      >
      a�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
      zG
        cc_enable_arenas: true
      >
      public_dependency: 0
    a�
      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
      a7
      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�rrDrr)r,Z%UNITTEST_IMPORT_FILE_DESCRIPTOR_ASCIIr.r.r/�testCopyToProto_FileDescriptors0z8DescriptorCopyToProtoTest.testCopyToProto_FileDescriptorcCsd}|jtjjtj|�dS)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�rr�rDrZServiceDescriptorProto)r,ZTEST_SERVICE_ASCIIr.r.r/�!testCopyToProto_ServiceDescriptorNs

z;DescriptorCopyToProtoTest.testCopyToProto_ServiceDescriptorr�z It is not implemented in python.cCs&d}tjjjd�}|j|tj|�dS)Nz}
      name: 'Foo'
      input_type: '.protobuf_unittest.FooRequest'
      output_type: '.protobuf_unittest.FooResponse'
    r?)rr�rDrHr�rZMethodDescriptorProto)r,r�r]r.r.r/� testCopyToProto_MethodDescriptoras	z:DescriptorCopyToProtoTest.testCopyToProto_MethodDescriptorz!Pure python does not raise error.cCsbtj�}|jttjjj|�|jttjjj|�|jttj	jj|�tj
�}|jttjj|�dS)N)rrr3r5rr�rDr}rr�r�r)r,r-�protor.r.r/�testCopyToProto_TypeErrorrsz3DescriptorCopyToProtoTest.testCopyToProto_TypeErrorN)r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�r�r�r.r.r.r/r��s$	;

r�c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�MakeDescriptorTestc	
Cs�tj�}d|_|jj�}|j|_|jj�}d|_|jj�}d|_|jj�}d|_d|_|j	j�}d|_d|_t
jj|_
t
jj|_|j	j�}d|_d	|_t
jj|_
t
jj|_d|_|j	j�}d|_d
|_t
jj|_
t
jj|_d|_t
j|�}|j|jdjt
jj�|j|jdjt
jj�|j|jdjj|�|j|jdjdjd
�|j|jdjdj|jdjd�|j|j�|j|jdj�tj �dk�r�|j!t"��d|jd_WdQRXdS)NZFoo2ZSubr��BARr�r�uint64_fieldraZnested_message_field�	bar_fieldzFoo2.Sub.FOOrzFoo2.Sub.bar_fieldrF)#rrrrr�nested_typerrrrr�FieldDescriptor�LABEL_REQUIREDr�TYPE_UINT64rZTYPE_MESSAGE�	type_name�	TYPE_ENUM�MakeDescriptorr2r9�cpp_type�CPPTYPE_UINT64ZCPPTYPE_MESSAGEr:Znested_typesr�r�rUrTrr�r3r�)	r,�file_descriptor_protorr�r�
enum_type_valr�
enum_field�resultr.r.r/�"testMakeDescriptorWithNestedFields�sX















z5MakeDescriptorTest.testMakeDescriptorWithNestedFieldscCs�tj�}d|_|jj�}|j|_|jj�}d|_|jj�}d|_d|_|jj�}d|_d|_t	j
j|_t	j
j
|_|jj�}d|_d|_t	j
j|_t	j
j|_d	|_t	j|�}|j|jd
jt	j
j�dS)Nr?r�r�r�rr�rar�zFoo.FOOr)rrrrrrrrrrr�r�rr�rr�r�r�r2r9r�r�)r,r�rrr�rr�r�r.r.r/�&testMakeDescriptorWithUnsignedIntField�s.









z9MakeDescriptorTest.testMakeDescriptorWithUnsignedIntFieldcCsFtj�}tj}|jj|�tj|�}|j�}|j	d|j
tjj�dS)N�e)
rr�rrorDr}rr�r=r2rJrurq)r,�descriptor_protoZaggregate_messageZreformed_descriptorrmr.r.r/�testMakeDescriptorWithOptions�s
z0MakeDescriptorTest.testMakeDescriptorWithOptionscCs�tj�}d|_dddddg}dddddg}x2tt|��D]"}|jj�}|d|_|||_q8Wtj	|�}x,tt|��D]}|j
|j|j||�qvWdS)	NZBarZfoo_fooZFooBarZfooBazZfooFooZfoobarZfooBarr)
rr�r�ranger�rrrrr�r2r9r�)r,r��namesZcamelcase_namesr�rr�r.r.r/�testCamelcaseName�s


z$MakeDescriptorTest.testCamelcaseNamecCs�tj�}d|_ddddddg}dddddd	g}x2tt|��D]"}|jj�}|d
|_|||_q<Wd	|_t	j
|�}x,tt|��D]}|j|j|j||�q�WdS)NZTestJsonNameZ
field_nameZ	fieldNameZ	FieldNameZ_field_nameZ
FIELD_NAME�	json_nameZ	FIELDNAMEz@typer)
rr�rr�r�rrrr�rr�r2r9)r,r�r�Z
json_namesr�rr�r.r.r/�testJsonName�s




zMakeDescriptorTest.testJsonNameN)r�r�r�r�r�r�r�r�r.r.r.r/r��s
/
r��__main__)r��
__author__r�Z	unittest2r��ImportErrorZgoogle.protobufrrrrZgoogle.protobuf.internalrrrr	r
rr�ZTestCaserr�r�r�r�r��mainr.r.r.r/�<module> s:?|v