__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

aptanhua@216.73.216.200: ~ $
3

���hnV�@s(dZdZddlZddlZddlZddlZddlZddlZddlZddl	Z	yddl
ZWnek
rpddlZYnXye
Wnek
r�dd�Z
YnXddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZej �rXe!Z"dd�Z#dd�Z$dd�Z%dd�Z&ej'Z'ej(defdef�Gdd �d e'��Z)Gd!d"�d"e'�Z*Gd#d$�d$e'�Z+Gd%d&�d&e'�Z,Gd'd(�d(e'�Z-ej.ej/�d)k�p�ej0d0kd,�Gd-d.�d.e'��Z1e2d/k�r$ej3�dS)1a�Tests python protocol buffers against the golden message.

Note that the golden messages exercise every known field type, thus this
test ends up exercising and verifying nearly all of the parsing and
serialization code in the whole library.

TODO(kenton):  Merge with wire_format_test?  It doesn't make a whole lot of
sense to call this a test of the "message" module, which only declares an
abstract interface.
z!gps@google.com (Gregory P. Smith)�NcCs||k||kS)N�)�x�yrr�"/usr/lib/python3.6/message_test.py�<lambda>>sr)�map_proto2_unittest_pb2)�map_unittest_pb2)�unittest_pb2)�unittest_proto3_arena_pb2)�descriptor_pb2)�descriptor_pool)�message_factory)�text_format)�api_implementation)�encoder)�packed_field_test_pb2)�	test_util)�testing_refleaks)�message)�_parameterizedcCs||kS)Nr)�valrrr�isnanVsrcCst|�ot|d�S)Nr)r)rrrr�isinfYsrcCst|�o|dkS)Nr)r)rrrr�IsPosInf\srcCst|�o|dkS)Nr)r)rrrr�IsNegInf^srZ_proto2Z_proto3c
@s8eZdZdd�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-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Z d=d>�Z!d?d@�Z"dAdB�Z#dCdD�Z$dEdF�Z%dGdH�Z&dIdJ�Z'dKdL�Z(dMdN�Z)dOdP�Z*dQdR�Z+dSdT�Z,dUdV�Z-dWdX�Z.dYdZ�Z/d[d\�Z0d]d^d_d`dadbe1�gie2�g
Z3dcdd�Z4dedf�Z5dgdh�Z6didj�Z7dkdl�Z8dmdn�Z9dodp�Z:Gdqdr�dre;�Z<dsdt�Z=dudv�Z>dwdx�Z?dydz�Z@d{d|�ZAd}d~�ZBdd��ZCd�d��ZDd�d��ZEd�d��ZFd�d��ZGd]S)��MessageTestcCsXtj�dkr|jd�tjd�}|jt��}|jj|�WdQRX|j	dt
|j��dS)N�pythonz�Skipping testBadUtf8String, currently only the python api implementation raises UnicodeDecodeError when a string field contains bad utf-8.Zbad_utf8_stringzTestAllTypes.optional_string)r�TypeZskipTestr�GoldenFileData�assertRaises�UnicodeDecodeError�TestAllTypes�
FromString�assertIn�str�	exception)�self�message_moduleZ
bad_utf8_data�contextrrr�testBadUtf8Stringjs

zMessageTest.testBadUtf8StringcCsr|tkrtjd�}n
tjd�}|j�}|j|�|tkrDtj||�|j||j��tj	|�}|j||j��dS)NZ golden_message_oneof_implementedZgolden_message_proto3)
r	rrr!�ParseFromStringZExpectAllFieldsSet�assertEqual�SerializeToString�copy�deepcopy)r&r'�golden_data�golden_message�golden_copyrrr�testGoldenMessagets


zMessageTest.testGoldenMessagecCshtjd�}|j�}|j|�|j�}tj|�|j||�|j||j��tj|�}|j||j��dS)N�golden_packed_fields_message)	rr�TestPackedTypesr*ZSetAllPackedFieldsr+r,r-r.)r&r'r/r0�all_setr1rrr�testGoldenPackedMessage�s



z#MessageTest.testGoldenPackedMessagecCs�|j�}|jt|jd�|jt|jd�tjdd�}tj�dkrv|jt	j
��}|j|�WdQRX|jdt|j
��nBtjdd��0}tjd	�|j|�|jd
t|dj	��WdQRXdS)Nr�0��rzUnexpected end-group tag.T)�record�alwaysz4Unexpected end-group tag: Not all data was converted���)r!r�	TypeErrorr"�	ExceptionrZTagBytesrrr�DecodeErrorr+r$r%�warnings�catch_warnings�simplefilter)r&r'�msgZend_tagr(�wrrr�testParseErrors�s

zMessageTest.testParseErrorsc
s�d}|j�}|jjddddg�|j||jdd��|j||jdd��|j||jdd��Gd	d
�d
t��G�fdd�dt�}|j���|j|�d�WdQRXdS)
Ns5�
One string�
Two string�
Red string�Blue stringz
One stringz
Two stringz
Red stringzBlue string)�
deterministicFTc@seZdZdS)z:MessageTest.testDeterminismParameters.<locals>.BadArgErrorN)�__name__�
__module__�__qualname__rrrr�BadArgError�srJcs$eZdZ�fdd�Z�fdd�ZdS)z5MessageTest.testDeterminismParameters.<locals>.BadArgcs
���dS)Nr)r&)rJrr�__bool__�sz>MessageTest.testDeterminismParameters.<locals>.BadArg.__bool__cs
���dS)Nr)r&)rJrrrK�sN)rGrHrIrKr)rJrr�BadArg�srL)r!�repeated_string�extendr+r,r>�objectr)r&r'r/r0rLr)rJr�testDeterminismParameters�s"z%MessageTest.testDeterminismParameterscCs@tjd�}|j�}|j|�tj|�}tj|�}|j||�dS)Nr0)rrr!r*�pickle�dumps�loadsr+)r&r'r/r0�pickled_message�unpickled_messagerrr�testPickleSupport�s



zMessageTest.testPickleSupportcCs�|tkrd}nd}|j�}|j|�|jt|j��|jt|j��|jt|jd��|jt|jd��|j	||j
��dS)Ns]�a�����s ]�a�����r)r	r!r*�
assertTruer�optional_float�optional_double�repeated_float�repeated_doubler+r,)r&r'r/r0rrr�testPositiveInfinity�s
z MessageTest.testPositiveInfinitycCs�|tkrd}nd}|j�}|j|�|jt|j��|jt|j��|jt|jd��|jt|jd��|j	||j
��dS)Ns]��a������s ]��a������r)r	r!r*rWrrXrYrZr[r+r,)r&r'r/r0rrr�testNegativeInfinity�s
z MessageTest.testNegativeInfinitycCs�d}|j�}|j|�|jt|j��|jt|j��|jt|jd��|jt|jd��|j�}|j�}|j|�|jt|j��|jt|j��|jt|jd��|jt|jd��dS)Ns]�a�����r)	r!r*rWrrXrYrZr[r,)r&r'r/r0�
serializedrrrr�testNotANumber�s

zMessageTest.testNotANumbercCsRd}|j�}|j|�|jt|jd��|jt|jd��|j||j��dS)Ns����r)r4r*rWr�packed_float�
packed_doubler+r,)r&r'r/r0rrr�testPositiveInfinityPackeds
z&MessageTest.testPositiveInfinityPackedcCsRd}|j�}|j|�|jt|jd��|jt|jd��|j||j��dS)Ns�����r)r4r*rWrr`rar+r,)r&r'r/r0rrr�testNegativeInfinityPackeds
z&MessageTest.testNegativeInfinityPackedcCs�d}|j�}|j|�|jt|jd��|jt|jd��|j�}|j�}|j|�|jt|jd��|jt|jd��dS)Ns����r)r4r*rWrr`rar,)r&r'r/r0r^rrrr�testNotANumberPacked%s

