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__/generator_test.cpython-36.pyc
3

���h�9�@s�dZdZyddlZWnek
r0ddlZYnXddlmZddlmZddlm	Z	ddlm
Z
ddlmZdd	lmZdd
lm
Z
ddlmZddlmZdd
lmZdZGdd�dej�ZGdd�dej�Zedkr�ej�dS)z�Unittest that directly tests the output of the pure-Python protocol
compiler.  See //google/protobuf/internal/reflection_test.py for a test which
further ensures that we can use Python protocol message objects as we expect.
z#robinson@google.com (Will Robinson)�N)�test_bad_identifiers_pb2)�unittest_custom_options_pb2)�unittest_import_pb2)�unittest_import_public_pb2)�unittest_mset_pb2)�unittest_mset_wire_format_pb2)� unittest_no_generic_services_pb2)�unittest_pb2)�service)�symbol_databasei c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-S).�
GeneratorTestcCs(d}tj}|j|jj|jj|j�dS)N�optional_nested_message)r	�TestAllTypes�assertEqual�
NestedMessage�
DESCRIPTOR�fields_by_nameZmessage_type)�self�
field_nameZ
proto_type�r�$/usr/lib/python3.6/generator_test.py�testNestedMessageDescriptor@s
z)GeneratorTest.testNestedMessageDescriptorcCs�|jdtj�|jdtj�|jdtj�tj�}|jd|j�|jdtjj�|jd|j�|jdtjj�|jd|j�|jdtjj�dS)N������)	rr	ZFOREIGN_FOOZFOREIGN_BARZFOREIGN_BAZr�FOOZBARZBAZ)r�protorrr�	testEnumsGszGeneratorTest.testEnumscs�tj�}dd���fdd�}|j||j��|j|jdk�|j||j��|j|jdk�|j�|j��|j||j��|j|jdk�|j||j��|j|jdk�|j�|j��|j	d|j
�dS)NcSs||kS)Nr)�valrrr�isnan\sz5GeneratorTest.testExtremeDefaultValues.<locals>.isnancs�|�o�|d�S)Nrr)r!)r"rr�isinf_sz5GeneratorTest.testExtremeDefaultValues.<locals>.isinfrz? ? ?? ?? ??? ??/ ??-)r	ZTestExtremeDefaultValues�
assertTrueZ
inf_doubleZneg_inf_doubleZ
nan_doubleZ	inf_floatZ
neg_inf_floatZ	nan_floatrZcpp_trigraph)r�messager#r)r"r�testExtremeDefaultValuesWsz&GeneratorTest.testExtremeDefaultValuescs>tjj}ddddd��t�fdd�|jD��}|j�|�dS)NFT)Zoptional_int32Zrepeated_int32r
Z
default_int32cs"g|]}|j�kr|j|jf�qSr)�nameZhas_default_value)�.0�f)�expected_has_default_by_namerr�
<listcomp>{sz6GeneratorTest.testHasDefaultValues.<locals>.<listcomp>)r	rr�dict�fieldsr)r�descZhas_default_by_namer)r*r�testHasDefaultValuesps
z"GeneratorTest.testHasDefaultValuescCs.|jtjjtjj�|jtjjjtjj�dS)N)rr	�optional_int32_extension�containing_type�TestAllExtensionsr�TestRequired�single)rrrr�'testContainingTypeBehaviorForExtensions�s

z5GeneratorTest.testContainingTypeBehaviorForExtensionscCs*|jtjjd�|jtjjjtjj�dS)N)rr	r0Zextension_scoper3r4r)rrrr�testExtensionScope�s
z GeneratorTest.testExtensionScopecCsB|jtjj�|jtjjj�tjj}|jd}|j|j�dS)N�a)r$r	r0Zis_extensionr3r4rr)rZmessage_descriptorZnon_extension_descriptorrrr�testIsExtension�s

zGeneratorTest.testIsExtensioncCstj�}|j|jj�j�dS)N)rZTestMessageSetr$r�
GetOptionsZmessage_set_wire_format)rrrrr�testOptions�szGeneratorTest.testOptionscCs*tj�}|jjdj�}|j|dk	�dS)NZAnEnum)rZTestMessageWithCustomOptionsr�enum_types_by_namer9r$)rrZenum_optionsrrr�testMessageWithCustomOptions�sz*GeneratorTest.testMessageWithCustomOptionscCs\|jttjjj�ttjjjtjjjtjjjg��|jtj	jjg�|jtjjjjg�dS)N)
r�setr	rrZnested_typesr�
OptionalGroup�
RepeatedGroup�TestEmptyMessage)rrrr�testNestedTypes�szGeneratorTest.testNestedTypescCst|jtjjjdk�|jtjjjdk�|jtjjjjtjj�|jtjjjjtjj�|jtjjjjtjj�dS)N)	r$r	r@rr1rrrr?)rrrr�testContainingType�s




z GeneratorTest.testContainingTypecCs*|jtjjdk�|jtjjtjj�dS)N)r$r	�_FOREIGNENUMr1r�_TESTALLTYPES_NESTEDENUMrr)rrrr�"testContainingTypeInEnumDescriptor�s
z0GeneratorTest.testContainingTypeInEnumDescriptorcCs||jtjjjjd�tjjj}|j|jjd�|jtjjjjd�|jtj	jjd�|jtj
jjd�|jtjjjd�dS)N�protobuf_unittestZprotobuf_unittest_import)rr	rr�file�packagerrZ
ImportMessagerCrDZ_IMPORTENUM)rr.rrr�testPackage�s 