z MessageTest.testNotANumberPackedcCst|j�}tjdd�}||_|j|j��|j|j|k�dtjdd�}||_|j|j��|j|j|k�||_|j|j��|j|j|k�||_|j|j��|j|j|k�tjdd�}||_|j|j��|j|j|k�dtjdd�}||_|j|j��|j|j|k�||_|j|j��|j|j|k�||_|j|j��|j|j|k�dS)N��g�?i����i����)r!�math�powrXr*r,rW)r&r'r�kMostPosExponentNoSigBits�kMostPosExponentOneSigBit�kMostNegExponentNoSigBits�kMostNegExponentOneSigBitrrr�testExtremeFloatValues3s:z"MessageTest.testExtremeFloatValuescCst|j�}tjdd�}||_|j|j��|j|j|k�dtjdd�}||_|j|j��|j|j|k�||_|j|j��|j|j|k�||_|j|j��|j|j|k�tjdd�}||_|j|j��|j|j|k�dtjdd�}||_|j|j��|j|j|k�||_|j|j��|j|j|k�||_|j|j��|j|j|k�dS)Nrei�g�?i���i���)r!rgrhrYr*r,rW)r&r'rrirjrkrlrrr�testExtremeDoubleValues`s:z#MessageTest.testExtremeDoubleValuescCs"|j�}d|_|jt|�d�dS)Ng@zoptional_float: 2.0
)r!rXr+r$)r&r'rrrr�testFloatPrinting�szMessageTest.testFloatPrintingcCs>|j�}d|_tjdkr*|jt|�d�n|jt|�d�dS)Ng^!�7ݚ�?�z%optional_double: 0.12345678912345678
z optional_double: 0.123456789123
)rp)r!rY�sys�version_infor+r$)r&r'rrrr�testHighPrecisionFloatPrinting�s

z*MessageTest.testHighPrecisionFloatPrintingcCs<|j�}tj|�|j�}|j|j��|jt|�d�dS)N�)r!rZSetAllNonLazyFieldsZTestEmptyMessager*r,r+r$)r&r'Z	populated�emptyrrr�testUnknownFieldPrinting�s

z$MessageTest.testUnknownFieldPrintingcCs�|j�}|jjdd�|jjdd�|jjdd�|jjdd�|jddddgdd�|jD��|jddddgdd�t|j�D��|jddddgd	d�|jddd
�D��dS)Nr8)�bbrerpr9cSsg|]
}|j�qSr)rw)�.0�mrrr�
<listcomp>�sz@MessageTest.testRepeatedNestedFieldIteration.<locals>.<listcomp>cSsg|]
}|j�qSr)rw)rxryrrrrz�scSsg|]
}|j�qSr)rw)rxryrrrrz�sr<)r!�repeated_nested_message�addr+�reversed)r&r'rCrrr� testRepeatedNestedFieldIteration�sz,MessageTest.testRepeatedNestedFieldIterationcCs�|j�}|jjd�|jjd�|jjd�|jj�|j|jdd�|j|jdd�|j|jdd�|jt|j�tdddg��|jjd�|jjd�|jjd�|jj�|j|jdd�|j|jdd�|j|jdd�|jjd�|jjd	�|jjd
�|jj�|j|jdd�|j|jdd
�|j|jdd	�|jt|j�tdd
d	g��|j	jd�|j	jd�|j	jd
�|j	j�|j|j	dd�|j|j	dd
�|j|j	dd�|jt|j	�tdd
dg��dS)z7Check some different types with the default comparator.r8rprerg�������?g�������?g333333�?�a�c�b�a�c�bN)
r!�repeated_int32�append�sortr+r$rZ�assertAlmostEqualrMZrepeated_bytes)r&r'rrrr�0testSortingRepeatedScalarFieldsDefaultComparator�s@



z<MessageTest.testSortingRepeatedScalarFieldsDefaultComparatorcCs�|j�}|jjd
�|jjd�|jjd�|jjtd�|j|jdd
�|j|jdd�|j|jdd�|jjd�|jjd�|jjd�|jjtd�|j|jdd�|j|jdd�|j|jdd�d	S)z2Check some different types with custom comparator.rprer8)�keyr�aaarwr�N������r<r<r�r�)r!r�r�r��absr+rM�len)r&r'rrrr�/testSortingRepeatedScalarFieldsCustomComparator�sz;MessageTest.testSortingRepeatedScalarFieldsCustomComparatorcCs�|j�}d|jj�_d|jj�_d|jj�_d|jj�_d|jj�_d|jj�_|jjtjd�d�|j|jd	jd�|j|jdjd�|j|jdjd�|j|jdjd�|j|jdjd�|j|jdjd�|jt|j�d
�dS)zECheck passing a custom comparator to sort a repeated composite field.r8rpre��r9rw)r�rz0[bb: 1
, bb: 2
, bb: 3
, bb: 4
, bb: 5
, bb: 6
]N)	r!r{r|rwr��operator�
attrgetterr+r$)r&r'rrrr�2testSortingRepeatedCompositeFieldsCustomComparator�s z>MessageTest.testSortingRepeatedCompositeFieldsCustomComparatorcCs�|j�}d|jj�_d|jj�_d|jj�_d|jj�_d|jj�_d|jj�_d|jj�_|jjdd	�d
�|jdddddddgdd�|jD��|j�}|j�|j|�|jdddddddgd
d�|jD��dS)zECheck passing a custom comparator to sort a repeated composite field.���
�!���
cSs
|jdS)Nr�)rw)�zrrrr
szFMessageTest.testSortingRepeatedCompositeFieldsStable.<locals>.<lambda>)r�cSsg|]
}|j�qSr)rw)rx�nrrrrz
szHMessageTest.testSortingRepeatedCompositeFieldsStable.<locals>.<listcomp>cSsg|]
}|j�qSr)rw)rxr�rrrrzsN)	r!r{r|rwr�r+r,�ClearZMergeFromString)r&r'r�pbrrr�(testSortingRepeatedCompositeFieldsStable�s$
z4MessageTest.testSortingRepeatedCompositeFieldsStablecCs@|j�}tjd�}dd�}d|jj�_d|jj�_d|jj�_d|jj�_d|jj�_d	|jj�_|jj|d
�|jdd�|jD�dddd	ddg�|jj|d
d�|jdd�|jD�ddd	dddg�tj	dkr�dS|jj|d�|jdd�|jD�dddd	ddg�|jj|d
d�|jdd�|jD�ddd	dddg�dS)zECheck sorting a repeated composite field using list.sort() arguments.rwcSst|j|j�S)N)�cmprw)rr�rrrrszEMessageTest.testRepeatedCompositeFieldSortArguments.<locals>.<lambda>r8rprer�r�r9)r�cSsg|]
}|j�qSr)rw)rx�krrrrz%szGMessageTest.testRepeatedCompositeFieldSortArguments.<locals>.<listcomp>T)r��reversecSsg|]
}|j�qSr)rw)rxr�rrrrz(sN)�
sort_functioncSsg|]
}|j�qSr)rw)rxr�rrrrz,s)r�r�cSsg|]
}|j�qSr)rw)rxr�rrrrz/s)rp)
r!r�r�r{r|rwr�r+rqrr)r&r'rZget_bbZcmp_bbrrr�'testRepeatedCompositeFieldSortArgumentss.

z3MessageTest.testRepeatedCompositeFieldSortArgumentscCs�|j�}|jjd�|jjd�|jjd�|jjtd�|jt|j�dddg�|jjtdd�|jt|j�dddg�tjdkr�dd�}|jj|d	�|jt|j�dddg�|jj|dd
�|jt|j�dddg�|j	jd�|j	jd�|j	jd
�|j	jt
d�|jt|j	�d
ddg�|j	jt
dd�|jt|j	�ddd
g�tjd k�r�dd�}|j	j|d	�|jt|j	�d
ddg�|j	j|dd
�|jt|j	�ddd
g�dS)!z9Check sorting a scalar field using list.sort() arguments.rprer8)r�T)r�r�cSstt|�t|��S)N)r�r�)rr�rrrr>szBMessageTest.testRepeatedScalarFieldSortArguments.<locals>.<lambda>)r�)r�r�r�rwr�cSstt|�t|��S)N)r�r�)rr�rrrrLsNr�r�r<r<r�r�r�r�r<)rpr<r�r�r�r�r<)rp)r!r�r�r�r�r+�listrqrrrMr�)r&r'rZabs_cmpZlen_cmprrr�$testRepeatedScalarFieldSortArguments2s6
z0MessageTest.testRepeatedScalarFieldSortArgumentscCsJ|j�}|j�}|jjd�|jjd�|jjd�|jjd�|jjd�|jjd�d|jj�_d|jj�_d|jj�_d|jj�_d|jj�_d|jj�_tjdkr�dS||k}|j|jk}|jt	||�d�|jt	|j|j�d�|jt	|jdddg�d�|jt	|j|j�d�|j
t��t	|j|jdd��WdQRXdS)Nrr8rerp)rp)r!r�r�r{r|rwrqrrr+r�rr=)r&r'�m1�m2�_rrr�testRepeatedFieldsComparableRs2

z(MessageTest.testRepeatedFieldsComparablecCs,|j�}|j|jtj�|j|jtj�dS)N)r!�assertIsInstancer��collections�MutableSequencer{)r&r'ryrrr�testRepeatedFieldsAreSequencesusz*MessageTest.testRepeatedFieldsAreSequencescCsL|j�}|jt��t|j�WdQRX|jt��t|j�WdQRXdS)N)r!rr=�hashr�r{)r&r'ryrrr�testRepeatedFieldsNotHashable{s
z)MessageTest.testRepeatedFieldsNotHashablecCs*|j�}|jjjg�|j|jd��dS)N�payload)�NestedTestAllTypesr�r�rNrW�HasField)r&r'ryrrr�$testRepeatedFieldInsideNestedMessage�sz0MessageTest.testRepeatedFieldInsideNestedMessagecCst||�|j|j|��dS)z�Make sure that a nested message object exists.

    As soon as a nested message attribute is accessed, it will be present in the
    _fields dict, without being marked as actually being set.
    N)�getattr�assertFalser�)r&rCZ	attributerrr�ensureNestedMessageExists�s
z%MessageTest.ensureNestedMessageExistscCs,|j�}|jt|jd�|jt|jd�dS)NZno_such_oneof_fieldr)r!r�
ValueError�
WhichOneofr>)r&r'ryrrr� testOneofGetCaseNonexistingField�sz,MessageTest.testOneofGetCaseNonexistingFieldcCs�|j�}|jd|jd��|j|jd��d|_|jd|jd��|j|jd��|j|jd��d|_|jd|jd��|j|jd��|j|jd��dS)N�oneof_field�oneof_uint32r�oneof_stringrt)	r!�assertIsr�r�r�r�r+rWr�)r&r'ryrrr�testOneofDefaultValues�sz"MessageTest.testOneofDefaultValuescCsb|j�}|jd|jd��d|_|jd|jd��|j|jd��d|_|jd|jd��|j|jd��|j|jd��|j	|jd|jd��|j|jd��|j|jd��|j	j
|jd|jd��|j|jd��|j|jd��d|j	_
|jd|jd��|j|jd��|j|jd��d|_|jd|jd��|j|jd��|j|jd��dS)	Nr�r�r��foor��oneof_nested_messagesbb�oneof_bytes)r!r�r�r�r+rWr�r�r�r�rwr�)r&r'ryrrr�testOneofSemantics�s2zMessageTest.testOneofSemanticscCs>|j�}d|_|j|d�|jd|jd��|jd|j�dS)Nr�r�r�r�)r!r�r�r+r�)r&r'ryrrr�!testOneofCompositeFieldReadAccess�s
z-MessageTest.testOneofCompositeFieldReadAccesscCs�|j�}|jd|jd��|tkr2|j|jd��d|_|jd|jd��|tkrb|j|jd��d|_	|jd|jd��|j
d�|jd|jd��|tkr�|j|jd��dS)Nr�r�r�sbbr�)r!r�r�r	r�r�r�r+rWr��
ClearField)r&r'ryrrr�testOneofWhichOneof�s
zMessageTest.testOneofWhichOneofcCsV|j�}d|_|jd�|tkr0|j|jd��|j|jd��|jd|jd��dS)Nr�r�r�)r!r�r�r	r�r�r�r�)r&r'ryrrr�testOneofClearField�s
zMessageTest.testOneofClearFieldcCsV|j�}d|_|jd�|tkr0|j|jd��|j|jd��|jd|jd��dS)Nr�r�r�)r!r�r�r	r�r�r�r�)r&r'ryrrr�testOneofClearSetField�s
z"MessageTest.testOneofClearSetFieldcCsp|j�}d|_|j|d�|jd�|jd|j�|tkrJ|j|jd��|j|jd��|jd|jd��dS)Nr�r�r�r�)	r!r�r�r�r+r	rWr�r�)r&r'ryrrr�testOneofClearUnsetField�s
z$MessageTest.testOneofClearUnsetFieldcCs:|j�}d|_|j�}|j|j��|jd|jd��dS)Nr�r�r�)r!r�r*r,r+r�)r&r'ryr�rrr�testOneofDeserializes
z MessageTest.testOneofDeserializecCs6|j�}d|_|j�}|j|�|jd|jd��dS)Nr�r�r�)r!r��CopyFromr+r�)r&r'ryr�rrr�testOneofCopyFroms

zMessageTest.testOneofCopyFromcCsb|j�}d|j_|j�}d|j_d|jj_|j|�|jd|jjd��|jd|jjjd��dS)Nr�sbbr�r�r�)r�r�r�r��child�	MergeFromr+r�)r&r'ryr�rrr�testOneofNestedMergeFroms

z$MessageTest.testOneofNestedMergeFromcCsf|j�}d|jj_d|jjj_|j�}d|j_|j|�|jd|jjd��|jd|jjjd��dS)Nr��r�r�r�)	r�r�r�rwr�r�r�r+r�)r&r'ryr�rrr�testOneofMessageMergeFroms

z%MessageTest.testOneofMessageMergeFromcCs(|j|jj�d�}|jd|jd��dS)N)r�r�r�)r!�
NestedMessager+r�)r&r'ryrrr�testOneofNestedMessageInit$sz&MessageTest.testOneofNestedMessageInitcCsB|j�}d|_|j�|j|jd��d|_|jd|jd��dS)Nr�r�sbbr�)r!r�r��assertIsNoner�r�r+)r&r'ryrrr�testOneofClear)szMessageTest.testOneofClearcCs&|j�}td�|_|j|jtj�dS)zmAssigning a byte string to a string field should result
    in the value being converted to a Unicode string.rtN)r!r$�optional_stringr��six�	text_type)r&r'ryrrr�"testAssignByteStringToUnicodeField1s
z.MessageTest.testAssignByteStringToUnicodeFieldcCs�|j�}|jjd�|jtd�tt|j���}|jt|j�t|��d|jj�_|jtd�tt|j���}|jt|j�t|��dS)z|It should be possible to use long-valued indicies in slices

    This didn't used to work in the v2 C++ implementation.
    r8rrpN)	r!r�r��intr�r+r{r|rw)r&r'ryZslrrr�testLongValuedSlice8szMessageTest.testLongValuedSlicecCsl|j�}|jt�� }|jjdd�td�D��WdQRX|jt�� }|jjdd�td�D��WdQRXdS)z5This didn't use to work in the v2 C++ implementation.css|]
}tVqdS)N)r)rx�irrr�	<genexpr>MszCMessageTest.testExtendShouldNotSwallowExceptions.<locals>.<genexpr>r�Ncss|]
}tVqdS)N)r)rxr�rrrr�Ps)r!r�	NameErrorr�rN�range�repeated_nested_enum)r&r'ryr�rrr�$testExtendShouldNotSwallowExceptionsIs$z0MessageTest.testExtendShouldNotSwallowExceptionsNFrg�rtcCs^|j�}|jg|j�x(tjD]}|jj|�|jg|j�qW|jjg�|jg|j�dS)z,Test no-ops extending repeated int32 fields.N)r!�assertSequenceEqualr�r�FALSY_VALUESrN)r&r'ry�falsy_valuerrr�testExtendInt32WithNothingTsz&MessageTest.testExtendInt32WithNothingcCs^|j�}|jg|j�x(tjD]}|jj|�|jg|j�qW|jjg�|jg|j�dS)z,Test no-ops extending repeated float fields.N)r!r�rZrr�rN)r&r'ryr�rrr�testExtendFloatWithNothingasz&MessageTest.testExtendFloatWithNothingcCs^|j�}|jg|j�x(tjD]}|jj|�|jg|j�qW|jjg�|jg|j�dS)z-Test no-ops extending repeated string fields.N)r!r�rMrr�rN)r&r'ryr�rrr�testExtendStringWithNothingnsz'MessageTest.testExtendStringWithNothingcCs�|j�}|jg|j�|jjdg�|jdg|j�|jjddg�|jdddg|j�|jjddg�|jdddddg|j�dS)z7Test extending repeated int32 fields with python lists.rr8rerpr9N)r!r�r�rN)r&r'ryrrr�testExtendInt32WithPythonList{sz)MessageTest.testExtendInt32WithPythonListcCs�|j�}|jg|j�|jjdg�|jdg|j�|jjddg�|jdddg|j�|jjddg�|jdddddg|j�dS)z7Test extending repeated float fields with python lists.gg�?g@g@g@N)r!r�rZrN)r&r'ryrrr�testExtendFloatWithPythonList�sz)MessageTest.testExtendFloatWithPythonListcCs�|j�}|jg|j�|jjdg�|jdg|j�|jjddg�|jdddg|j�|jjddg�|jdddddg|j�dS)z8Test extending repeated string fields with python lists.rtZ11Z22Z33Z44N)r!r�rMrN)r&r'ryrrr�testExtendStringWithPythonList�sz*MessageTest.testExtendStringWithPythonListcCs:|j�}|jg|j�|jjd�|jdddg|j�dS)zDTest extending repeated string fields with characters from a string.�abcrr�r�N)r!r�rMrN)r&r'ryrrr�testExtendStringWithString�sz&MessageTest.testExtendStringWithStringc@s2eZdZdZddd�Zdd�Zdd�Zd	d
�ZdS)zMessageTest.TestIterablez�This iterable object mimics the behavior of numpy.array.

    __nonzero__ fails for length > 1, and returns bool(item[0]) for length == 1.

    NcCs|pg|_dS)N)�_list)r&�valuesrrr�__init__�sz!MessageTest.TestIterable.__init__cCs8t|j�}|dkrdS|dkr,t|jd�Std��dS)NrFr8zTruth value is ambiguous.)r�r��boolr�)r&�sizerrrrK�s
z!MessageTest.TestIterable.__bool__cCs
t|j�S)N)r�r�)r&rrr�__len__�sz MessageTest.TestIterable.__len__cCs
|jj�S)N)r��__iter__)r&rrrr��sz!MessageTest.TestIterable.__iter__)N)rGrHrI�__doc__r�rKr�r�rrrr�TestIterable�s

r�cCs�|j�}|jg|j�|jjtjg��|jg|j�|jjtjdg��|jdg|j�|jjtjddg��|jdddg|j�|jjtjddg��|jdddddg|j�dS)z3Test extending repeated int32 fields with iterable.rr8rerpr9N)r!r�r�rNrr�)r&r'ryrrr�testExtendInt32WithIterable�sz'MessageTest.testExtendInt32WithIterablecCs�|j�}|jg|j�|jjtjg��|jg|j�|jjtjdg��|jdg|j�|jjtjddg��|jdddg|j�|jjtjddg��|jdddddg|j�dS)z3Test extending repeated float fields with iterable.gg�?g@g@g@N)r!r�rZrNrr�)r&r'ryrrr�testExtendFloatWithIterable�sz'MessageTest.testExtendFloatWithIterablecCs�|j�}|jg|j�|jjtjg��|jg|j�|jjtjdg��|jdg|j�|jjtjddg��|jdddg|j�|jjtjddg��|jdddddg|j�dS)z4Test extending repeated string fields with iterable.rt�1�2�3�4N)r!r�rMrNrr�)r&r'ryrrr�testExtendStringWithIterable�sz(MessageTest.testExtendStringWithIterablec
CsPtj�dkstj�dkrdS|j�}|jtj��}tj|jtj	�WdQRXdS)N�cppre)
rrZVersionr!rrQZPickleErrorrRr�ZHIGHEST_PROTOCOL)r&r'ryr�rrr�!testPickleRepeatedScalarContainer�sz-MessageTest.testPickleRepeatedScalarContainercCs|j�}|jj�dS)z?Exercise a scenario that has led to segfaults in the past.
    N)r!r{r�)r&r'ryrrr�'testSortEmptyRepeatedCompositeContainer�sz3MessageTest.testSortEmptyRepeatedCompositeContainerc	Cs,|j�}|jt��}|jd�WdQRXdS)zBUsing HasField on a repeated field should raise an exception.
    r�N)r!rr�r�)r&r'ryr�rrr�testHasFieldOnRepeatedField�sz'MessageTest.testHasFieldOnRepeatedFieldcCs�|j�}|jt��}|jj�WdQRX|jjttd���|jd|jj��|jd|jjd��|jd|jjd��|jddg|j�dS)Nr�r9rrer8rp)	r!r�
IndexErrorr��poprNr�r�r+)r&r'ryr�rrr�testRepeatedScalarFieldPop�sz&MessageTest.testRepeatedScalarFieldPopcCs�|j�}|jt��}|jj�WdQRX|jt��}|jjd�WdQRXx td�D]}|jj�}||_qTW|j	d|jj�j�|j	d|jjd�j�|j	d|jjd�j�|j	ddgdd	�|jD��dS)
Nr7r�r9rrer8rpcSsg|]
}|j�qSr)rw)rxr�rrrrzsz=MessageTest.testRepeatedCompositeFieldPop.<locals>.<listcomp>)
r!rrr{rr=r�r|rwr+)r&r'ryr�r�r�rrr�testRepeatedCompositeFieldPops

z)MessageTest.testRepeatedCompositeFieldPopcCs\|j�}x.td�D]"}|jj||�|jj�}||_qW|j|j|j�|j|j|j�dS)Nr�)	r!r�r��insertr{r|rwr�r+)r&r'ryr�r�rrr�testRepeatedCompareWithSelfs

z'MessageTest.testRepeatedCompareWithSelfcCs6|j�}|jj�}|j}|jj�}|j|jjd�dS)zwA case that lead to a segfault when a message detached from its parent
    container has itself a child container.
    rN)r�Zrepeated_childr|r�r+r��optional_int32)r&r'ryrrr�testReleasedNestedMessagess


z&MessageTest.testReleasedNestedMessagescCsz|j�}|jt��g|_WdQRX|jjd�tj�dkrZ|jt��g|_WdQRXn|jt��g|_WdQRXdS)Nr8r)r!r�AttributeErrorr�r�rrr=)r&r'ryrrr�testSetRepeatedComposite(sz$MessageTest.testSetRepeatedComposite)HrGrHrIr)r2r6rErPrVr\r]r_rbrcrdrmrnrorsrvr~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��	bytearray�setr�r�r�r�r�r�r�r�rOr�r�r�r�rrrrrr	rr
rrrrres�
$			--( #	#		
	






	
rc@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�
Proto2TestcCs�tj�}|j|jd��|j|jd��|j|jd��|jt��|jd�WdQRX|jt��|jd�WdQRX|jt��|jd�WdQRX|jd|j�|jd|j�|jd|j	j
�d|_d|_d|j	_
|j|jd��|j|jd��|j|jd��d	|_d
|_d|j	_
|j|jd��|j|jd��|j|jd��|jd�|jd�|jd�|j|jd��|j|jd��|j|jd��|jd|j�|jd|j�|jd|j	j
�dS)Nr
�
optional_bool�optional_nested_message�field_doesnt_existr�r{rFr�T�)
r	r!r�r�rr�r+r
rrrwrWr�)r&rrrr�testFieldPresence:sD


zProto2Test.testFieldPresencecCs
tj�}|jt��}d|_WdQRX|jt|jjd�|jjd�d|jd<|jt��d|jd<WdQRXtj�}d|_|jjd�|j�}tj�}|j	|�|j
|jd��|jd|j�|jdt
|j��|j�|j	|j��|jd|j�|jd|jd�dS)	z:Assigning an invalid enum number is not allowed in proto2.i��Nreri@�i��t�optional_nested_enumr8)r	r!rr�rr�r�r
r,r*r�r�r+r�r�)r&ryr�r�r^Zm3rrr�testAssignInvalidEnumjs*

z Proto2Test.testAssignInvalidEnumc
Cs6tj�}d|jd<|jt��d|jd<WdQRXdS)Nr�{r8)rZTestEnumMapZknown_map_fieldrr�Zunknown_map_field)r&ryrrr�testUnknownEnumMap�s
zProto2Test.testUnknownEnumMapcCstj�}|jtt|d�dS)N�
Extensions)r	r!rrr�)r&rCrrr�testExtensionsErrors�szProto2Test.testExtensionsErrorscCshtjd�}tj�}|j|�tj�}tj|�|j||�|j||j��tj	|�}|j||j��dS)Nr0)
rrr	ZTestAllExtensionsr*ZSetAllExtensionsr+r,r-r.)r&r/r0r5r1rrr�testGoldenExtensions�s



zProto2Test.testGoldenExtensionscCshtjd�}tj�}|j|�tj�}tj|�|j||�|j||j��tj	|�}|j||j��dS)Nr3)
rrr	ZTestPackedExtensionsr*ZSetAllPackedExtensionsr+r,r-r.)r&r/r0r5r1rrr�testGoldenPackedExtensions�s



z%Proto2Test.testGoldenPackedExtensionscCsNtjdd�}tj|�}tj|�}|j||�|j|jd�|jtj	|j
�dS)Nr8)r)r	ZTestRequiredrQrRrSr+rrrZEncodeErrorr,)r&r0rTrUrrr�testPickleIncompleteProto�s

z$Proto2Test.testPickleIncompleteProtocCs�tj�tj�tj�g}d|d_d|d_d|d_d|d_tj�}d|_d|_d|_tjj�}|jj|�|j	j|�|j
j|�|jj|�|jj|�|j
j�jj|d�|j
j�jj|d�|j
j�jj|d�|jj�jj|d�|jj�jj|d�|jj�jj|d�|j�}tj�}|j|�|j|j|�|j|j|�|j|jj|�|j|jtjj|�|jt|j�d�|jt|j�d�|jt|jtjj�d�dS)zcCheck the merge behavior when a required or optional field appears
    multiple times in the input.r8rrerpZhelloN)r	r!r
�optional_int64r�ZTestParsingMergeZRepeatedFieldsGeneratorZfield1rNZfield2Zfield3Zext1Zext2Zgroup1r|r�Zgroup2r,r*r+Zrequired_all_typesZoptional_all_types�
optionalgroupZoptional_group_all_typesrZoptional_extr�Zrepeated_all_types�
repeatedgroupZrepeated_ext)r&ZmessagesZmerged_message�	generator�dataZ
parsing_mergerrr�testParsingMerge�sJ








zProto2Test.testParsingMergecCs`tjddddddiddiid	dd
iddigdtjjgd
dd�}|j|tj�|jd|j�|jd|j�|jd|j�|jd|j�|jd|j	j
�|j|jtjj�|jd|jj
�|j|jd��|j|jtj��|jtjj|j�|jdt|j��|jd
|jdj
�|jd|jdj
�|jdt|j��|jtjj|jd�|jtjj|jd�|jd
|j�|jd|j�|j|jd��|jdt|j��|jd|j�tjd	d�}|jtjj|j�|jt��tjddid�WdQRX|jt��tjddid�WdQRX|jt��tjdd�WdQRX|jt��tjdd�WdQRXdS)N�d��g�r@�xri�rwi��BAZiXi��FOOi r)r
�optional_fixed32rX�optional_bytesr r�optional_foreign_messagerr!r��
default_int32r�r,rerr8r�*)rZINVALID_NESTED_FIELD�)rZINVALID_VALUE_TYPEZ
INVALID_LABEL)r�) r	r!ZBARr�r+r
r*rXr+r rrr�rwrWr�r,�ForeignMessager(rr�r!r�r)r-r�r�rZZ
default_int64rr�r=)r&rrrr�testPythonicInit�sl






zProto2Test.testPythonicInitN)rGrHrIrrrrrrrr$r1rrrrr8s01rc@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-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Z d=d>�Z!d?d@�Z"dAS)B�
Proto3TestcCs@t|�}x&|D]\}}|j|||�||=qW|ji|�dS)N)�dictr+)r&Zmap_iterZ
dict_valuer��vrrr�assertMapIterEquals+s

zProto3Test.assertMapIterEqualsc4Cs�tj�}|jt��|jd�WdQRX|jt��|jd�WdQRX|jt��|jd�WdQRX|jt��|jd�WdQRX|j|jd��|jt��|jd�WdQRX|jt��|jd�WdQRX|jt��|jd�WdQRX|jd	|j�|jd	|j�|jd
|j	�|jd|j
�|jd	|jj�d	|j_|j
|jd��d|_d
|_d|_	d|_
d|j_|jd�|jd�|jd�|jd�|jd�|jd	|j�|jd	|j�|jd
|j	�|jd|j
�|jd	|jj�dS)Nr
rXr�rrrr�r{rrtFr�g�������?r�Tr)r
r!rr�r�r�r+r
rXr�rrrwrWr�)r&rrrrr5sL




zProto3Test.testFieldPresencecCs�tj�}d|_|jd|j�|jjd�|jd|jd�d|jd<|jd|jd�|j�}tj�}|j|�|jd|j�|jd|jd�dS)zCAssigning an unknown enum value is allowed and preserves the value.i��i��Tri��tN)r
r!rr+r�r�r,r*)r&ryr^r�rrr�testAssignUnknownEnumns