zGeneratorTest.testPackagecCsJ|jtjjjg�|jtjjjdtfg�|jtjjjdddtfg�dS)	Nr�*�+�/�i)rJrK)rLrM)rr	rrZextension_rangesr2�
MAX_EXTENSIONZTestMultipleExtensionRanges)rrrr�testExtensionRange�sz GeneratorTest.testExtensionRangecCsr|jtjjd�|jtjjd�|jtjjdk�|jtjjtjg�|jtjjt	jg�|jtjj
t	jg�dS)Nzgoogle/protobuf/unittest.protorF)rr	rr'rH�assertFalseZ
serialized_pbZdependenciesrrZpublic_dependencies)rrrr�testFileDescriptor�s





z GeneratorTest.testFileDescriptorcCsR|jttd��|jttd��|jttd��ttd�rN|jttjtj��dS)NZTestMessagerZtest_extension�TestService)r$�hasattrrrP�
issubclassrRr
ZService)rrrr�testNoGenericServices�s

z#GeneratorTest.testNoGenericServicescCs6tj}|jtj|jtjj�|jtjj|jk�dS)N)r	rrZ
_TESTALLTYPESZmessage_types_by_namer'rPZ_TESTALLTYPES_NESTEDMESSAGE)r�	file_typerrr�testMessageTypesByName�sz$GeneratorTest.testMessageTypesByNamecCs"tj}|jtj|jtjj�dS)N)r	rrrCr;r')rrVrrr�testEnumTypesByName�sz!GeneratorTest.testEnumTypesByNamecCs"tj}|jtj|jtjj�dS)N)r	rrZmy_extension_stringZextensions_by_namer')rrVrrr�testExtensionsByNamesz"GeneratorTest.testExtensionsByNamecCsDtj�}|jd|jj�tj�}|jd|j�|jtjtjk�dS)Nr)	r	rrZoptional_public_import_message�erZPublicImportMessager$r)rZall_type_protoZpublic_import_protorrr�testPublicImports
szGeneratorTest.testPublicImportscCs\tj�}|j|jtjd�|j|jtjd�|j|jtjd�|j|jtjd�dS)NZfooZbarZbazZqux)rZTestBadIdentifiersrZ
Extensionsr%Z
descriptorZ
reflectionr
)rr%rrr�testBadIdentifierssz GeneratorTest.testBadIdentifierscCs�tjj}|jdt|j��|jd|jdj�|jd|jdj�|j||jdj	�|j|jd|j
d�tddddg�}|j|tdd	�|jdjD���xDt
|jj��D]2\}}||kr�|j|jd|j�q�|j|j�q�WdS)
NrZoneof_fieldrZoneof_uint32Zoneof_nested_messageZoneof_stringZoneof_bytescSsg|]
}|j�qSr)r')r(Zfieldrrrr+-sz+GeneratorTest.testOneof.<locals>.<listcomp>)r	rrr�lenZoneofsr'�indexZassertIsr1Zoneofs_by_namer=r-�listr�itemsZcontaining_oneofZassertIsNone)rr.Znested_namesrZ
field_descrrr�	testOneof"s
zGeneratorTest.testOneofN)�__name__�
__module__�__qualname__rr r&r/r5r6r8r:r<rArBrErIrOrQrUrWrXrYr[r\rarrrrr>s,
rc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�SymbolDatabaseRegistrationTestz?Checks that messages, enums and files are correctly registered.cCs�|jtjtj�jd��|jtjjtj�jd��|jt��tj�jd�WdQRX|jtjj	tj�jd��|jtjj
tj�jd��dS)Nzprotobuf_unittest.TestAllTypesz,protobuf_unittest.TestAllTypes.NestedMessagezprotobuf_unittest.NestedMessagez,protobuf_unittest.TestAllTypes.OptionalGroupz,protobuf_unittest.TestAllTypes.RepeatedGroup)rr	rr�DefaultZ	GetSymbolrZassertRaises�KeyErrorr>r?)rrrr�
testGetSymbol8s"z,SymbolDatabaseRegistrationTest.testGetSymbolcCs8|jdtj�jjd�j�|jdtj�jjd�j�dS)Nzprotobuf_unittest.ForeignEnumz)protobuf_unittest.TestAllTypes.NestedEnum)rrrf�poolZFindEnumTypeByNameZ	full_name)rrrrr Ks


z(SymbolDatabaseRegistrationTest.testEnumscCs|jdtj�jjd�j�dS)Nzgoogle/protobuf/unittest.proto)rrrfriZFindFileByNamer')rrrr�testFindFileByNameUs
z1SymbolDatabaseRegistrationTest.testFindFileByNameN)rbrcrd�__doc__rhr rjrrrrre5s
re�__main__)rk�
__author__Z	unittest2Zunittest�ImportErrorZgoogle.protobuf.internalrZgoogle.protobufrrrrrrr	r
rrNZTestCaserrerb�mainrrrr�<module>'s*x&