z Proto3Test.testAssignUnknownEnumcCsNtj�}|jd|jk�|jd|jk�|jd|jk�|jd|jk�|jd|jk�|jd|jk�|jd|j	k�|jd|j
k�|jd|jk�|jd|jd�|jd|jd�|jd|jd�|jd|jd�|jd	|jd�|j
t|jdt��|jd|jd�|j
t|jdt��|jd
|j	d�|jd|j
d�|jd|jd�|j
d|jk�|j
d|jk�|j
d|jk�|j
d|jk�|j
d|jk�|j
d|jk�|j
d|j	k�|j
d|j
k�|j
d|jk�|j|j	dtj�|jt��|j	dWdQRX|jt��d|j	kWdQRXdS)Nrrer�Fr��oixrgrtr�i����ll����li����ll����li����ll����l)r�TestMapr��map_int32_int32�map_int64_int64�map_uint32_uint32�map_uint64_uint64�map_int32_double�
map_bool_bool�map_string_stringZmap_int32_bytes�map_int32_enumr+rW�
isinstance�floatr�r�r�r�rr=)r&rCrrr�testScalarMapDefaults�sFz Proto3Test.testScalarMapDefaultscCs&tj�}|j|jjd��|jd|jjdd��|j|jjd��d|jd<|jd|jjd��|jd|jjd��|jt��|jjd�WdQRX|j|jjd��|jd|jjdd��|jd}|j	||jjd��t
j�dk�r|jt��|jjd�WdQRXn|jd|jjd��dS)Nr�r�rrtr)rr8r�r9�getr+rr=�map_int32_foreign_messager�rr)r&rC�submsgrrr�
testMapGet�s"

zProto3Test.testMapGetc!Cs4tj�}|jdt|j��|jd|jk�d|jd<d|jd<d|jd<d|jd<d|j	d<d	|j
d
<d|jd<d
|jd
<d|j
d<d|j
d<|jg|j��|jd
t|j��|jt��d|jd<WdQRX|jd
t|j��|jt��d|jd<WdQRX|j�}tj�}|j|�|jt��d|jd<WdQRX|jt��d|jd<WdQRX|jd|jd�|jd|jd�|jd|jd�|jd|jd �|jd|j	d�|jd	|j
d
�|jd|jd�|jd
|jd
�|jd|j
d�|jd|j
d�tj�dk�r0|jdt|j��dS)!Nrr�i�rre�"r�g333333�?gffffff
@r8�123r�Tixrz{-123: -456}i8���i����ll����ll����lli8���i����ll����ll����ll)rr8r+r�r9r�r:r;r<Zmap_int32_floatr=r?r>r@�FindInitializationErrorsrr=r,r*r�rrr$)r&rCr^�msg2rrr�
testScalarMap�sP










zProto3Test.testScalarMapcCs@tj�}d|jd<d|jd<|j|j�d�|jd|j��dS)Nrrtr�s
r
)rr8r9r?r+�ByteSizer,)r&rCrrr�testMapEntryAlwaysSerializeds

z'Proto3Test.testMapEntryAlwaysSerializedcCsntj�}d}|jd�}||j|<t|jj��d\}}|j||�|j||�|j|tj	�|j|tj	�dS)Nuሴ�utf8r)
rr8�encoder?r��itemsr+r�r�r�)r&rCZunicode_objZ	bytes_objr��valuerrr� testStringUnicodeConversionInMaps

z+Proto3Test.testStringUnicodeConversionInMapcCsZtj�}|jdt|j��|jd|jk�|jd|jjd
�|jdt|j��|jd|j�|jd|j�|jdt|j��|jt	��|jdWdQRX|jt
��|jd|jd<WdQRX|jdt|j��|j�}tj�}|j|�|jdt|j��|jd|j�|jd|j�|jdt|j��t
j�dk�rV|jd	tt|j���dS)
Nrr�ri�rerIi�rri8���i8���i8���)rr8r+r�rEr�Z
get_or_creater#rr=r�r,r*rrr$)r&rCr^rKrrr�testMessageMap&s0

zProto3Test.testMessageMapcCs�tj�}d|jdj_|jd=d|jdj_|jdt|j��d|jdj_|jdt|j��|j�}tj�}|j|�ddg}x|D]}|j|=q�WdS)Nr8re)	rr8�map_int32_all_typesrrwr+r�r,r*)r&rCr^rK�keysr�rrr�testNestedMessageMapItemDeleteOs

z)Proto3Test.testNestedMessageMapItemDeletecCsptj�}d|jd<|j�}d|jd<|j|j�|d�d|jd_|j�}d|jd_|j|j�|d�dS)Nr8��)rr8r9rMr+rEr�)r&rCr�rrr�testMapByteSize`s

zProto3Test.testMapByteSizec	Cs�tj�}d|jd<d|jd<d|jd<d|jd_d	|jd
_tj�}d|jd<d|jd
<d|jd
_d|jd
_|jd
}|j|�|jd|jd�|jd|jd�|jd|jd�|jd|jd
�|jd|jdj�|jd	|jd
j�|j	|jd
j
d��tj�dk�r(|jd|j�i}x.|jD]$}|j	||k�|j|j||<�q4W|jdd	d�|�|jd=|j	d|jk�|jd
=|j	d
|jk�tj�dk�r�|j
t��|jd=WdQRXn|j
t��|jd=WdQRXdS)NrHr��N�8r��r�r7r����7�c�Xrr��dr)r7r^rt)rr8r9r:rEr�rbr�r+r�r�rrrr=�KeyError)r&rCrKZ
old_map_valueZas_dictr�rrr�
testMergeFromlsH






zProto3Test.testMergeFromc	Cs.tj�}|jtd��|jd�WdQRXdS)NzWParameter to MergeFrom\(\) must be instance of same class: expected .*TestMap got int\.r8)rr8�assertRaisesRegexr=r�)r&rCrrr�testMergeFromBadType�s
zProto3Test.testMergeFromBadTypec	Cs.tj�}|jtd��|jd�WdQRXdS)Nz[Parameter to [A-Za-z]*From\(\) must be instance of same class: expected .*TestMap got int\.r8)rr8rer=r�)r&rCrrr�testCopyFromBadType�s
zProto3Test.testCopyFromBadTypecCs�tj�}td�|jtd�<td	�|jtd�<td�|jtd�<td�|jtd
�<|j�}tj�}|j|�|j	d|jd�|j	d|jd�|j	d|jd�|j	d|jd�dS)Ni�rrerHr�i8���i����ll����ll����lli8���i����ll����ll����ll)
rr8r�r9r:r;r<r,r*r+)r&rCr^rKrrr�testIntegerMapWithLongs�s
z"Proto3Test.testIntegerMapWithLongscCs�tj�}d|jjd<|j�}tj�}|j|�|j||�d|jjd<|j�}|j|�|j||�|jjj�|j�}|j|�|j||�dS)Ni�ri�ix)r�TestMapSubmessage�test_mapr9r,r*r+�clear)r&rCr^rKrrr�testMapAssignmentCausesPresence�s


z*Proto3Test.testMapAssignmentCausesPresencecCs�tj�}d|jjd_|j�}tj�}|j|�|j||�d|jjd_|j�}|j|�|j||�|jjdj|jjd�|j�}|j|�|j||�|jjj	�|j�}|j|�|j||�dS)Nr�r�ix)
rrirjrEr�r,r*r+r�rk)r&rCr^rKrrr�-testMapAssignmentCausesPresenceForSubmessages�s&



z8Proto3Test.testMapAssignmentCausesPresenceForSubmessagescCs~tj�}t|j�}t|j�}d|jd<d|jd_|jt��x|D]}qDWWdQRX|jt��x|D]}qhWWdQRXdS)NrIr�r�)rr8�iterr?rEr�r�RuntimeError)r&rCZstring_string_iterZint32_foreign_iterr�rrr�testModifyMapWhileIterating�s




z&Proto3Test.testModifyMapWhileIteratingc
Cs�tj�}|jd}|j||jd�|j|tj�d|_|j�}tj�}|j	|�|j
d|jdj�|jt��tj�|jd<WdQRXdS)Nr7r�ra)
rr8rEr�r�r	r0r�r,r*r+rr�)r&rCrFr^rKrrr�testSubmessageMaps

zProto3Test.testSubmessageMapcCs�tj�}x$t|jj��D]\}}|jd�qWd|jd<d|jd<d|jd<|jdt|j��dddd�}|jt|jj��|�dS)NFr9rer�rp�)rerpr9)	rr8r�r9rQrWr+r�r5)r&rCr�r4�
matching_dictrrr�testMapIterations


zProto3Test.testMapIterationcs&tjdk�r"tj�}d|jd<d|jd<d|jd<d|jd<|j}�jdt|��tj�}|j|j���fdd	�}|t	|j
��t|j
���|t	|j��t|j���|t	|j
��t|j
����jd|jd���jd|jd
���jd|jd���jd|jd���jdt|��|j�\}}�jd||��jdt|��|j��jdt|���jt��|j�WdQRX�jd|jd���jdt|��|j|j��jdt|���jt��|j|j|j�WdQRX�jt��|jd�WdQRX�jt��|jd
d�WdQRXdS)Nrpr9rer�rsr�r�cs0�jt|�|d��jt|�|dd��dS)Nrr8)r+�nextr�)�seq�iterator)r&rr�
CheckItems9sz-Proto3Test.testPython2Map.<locals>.CheckItemsi�rr8r�)rR)rp)rqrrrr8r9r+r�r*r,r�rQrorVr�rDr�popitemrkrrc�
setdefault�updater=)r&rCZ	map_int32rKryr�rRr)r&r�testPython2Map-sJ



zProto3Test.testPython2MapcCsftj�}d|jd<d|jd<d|jd<d|jd<d|jd<t|jj��}t|jj��}|j||�dS)Nrt�
local_init_op�trainable_variables�	variables�init_op�	summaries)rr8r?r�rQr+)r&rCZitems1Zitems2rrr�testMapItems]s




zProto3Test.testMapItemscCs~d}tj�}d|jd<d|jd<d|jd<d|jd	<d
|jd<d
|jd<d
|jd<d|jd<d|jd<|j||jdd��dS)Ns�r
init_opdr

item1er

item2fr

item3gr
item4QQr

local_init_opar
	summarieser
trainable_variablesbr
	variablescrr~r�rr�r�rbr��er�Zitem1�fZitem2�gZitem3ZQQZitem4T)rF)rr8r?r+r,)r&r/rCrrr�!testMapDeterministicSerializationls	








z,Proto3Test.testMapDeterministicSerializationcCsRtj�}d|jd<d|jd<d|jd<t|jj��}~dddd�}|j||�dS)Nr9rer�rprs)rerpr9)rr8r9r�rQr5)r&rC�itrtrrr�testMapIterationClearMessage�s


z'Proto3Test.testMapIterationClearMessagecCsftjddd�d�}|jd|jd�|jd|jd�tjdtjdd�id	�}|jd|jdj�dS)
Nrer9)r8rp)r9r8rpr�)r�)rE)rr8r+r9r	r0rEr�)r&rCrrr�testMapConstruction�szProto3Test.testMapConstructioncCsdtj�}|j}d|d<d|d<d|d<|jd�|jd|j��dddd�}|jt|j��|�dS)	Nr9rer�rprsr9r�)rerpr9)	rr8r9r�r+r,r5r�rQ)r&rCZ	int32_maprtrrr�testMapValidAfterFieldCleared�s
z(Proto3Test.testMapValidAfterFieldClearedcCsLtj�}|j}d|d_|jd�|jd|j��|jdt|j	��k�dS)Nr�rerEr�)
rr8rEr�r�r+r,rWr�rV)r&rCZint32_foreign_messagerrr�$testMessageMapValidAfterFieldCleared�s

z/Proto3Test.testMessageMapValidAfterFieldClearedcCs|tj�}t|j�}|jd�|jt��x|D]}q.WWdQRXt|j�}|jd�|jt��x|D]}qfWWdQRXdS)Nr9rE)rr8ror9r�rrprE)r&rCr�r�rrr�"testMapIterInvalidatedByClearField�s





z-Proto3Test.testMapIterInvalidatedByClearFieldcCs�tj�}|jdt|j��d|jd<|jdt|j��|jt��|jd=WdQRX|jd=|jdt|j��|jt��|jd=WdQRXdS)Nrr�r9r8ra� )rr8r+r�r9rrcrU)r&rCrrr�
testMapDelete�s
zProto3Test.testMapDeletecCsLtj�}|j|jtj�|j|jtj�|j|jtj�|j|jtj�dS)N)rr8r�r9r��Mapping�MutableMappingrE)r&rCrrr�testMapsAreMapping�szProto3Test.testMapsAreMappingcCsDtj�}d|jd<|j|j|j�|j|j|j�|j|jd�dS)Ni�rri8���i����)rr8r9r+rEZassertNotEqual)r&rCrrr�testMapsCompare�s
zProto3Test.testMapsComparecCs@tj�}d|jd<d|jd<d|jd_|jdt|j���dS)NrIr��@�#r�r�r)	rr8r?r9Zmap_string_foreign_messager�r+r�rJ)r&rCrrr�(testMapFindInitializationErrorsSmokeTest�s


z3Proto3Test.testMapFindInitializationErrorsSmokeTestN)#rGrHrIr5rr6rCrGrLrNrSrTrWrZrdrfrgrhrlrnrqrrrur}r�r�r�r�r�r�r�r�r�r�r�rrrrr2(s@
90=)<0	
r2c@seZdZdd�Zdd�ZdS)�ValidTypeNamesTestcs�tt|��jd�d�d|d|f}|jt�fdd�|D��d�|f��jd�}|d
}dj|dd��}t||gd	�dS)N�'r8zRepeated%sContainerzRepeated%sFieldContainerc3s|]}�j|�VqdS)N)�endswith)rxr4)�tp_namerrr�sz:ValidTypeNamesTest.assertImportFromName.<locals>.<genexpr>z%r does end with any of %r�.)�fromlistr<r<)r$�type�splitrW�any�join�
__import__)r&rCZ	base_nameZvalid_names�parts�
class_nameZmodule_namer)r�r�assertImportFromName�s

z'ValidTypeNamesTest.assertImportFromNamecCs(tj�}|j|jd�|j|jd�dS)NZScalarZ	Composite)r	r!r�r�r{)r&r�rrr�testTypeNamesCanBeImported
sz-ValidTypeNamesTest.testTypeNamesCanBeImportedN)rGrHrIr�r�rrrrr��s
r�c@s$eZdZdd�Zdd�Zdd�ZdS)�PackedFieldTestcCs�|jjd�|jjd�|jjd�|jjd�|jjd�|jjd�|jjd�|jjd�|j	jd�|j
jd�|jjd�|jjd�|j
jd�|jjd�dS)Nr8g�?T)r�r�Zrepeated_int64Zrepeated_uint32Zrepeated_uint64Zrepeated_sint32Zrepeated_sint64Zrepeated_fixed32Zrepeated_fixed64Zrepeated_sfixed32Zrepeated_sfixed64rZr[Z
repeated_boolr�)r&rrrr�
setMessageszPackedFieldTest.setMessagecCs*tj�}|j|�d}|j||j��dS)NsH
"*2:BJRZ�?b�?jr)rr4r�r+r,)r&rr/rrr�testPackedFields"s
z PackedFieldTest.testPackedFieldscCs*tj�}|j|�d}|j||j��dS)Ns: (0=AMQ]�?a�?hp)rZTestUnpackedTypesr�r+r,)r&rr/rrr�testUnpackedFields5s
z"PackedFieldTest.testUnpackedFieldsN)rGrHrIr�r�r�rrrrr�sr�rrermz;explicit tests of the C++ implementation for PY27 and abovec@s0eZdZedd��Zdd�Zdd�Zdd�Zd	S)
�OversizeProtosTestcCsFd}tj�}tj�}tj||�|j|�tj|�j	|j
d��|_dS)Na�
      name: "f/f.msg2"
      package: "f"
      message_type {
        name: "msg1"
        field {
          name: "payload"
          number: 1
          label: LABEL_OPTIONAL
          type: TYPE_STRING
        }
      }
      message_type {
        name: "msg2"
        field {
          name: "field"
          number: 1
          label: LABEL_OPTIONAL
          type: TYPE_MESSAGE
          type_name: "msg1"
        }
      }
    zf.msg2)rZDescriptorPoolrZFileDescriptorProtorZParseZAddr
ZMessageFactoryZGetPrototypeZFindMessageTypeByName�	proto_cls)�clsZ	file_descZpoolZdescrrr�
setUpClassNs

zOversizeProtosTest.setUpClasscCs(|j�|_dd|jj_|jj�|_dS)Nr�ir�r8iii)r��p�fieldr�r,�p_serialized)r&rrr�setUpqs
zOversizeProtosTest.setUpcCsfddlm}|d�|j�}y|j|j�Wn4tjk
r`}z|jt|�d�WYdd}~XnXdS)Nr)�SetAllowOversizeProtosFzError parsing message)	�google.protobuf.pyext._messager�r�r*r�rr?r+r$)r&r��qr�rrr�testAssertOversizeProtovsz*OversizeProtosTest.testAssertOversizeProtocCsBddlm}|d�|j�}|j|j�|j|jjj|jj�dS)Nr)r�T)	r�r�r�r*r�r+r�r�r�)r&r�r�rrr�testSucceedOversizeProtos
z+OversizeProtosTest.testSucceedOversizeProtoN)rGrHrI�classmethodr�r�r�r�rrrrr�Is#	r��__main__)rerm)4r��
__author__r�r-rgr�rQr�rqr@Z	unittest2Zunittest�ImportErrorr�r�Zgoogle.protobufrrr	r
rrr
rZgoogle.protobuf.internalrrrrrrrZPY3r�ZlongrrrrZBaseTestCaseZNamedParametersrrr2r�r�ZskipIfrrrr�rG�mainrrrr�<module>)s�WqX9:


Filemanager

Name Type Size Permission Actions
__init__.cpython-36.opt-1.pyc File 113 B 0644
__init__.cpython-36.pyc File 113 B 0644
_parameterized.cpython-36.opt-1.pyc File 13.17 KB 0644
_parameterized.cpython-36.pyc File 13.54 KB 0644
any_test_pb2.cpython-36.opt-1.pyc File 3.56 KB 0644
any_test_pb2.cpython-36.pyc File 3.56 KB 0644
api_implementation.cpython-36.opt-1.pyc File 2.48 KB 0644
api_implementation.cpython-36.pyc File 2.48 KB 0644
containers.cpython-36.opt-1.pyc File 19.77 KB 0644
containers.cpython-36.pyc File 19.77 KB 0644
decoder.cpython-36.opt-1.pyc File 20.5 KB 0644
decoder.cpython-36.pyc File 20.58 KB 0644
descriptor_database_test.cpython-36.opt-1.pyc File 2.09 KB 0644
descriptor_database_test.cpython-36.pyc File 2.09 KB 0644
descriptor_pool_test.cpython-36.opt-1.pyc File 28.47 KB 0644
descriptor_pool_test.cpython-36.pyc File 28.47 KB 0644
descriptor_pool_test1_pb2.cpython-36.opt-1.pyc File 8.48 KB 0644
descriptor_pool_test1_pb2.cpython-36.pyc File 8.48 KB 0644
descriptor_pool_test2_pb2.cpython-36.opt-1.pyc File 5.95 KB 0644
descriptor_pool_test2_pb2.cpython-36.pyc File 5.95 KB 0644
descriptor_test.cpython-36.opt-1.pyc File 29.15 KB 0644
descriptor_test.cpython-36.pyc File 29.15 KB 0644
encoder.cpython-36.opt-1.pyc File 23.43 KB 0644
encoder.cpython-36.pyc File 23.57 KB 0644
enum_type_wrapper.cpython-36.opt-1.pyc File 2.65 KB 0644
enum_type_wrapper.cpython-36.pyc File 2.65 KB 0644
factory_test1_pb2.cpython-36.opt-1.pyc File 4.26 KB 0644
factory_test1_pb2.cpython-36.pyc File 4.26 KB 0644
factory_test2_pb2.cpython-36.opt-1.pyc File 10.6 KB 0644
factory_test2_pb2.cpython-36.pyc File 10.6 KB 0644
file_options_test_pb2.cpython-36.opt-1.pyc File 2.29 KB 0644
file_options_test_pb2.cpython-36.pyc File 2.29 KB 0644
generator_test.cpython-36.opt-1.pyc File 10.52 KB 0644
generator_test.cpython-36.pyc File 10.52 KB 0644
json_format_test.cpython-36.opt-1.pyc File 28.12 KB 0644
json_format_test.cpython-36.pyc File 28.12 KB 0644
message_factory_test.cpython-36.opt-1.pyc File 5.34 KB 0644
message_factory_test.cpython-36.pyc File 5.34 KB 0644
message_listener.cpython-36.opt-1.pyc File 2.23 KB 0644
message_listener.cpython-36.pyc File 2.23 KB 0644
message_set_extensions_pb2.cpython-36.opt-1.pyc File 4.06 KB 0644
message_set_extensions_pb2.cpython-36.pyc File 4.06 KB 0644
message_test.cpython-36.opt-1.pyc File 58.58 KB 0644
message_test.cpython-36.pyc File 58.69 KB 0644
missing_enum_values_pb2.cpython-36.opt-1.pyc File 4.61 KB 0644
missing_enum_values_pb2.cpython-36.pyc File 4.61 KB 0644
more_extensions_dynamic_pb2.cpython-36.opt-1.pyc File 3.09 KB 0644
more_extensions_dynamic_pb2.cpython-36.pyc File 3.09 KB 0644
more_extensions_pb2.cpython-36.opt-1.pyc File 3.81 KB 0644
more_extensions_pb2.cpython-36.pyc File 3.81 KB 0644
more_messages_pb2.cpython-36.opt-1.pyc File 2.7 KB 0644
more_messages_pb2.cpython-36.pyc File 2.7 KB 0644
packed_field_test_pb2.cpython-36.opt-1.pyc File 7.8 KB 0644
packed_field_test_pb2.cpython-36.pyc File 7.8 KB 0644
proto_builder_test.cpython-36.opt-1.pyc File 2.26 KB 0644
proto_builder_test.cpython-36.pyc File 2.26 KB 0644
python_message.cpython-36.opt-1.pyc File 41.32 KB 0644
python_message.cpython-36.pyc File 41.41 KB 0644
reflection_test.cpython-36.opt-1.pyc File 78.49 KB 0644
reflection_test.cpython-36.pyc File 78.49 KB 0644
service_reflection_test.cpython-36.opt-1.pyc File 4.06 KB 0644
service_reflection_test.cpython-36.pyc File 4.06 KB 0644
symbol_database_test.cpython-36.opt-1.pyc File 3.65 KB 0644
symbol_database_test.cpython-36.pyc File 3.65 KB 0644
test_bad_identifiers_pb2.cpython-36.opt-1.pyc File 3.47 KB 0644
test_bad_identifiers_pb2.cpython-36.pyc File 3.47 KB 0644
test_util.cpython-36.opt-1.pyc File 24.73 KB 0644
test_util.cpython-36.pyc File 24.77 KB 0644
testing_refleaks.cpython-36.opt-1.pyc File 2.95 KB 0644
testing_refleaks.cpython-36.pyc File 2.95 KB 0644
text_encoding_test.cpython-36.opt-1.pyc File 1.33 KB 0644
text_encoding_test.cpython-36.pyc File 1.33 KB 0644
text_format_test.cpython-36.opt-1.pyc File 46.88 KB 0644
text_format_test.cpython-36.pyc File 46.88 KB 0644
type_checkers.cpython-36.opt-1.pyc File 8.94 KB 0644
type_checkers.cpython-36.pyc File 8.94 KB 0644
unknown_fields_test.cpython-36.opt-1.pyc File 8.94 KB 0644
unknown_fields_test.cpython-36.pyc File 8.94 KB 0644
well_known_types.cpython-36.opt-1.pyc File 25.43 KB 0644
well_known_types.cpython-36.pyc File 25.43 KB 0644
well_known_types_test.cpython-36.opt-1.pyc File 20.19 KB 0644
well_known_types_test.cpython-36.pyc File 20.19 KB 0644
wire_format.cpython-36.opt-1.pyc File 6.27 KB 0644
wire_format.cpython-36.pyc File 6.27 KB 0644
wire_format_test.cpython-36.opt-1.pyc File 5.43 KB 0644
wire_format_test.cpython-36.pyc File 5.43 KB 0644