
    i                        d Z ddlZddlZddlZddlZddl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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  ej8                  de        G d de      Z ej@                  defdef      ejB                   G d dejB                                      Z"ejB                   G d dejB                               Z#ejB                   G d dejB                               Z$ejB                   G d  d!ejB                               Z%ejB                   G d" d#ejB                               Z&ejB                   G d$ d%ejB                               Z'ejB                   G d& d'ejB                               Z(ejB                   G d( d)ejB                               Z)ejB                   G d* d+ejB                               Z*ejB                   G d, d-ejB                               Z+e,d.k(  r ejZ                          yy)/ziUnittest for reflection.py, which also indirectly tests the output of the
pure-Python protocol compiler.
    N)unittest_import_pb2)unittest_mset_pb2)unittest_pb2)unittest_proto3_arena_pb2)descriptor_pb2)
descriptor)message)
reflection)text_format)api_implementation)more_extensions_pb2)more_messages_pb2)message_set_extensions_pb2)wire_format)	test_util)testing_refleaks)decoder)_parameterizederrorc                   N    e Zd ZdZd Zd ZeZeZeZeZ	d Z
e
Zd Zd Zd Zd Zy	)
_MiniDecodera  Decodes a stream of values from a string.

  Once upon a time we actually had a class called decoder.Decoder.  Then we
  got rid of it during a redesign that made decoding much, much faster overall.
  But a couple tests in this file used it to check that the serialized form of
  a message was correct.  So, this class implements just the methods that were
  used by said tests, so that we don't have to rewrite the tests.
  c                      || _         d| _        y Nr   )_bytes_pos)selfbytess     z/var/www/catia.catastroantioquia-mas.com/valormas/lib/python3.12/site-packages/google/protobuf/internal/reflection_test.py__init__z_MiniDecoder.__init__M   s    DKDI    c                 j    t        j                  | j                  | j                        \  }| _        |S N)r   _DecodeVarintr   r   r   results     r   
ReadVarintz_MiniDecoder.ReadVarintQ   s(    --dkk499EFDIMr    c                 H    t        j                  | j                               S r"   )r   ZigZagDecoder&   r   s    r   
ReadSInt64z_MiniDecoder.ReadSInt64Z   s    ##DOO$566r    c                 H    t        j                  | j                               S r"   )r   	UnpackTagr&   r)   s    r   ReadFieldNumberAndWireTypez'_MiniDecoder.ReadFieldNumberAndWireType_   s      !233r    c                     t        j                  d| j                  | j                  | j                  dz          d   }| xj                  dz  c_        |S )Nz<f   r   structunpackr   r   r$   s     r   	ReadFloatz_MiniDecoder.ReadFloatb   @    ]]4TYYtyy{!CDQGFIINIMr    c                     t        j                  d| j                  | j                  | j                  dz          d   }| xj                  dz  c_        |S )Nz<d   r   r0   r$   s     r   
ReadDoublez_MiniDecoder.ReadDoubleg   r4   r    c                 F    | j                   t        | j                        k(  S r"   )r   lenr   r)   s    r   EndOfStreamz_MiniDecoder.EndOfStreaml   s    99DKK(((r    N)__name__
__module____qualname____doc__r   r&   	ReadInt32	ReadInt64
ReadUInt32
ReadUInt64r*   
ReadSInt32r-   r3   r7   r:    r    r   r   r   C   sG     ))**7 *4

)r    r   _proto2_proto3c                       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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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+d* Z,d+ Z-d, Z.d- Z/d. Z0y/)0ReflectionTestc                     | j                  t        |      t        |             t        t        |            D ]  }| j                  ||   ||           y r"   assertEqualr9   ranger   valuesothersis       r   assertListsEqualzReflectionTest.assertListsEqualv   J    S[#f+.3v; -
vay&),-r    c                 (   |j                  dddd       }| j                  d|j                         | j                  d|j                         | j                  d|j                         |t
        u r!| j                  |j                  d             y y )N   +)K@optional_string)optional_int32optional_doublerV   optional_floatrY   )TestAllTypesrK   rW   rX   rV   r   assertFalseHasFieldr   message_moduleprotos      r   testScalarConstructorz$ReflectionTest.testScalarConstructor{   s    '')	 ( E 	R--.VU223&(=(=>%
u~~&678 &r    c                    |j                  g dddgg ddgd       }| j                  g dt        |j                               | j                  ddgt        |j                               | j                  g dt        |j
                               | j                  dgt        |j                               | j                  g t        |j                               y )N         r/   Gz?rU   TFFrV   )repeated_int32repeated_doublerepeated_boolrepeated_stringrepeated_float)rZ   rK   listrh   ri   rj   rk   rl   r]   s      r   testRepeatedScalarConstructorz,ReflectionTest.testRepeatedScalarConstructor   s    ''#v**+ ( E 	\4(<(<#=>dF^T%*?*?%@A)40C0C+DE'($u/D/D*EFRe2234r    c                 `   |j                  ddddgg d|j                   j                  |j                   j                        |j                   j                  |j                   j                        g|j	                  d      |j	                  d	      |j	                  d
      gd       }| j                  d|j                         | j                  d|j                         | j                  ddgt        |j                               | j                  g dt        |j                               | j                  |j                   j                  |j                   j                        |j                   j                  |j                   j                        gt        |j                               | j                  |j	                  d      |j	                  d	      |j	                  d
      gt        |j                               | j                  |j                  d             y )NrT   rV   rf   rU   rg   bbc     )rW   rV   ri   rj   repeated_nested_messagerepeated_foreign_messageoptional_nested_messagery   )rZ   NestedMessageFOOBARForeignMessagerK   rW   rV   rm   ri   rj   rw   rx   r[   r\   r]   s      r   testMixedConstructorz#ReflectionTest.testMixedConstructor   s
   '')v*''55!..22 6 4''55!..22 6 4!5 ))C)0))E)2))B)/"1 !% ( &E  	R--.&(=(=>dF^T%*?*?%@A)40C0C+DE		$	$	2	2**.. 
3 
0		$	$	2	2++// 
3 
1	2 	U**+- 			&	&	&	-		&	&	&	/		&	&	&	,	. 	U++,	.
 	U^^$=>?r    c                 n   | j                  t        |j                  d       | j                  t        |j                  d       | j                  t        |j                  d       | j                  t        |j                  d       | j                  t        |j                  dg       | j                  t        |j                  d       | j                  t        |j                  dg       | j                  t        |j                  d       | j                  t        |j                  dg       y )	NfoorW     )rV   ry   rh   )rk   rw   )assertRaises	TypeErrorrZ   r   r^   s     r   testConstructorTypeErrorz'ReflectionTest.testConstructorTypeError   s1   >..u  F>..  F>..  N>..t  E>..w  H>..  F>..  H>..  N>..  Pr    c                    |j                  d      }| j                  d |j                                |j                  |j                   j                               }| j                  d |j                                |j                  dg      }|t        u r!| j                  d |j                                |j                  |j                   j                         g      }| j                  d |j                                y )Nrv   r   rd   r   re   r   r   )rZ   rK   ByteSizerz   r   )r   r^   r	   s      r   (testConstructorInvalidatesCachedByteSizez7ReflectionTest.testConstructorInvalidatesCachedByteSize   s    )))<GQ(((*+)) . ; ; I I K * MGQ(((*+))")>G%
q*'**,-))!/!<!<!J!J!L M * OGQ(((*+r    c                 L    |j                         }|j                  }~d|_        y N   )rZ   ry   rq   r   r^   r_   nesteds       r   testReferencesToNestedMessagez,ReflectionTest.testReferencesToNestedMessage   s'    '')E**F FIr    c                    |j                         }d|_        d|j                  _        | j	                  d|j                  j                         | j                  |j                  d             |j                  }d|_        | j	                  d|j                         | j	                  d|j                         | j                  |j                  d             y )N
      oneof_uint32abconeof_nested_message)rZ   r   r   rq   rK   r[   r\   oneof_stringr   s       r   	testOneOfzReflectionTest.testOneOf   s    '')EE$&E!R33667U^^N34''FEUE../R#U^^$:;<r    c                     |j                         }|j                  }|j                  d       ~~t        j                          |j                         }|j                  }y Nry   )rZ   ry   
ClearFieldgccollectr   s       r   5testGetDefaultMessageAfterDisconnectingDefaultMessagezDReflectionTest.testGetDefaultMessageAfterDisconnectingDefaultMessage   sT    '')E**F	./ JJL'')E**Fr    c                    |j                         }|j                  }d|_        | j                  |j	                  d             |j                  d       | j                  d|j                         | j                  d|j                  j                         | j                  ||j                         d|_        | j                  |j	                  d             | j                  d|j                  j                         y )N   ry   r   r   )	rZ   ry   rq   
assertTruer\   r   rK   assertIsNotr[   r   s       r   /testDisconnectingNestedMessageAfterSettingFieldz>ReflectionTest.testDisconnectingNestedMessageAfterSettingField  s    '')E**FFIOOENN#<=>	./Q		"Q55889VU::;FIU^^$=>?Q55889r    c                     |j                         }| j                  |j                  d             |j                  d       | j                  |j                  d             y r   )rZ   r[   r\   r   r]   s      r   0testDisconnectingNestedMessageBeforeGettingFieldz?ReflectionTest.testDisconnectingNestedMessageBeforeGettingField  sO    '')EU^^$=>?	./U^^$=>?r    c                 *   |j                         }|j                         }d|j                  _        |j                  |       | j	                  |j                  d             |j                  d       | j                  |j                  d             y Nr   ry   )rZ   ry   rq   	MergeFromr   r\   r   r[   r   r^   proto1proto2s       r   (testDisconnectingNestedMessageAfterMergez7ReflectionTest.testDisconnectingNestedMessageAfterMerge  sy    
 ((*F((*F()F""%
VOOFOO$=>?
/0V__%>?@r    c                     t        j                         dk7  ry |j                         }d|j                  _        |j                  d       ~t        j                          y )Npythonr   optional_lazy_message)r   TyperZ   r   rq   r   r   r   r]   s      r   "testDisconnectingLazyNestedMessagez1ReflectionTest.testDisconnectingLazyNestedMessage"  sO    
  H,'')E%&E"	,-JJLr    c                 t   |j                         }d|_        d|_        d|_        |j                  }| j                  |j                  j                  d   df|j                  j                  d   df|j                  j                  d   dfg|j                                d|j                  _	        | j                  |j                  j                  d   df|j                  j                  d   df|j                  j                  d   df|j                  j                  d   |fg|j                                y )	Nrc   r   r   rW   optional_fixed32rV   {   ry   )
rZ   r   rW   rV   ry   rK   
DESCRIPTORfields_by_name
ListFieldsrq   )r   r^   r_   nested_messages       r   testSingularListFieldsz%ReflectionTest.testSingularListFields/  s?   '')EEE!E22N				(	()9	<a@				(	();	<a@				(	():	<eDG 	 (+E!!$				(	()9	<a@				(	();	<a@				(	():	<eD				(	()B	D	
 r    c                    |j                         }|j                  j                  d       |j                  j                  d       |j                  j                  d       |j                  j                  ddg       |j                  j                  g        |j                  j                  d       |j                  j                  d t        d      D               d	|_        |j                   | j                  |j                  j                  d
   d	f|j                  j                  d   ddgf|j                  j                  d   dgf|j                  j                  d   g dfg|j                                y )Nrc   r   r   r   barbazc              3   2   K   | ]  }t        |        y wr"   )str).0xs     r   	<genexpr>z8ReflectionTest.testRepeatedListFields.<locals>.<genexpr>M  s      :AQ :s   rd      rW   rh   repeated_fixed32rk   )r   r   r   01)rZ   r   appendrh   rk   extendrL   rW   rj   rK   r   r   r   r]   s      r   testRepeatedListFieldsz%ReflectionTest.testRepeatedListFieldsE  sM   '')E	!!!$	"	#	  %0	  $	  '	   :q ::E					(	()9	<bA				(	()9	<q"gF				(	();	<qcB				(	():	<
)	+-
 r    c                     |j                         }| j                  t        |j                  d       | j                  t        |j                  d       y )Nnonexistent_fields   nonexistent_field)rZ   r   
ValueErrorr   r]   s      r   "testClearFieldWithUnknownFieldNamez1ReflectionTest.testClearFieldWithUnknownFieldNameX  sB    '')Ej%"2"24GHj%"2"24HIr    c                    |j                         }| j                  t        t        |dd       | j                  t        t        |ddg       | j                  t        t        |dd       | j                  t        t        |j                  dd       | j                  t        t        |j
                  dd       | j                  t        t        |dd       y )	Nrh   r   ry   r   rq   "   some_attributer   )rZ   r   AttributeErrorsetattrrw   rl   r]   s      r   testDisallowedAssignmentsz(ReflectionTest.testDisallowedAssignments]  s     '')Engu6FKngu6FMngu/5 	ngu/L/LB  	ngu/C/C&, 	ngu6I2Nr    c                    |j                         }| j                  t        t        |dd       | j                  t        t        |dd       | j                  t        t        |dd       | j                  t        t        |dd       | j                  t        t        |dd       | j                  t        t        |dd       | j                  t        t        |d	d       t	        j
                         d
k(  s7t        j                  j                  t        j                  j                  fdk\  r| j                  t        t        |dd       y d|_
        y )NrW   皙?r   rV   r   optional_bytesoptional_boolrY   rX   r   )re   r   )rZ   r   r   r   r   r   sysversion_infomajorminorr   r]   s      r   testSingleScalarTypeSafetyz)ReflectionTest.testSingleScalarTypeSafetyr  s   '')Ei%1A3Gi%1A5Ii%1BBGi%1A2Fi%%Hi%1A5Ii%1BEJ!X-					!1!1!7!78GC
	7E?CHer    c                 *     fd} |ddt                 |ddt                 |ddt                t         }t        j                  d      dk(  r |dd|       n |ddt                 |d	d|        |d	d
|        |dd|        |dd
|       y)zVerifies setting of scalar integers.

    Args:
      integer_fn: A function to wrap the integers that will be assigned.
      message_module: unittest_pb2 or unittest_proto3_arena_pb2
    c                    j                         } |      }t        || |       j                  t        ||       |       j                         }|j	                  |j                                j                  t        ||       |       y r"   )rZ   r   assertIsInstancegetattrParseFromStringSerializeToString)
field_namevalueexpected_typer_   r   
integer_fnr^   r   s        r   TestGetAndDeserializez@ReflectionTest.assertIntegerTypes.<locals>.TestGetAndDeserialize  sz    ))+eeeZ'
GE:6F**,fU4467
GFJ7Gr    rW   rc   i   @optional_uint32Lr/   l        optional_int64l            optional_uint64N)intr1   calcsize)r   r   r^   r   
integer_64s   ```  r   assertIntegerTypesz!ReflectionTest.assertIntegerTypes  s    H *As3*GS9+Wc:Jsq  -w
C -w<*GZ@*GZ@+WjA+WjAr    c                 *    | j                  d |       y )Nc                     | S r"   rD   r   s    r   <lambda>z1ReflectionTest.testIntegerTypes.<locals>.<lambda>  s    a r    )r   r   s     r   testIntegerTypeszReflectionTest.testIntegerTypes  s    K8r    c                 D    | j                  t        j                  |       y r"   )r   r   NonStandardIntegerr   s     r   testNonStandardIntegerTypesz*ReflectionTest.testNonStandardIntegerTypes  s    I88.Ir    c                    |j                         }| j                  t              5  d|_        d d d        | j	                  t
        d      5  t        j                  dd      |_        d d d        y # 1 sw Y   DxY w# 1 sw Y   y xY w)N2my_errorr   )rZ   r   r   r   assertRaisesRegexRuntimeErrorr   r   )r   r^   pbs      r   testIllegalValuesForIntegersz+ReflectionTest.testIllegalValuesForIntegers  s    		$	$	&B 
		9	% b 
		j	9 G$77:FbG G	 G Gs   A1A=1A:=Bc                 t     fd} |ddd        |ddd        |dd	d
        |ddd       j                         } j                  t        t        f      5   d	      |_        ddd       j                         } d      |_         j                  d|j
                         y# 1 sw Y   CxY w)zVerifies bounds checking for scalar integer fields.

    Args:
      integer_fn: A function to wrap the integers that will be assigned.
      message_module: unittest_pb2 or unittest_proto3_arena_pb2
    c                    j                         } |      } |      }t        || |       j                  |t        ||              t        || |       j                  |t        ||              j	                  t
        t        ft        || |dz
         j	                  t
        t        ft        || |dz          y Nrc   )rZ   r   rK   r   r   r   r   )r   expected_minexpected_maxr   r   r^   r   s       r   TestMinAndMaxIntegerszHReflectionTest.assetIntegerBoundsChecking.<locals>.TestMinAndMaxIntegers  s    &&(b-l-lb*l+
|WR%<=b*l+
|WR%<=
Y/"j$q(*
Y/"j$q(*r    rW   i   ir   r   l    r            l    r       Nrc   )rZ   r   r   r   r   optional_nested_enumrK   )r   r   r^   r  r   s   ```  r   assetIntegerBoundsCheckingz)ReflectionTest.assetIntegerBoundsChecking  s    * *JF+Q
;*JF+Q0BC 
	$	$	&B			J	2	3 2%j1b2 
	$	$	&B(mBQ//02 2s   B..B7c                 *    | j                  d |       y )Nc                     | S r"   rD   r   s    r   r   z?ReflectionTest.testSingleScalarBoundsChecking.<locals>.<lambda>  s    a r    )r	  r   s     r   testSingleScalarBoundsCheckingz-ReflectionTest.testSingleScalarBoundsChecking  s    ##K@r    c                 D    | j                  t        j                  |       y r"   )r	  r   r   r   s     r   )testNonStandardSingleScalarBoundsCheckingz8ReflectionTest.testNonStandardSingleScalarBoundsChecking  s    ##$$n6r    c                    |j                         }| j                  t        |j                  j                  d       | j                  t        |j                  j                  d       | j                  t        |j
                  d       | j                  t        |j                  d       |j                  j	                  d       d|j                  d<   | j                  t        |j                  j                  dd       | j                  t        |j                  j                  dd       | j                  t        |j                  j                  dg        | j                  t        |j                  j                  dd       |j
                  j	                  d	       | j                  t        |j
                  j                  dd       y )
Nr   r   r   r   r   i  r   indexr   )	rZ   r   r   rh   r   rk   repeated_bytes
IndexError__setitem__r]   s      r   testRepeatedScalarTypeSafetyz+ReflectionTest.testRepeatedScalarTypeSafety  sY   '')Ei!5!5!<!<cBi!5!5!<!<eDi!6!6;i!5!5r:	# Ej%"6"6"B"BCLi!5!5!A!A1eLi!5!5!A!A1bIi!5!5!A!Ar# 
  %i!6!6!B!BArJr    c                 .   |j                         }| j                  d|j                         d|_        | j                  d|j                         d|_        | j                  d|j                         d|_        | j                  d|j                         y )Nr   rc   l    r  )rZ   rK   rW   r   r]   s      r   !testSingleScalarGettersAndSettersz0ReflectionTest.testSingleScalarGettersAndSetters  s    '')EQ,,-EQ,,-*E^U%:%:;.E')>)>?r    c                    |j                         }| j                  d|j                         | j                  d|j                   j                         | j                  d|j                         | j                  d|j                   j                         | j                  d|j                         | j                  d|j                   j                         y )Nrc   rd   re   )rZ   rK   r{   r|   BAZr]   s      r   	testEnumszReflectionTest.testEnums  s    '')EQ		"Q33778Q		"Q33778Q		"Q33778r    c                 n   | j                  d|j                  j                  |j                               | j                  d|j                  j                  |j                               | j                  d|j                  j                  |j
                               | j                  t        |j                  j                  d       |j                         }| j                  d|j                  j                  |j                               | j                  d|j                  j                  j                  |j                               | j                  d|j                  j                  |j                               | j                  d|j                  j                  j                  |j                               | j                  d|j                  j                  |j                               | j                  d|j                  j                  j                  |j                               | j                  t        |j                  j                  d       | j                  t        |j                  j                  j                  d       | j                  t        |j                  j                  j                  d       | j                  t        |j                  j                  j                  d        | j                  d|j                  j                  j                  d	             y )
NFOREIGN_FOOFOREIGN_BARFOREIGN_BAZi0,  r{   r|   r  g     @T)rK   ForeignEnumNamer  r  r  r   r   rZ   
NestedEnumr{   r|   r  r   r]   s      r   testEnum_NamezReflectionTest.testEnum_Name  s   ""''(B(BCE 	""''(B(BCE 	""''(B(BCE 	j$0055u> '')EU%%**59957U#00;;@@KMU%%**59957U#00;;@@KMU%%**59957U#00;;@@KMj&&++U4j$11<<AA5J 	i!<!<!G!G!L!Li!<!<!G!G!L!LUN77BBGGMNr    c                 
   | j                  |j                  |j                  j                  d             | j                  |j                  |j                  j                         | j                  |j                  |j                  j                  d             | j                  |j                  |j                  j                         | j                  |j
                  |j                  j                  d             | j                  |j
                  |j                  j
                         | j                  t        |j                  j                  d       | j                  t              5  |j                  j                   d d d        |j                         }| j                  |j                  |j                  j                  d             | j                  |j                  |j                  j                         | j                  |j                  |j                  j                  j                  d             | j                  |j                  |j                  j                  j                         | j                  |j                  |j                  j                  d             | j                  |j                  |j                  j                         | j                  |j                  |j                  j                  j                  d             | j                  |j                  |j                  j                  j                         | j                  |j                  |j                  j                  d             | j                  |j                  |j                  j                         | j                  |j                  |j                  j                  j                  d             | j                  |j                  |j                  j                  j                         | j                  t        |j                  j                  d       | j                  t              5  |j                  j                  j                   d d d        | j                  t        |j                  j                  j                  d       | j                  t              5  |j                  j                  j                  j                   d d d        y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   y xY w)	Nr  r  r  FOr{   r|   r  Foo)rK   r  r  Valuer  r  r   r   r   r#  rZ   r{   r   r|   r  r$  r]   s      r   testEnum_ValuezReflectionTest.testEnum_Value,  s   ^//#//55mDF^//#//;;= 	^//#//55mDF^//#//;;= 	^//#//55mDF^//#//;;= 	j$0066>			>	* $  ##$ '')EUYY%%++E24UYY%%))+ 	UYY#00;;AA%HJUYY#00;;??A 	UYY%%++E24UYY%%))+ 	UYY#00;;AA%HJUYY#00;;??A 	UYY%%++E24UYY%%))+ 	UYY#00;;AA%HJUYY#00;;??A 	j&&,,e5			>	* !  ! 	j$11<<BBEK			>	* 7!!,,22667 7S$ $H! !
7 7s$   0T 9!T-,+T9 T*-T69Uc                    |t         k(  rg d}g d}g d}ng d}g d}g d}| j                  |t        |j                  j	                                      | j                  |t        |j                  j                                      | j                  |t        |j                  j                                      |j                         }|t         k(  rg d}g d}g d	}ng d
}g d}g d}| j                  |t        |j                  j	                                      | j                  |t        |j                  j                                      | j                  |t        |j                  j                                      y )N)r  r  r  )r/   r      )r  r/   r  r   r  r(  )FOREIGN_ZEROr  r  r  )r   r/   r   r(  ))r,  r   r)  r*  r+  )r{   r|   r  NEG)rc   rd   re   )r{   rc   r|   rd   r  re   r-  r.  )ZEROr{   r|   r  r-  )r   rc   rd   re   r.  ))r3  r   r/  r0  r1  r2  )	r   rK   rm   r  keysrN   itemsrZ   r   )r   r^   r4  rN   r5  r_   s         r   testEnum_KeysAndValuesz%ReflectionTest.testEnum_KeysAndValuesj  sE   %:dfJeJdf7eT.4499;<>V.44;;=>@U.44::<=? '')E%)df?e1dfLeT4 0 0 5 5 789VT%"2"2"9"9";<=U%**00235r    c                     |j                         }t        j                  |       |j                         }|j                   j	                  |      }| j                  ||       y r"   )rZ   r   SetAllFieldsr   
FromStringrK   )r   r^   r   string1r   s        r   testStaticParseFromz"ReflectionTest.testStaticParseFrom  sT    ((*F6"&&(G((33G<F 	VV$r    c                     |j                         }d|_        |j                         }d|_        |j                  |       | j	                  d|j                         | j	                  d|j                         y )Nrc   r   )rZ   rW   rV   r   rK   r   s       r   testMergeFromSingularFieldz)ReflectionTest.testMergeFromSingularField  sh    ((*FF((*F$F
VQ--.Wf445r    c                    |j                         }|j                  j                  d       |j                  j                  d       |j                         }|j                  j                  d       |j                  |       | j	                  d|j                  d          | j	                  d|j                  d          | j	                  d|j                  d          y Nrc   rd   r   )rZ   rh   r   r   rK   r   s       r   testMergeFromRepeatedFieldz)ReflectionTest.testMergeFromRepeatedField  s    ((*F
  #
  #((*F
  #
VQ--a01Q--a01Q--a01r    c                    |j                         }|j                  j                         }d|_        |j                  j                         }d|_        |j                         }|j                  j                         }d|_        |j	                  |       | j                  d|j                  d   j                         | j                  d|j                  d   j                         | j                  d|j                  d   j                         |j                         }|j                  j	                  |j                         | j                  d|j                  d   j                         | j                  d|j                  d   j                         | j                  d|j                  d   j                         y )Nr   iA    r   rc   rd   )rZ   rw   addrq   r   rK   )r   r^   r   mr   proto3s         r   "testMergeFromRepeatedNestedMessagez1ReflectionTest.testMergeFromRepeatedNestedMessage  sk   ((*F&&**,AAD&&**,AAD((*F&&**,AAD
VS&88;>>?S&88;>>?S&88;>>?((*F
"",,V-K-KLS&88;>>?S&88;>>?S&88;>>?r    c                    |j                         }t        j                  |       |j                         }|j                  |       | j	                  ||       |j                         }|j                         }| j	                  ||       y r"   )rZ   r   r8  r   rK   r   r   r^   r   r   r:  string2s         r   testMergeFromAllFieldsz%ReflectionTest.testMergeFromAllFields  sz    ((*F6"((*F
V 	VV$ &&(G&&(GWg&r    c                     |j                         }|j                         }|j                   | j                  |j                  d             |j	                  |       | j                  |j                  d             y r   )rZ   ry   r[   r\   r   )r   r^   message1message2s       r   testMergeFromBugzReflectionTest.testMergeFromBug  sm    **,H**,H $$X&&'@AB x X&&'@ABr    c                     |j                         }d|_        d|_        |j                         }d|_        |j                  |       | j	                  d|j                         | j	                  d|j                         y )Nrc   important-textr   )rZ   rW   rV   CopyFromrK   r   s       r   testCopyFromSingularFieldz(ReflectionTest.testCopyFromSingularField  so    ((*FF-F((*F$F
OOFQ--.%v'='=>r    c                    |j                         }|j                  j                  d       |j                  j                  d       |j                         }|j                  j                  d       |j                  |       | j	                  d|j                  d          | j	                  d|j                  d          y r?  )rZ   rh   r   rQ  rK   r   s       r   testCopyFromRepeatedFieldz(ReflectionTest.testCopyFromRepeatedField  s    ((*F
  #
  #((*F
  #
OOFQ--a01Q--a01r    c                    |j                         }t        j                  |       |j                         }|j                  |       | j	                  ||       |j                         }|j                         }| j	                  ||       y r"   )rZ   r   r8  rQ  rK   r   rH  s         r   testCopyFromAllFieldsz$ReflectionTest.testCopyFromAllFields  sx    ((*F6"((*F
OOF 	VV$ &&(G&&(GWg&r    c                 F   |j                         }|j                  j                  d       d|_        d|_        |j                  |       | j                  d|j                  d          | j                  d|j                         | j                  d|j                         y )Nrc   rd   rP  r   )rZ   rh   r   rW   rV   rQ  rK   )r   r^   r   s      r   testCopyFromSelfzReflectionTest.testCopyFromSelf	  s    ((*F
  #F-F
OOFQ--a01Q--.%v'='=>r    c                    |j                         }d|_        t        j                  |      }| j	                  d|j                         |j
                  j                  d       |j
                  j                  d       t        j                  |j
                        }| j	                  ddg|       |j                  |d          | j	                  dg|       |j                  j                         }d|_
        t        j                  |j                        }| j	                  |j                  |       d|_
        | j                  |j                  |       |j                  |d          | j	                  t        |      d       y )Nrc   rd   re   r   )rZ   rW   copydeepcopyrK   rh   r   removerw   rC  rq   assertNotEqualr9   )r   r^   r   r   	containerrL  messagess          r   testDeepCopyzReflectionTest.testDeepCopy  s6   ((*FF]]6"FQ--.
  #
  #f334IaVY'Yq\"aS)$--113HHK}}V;;<HV33X>HK66AOOHQK S]A&r    c                    |j                         }|j                  }|j                          | j                  ||j                         d|_        | j                  |j                  d             | j                  d|j                  j                         |j                         }|j                  }d|_        |j                  }d|_	        |j                          | j                  ||j                         | j                  ||j                         | j                  d|j                         | j                  d|j                         d|_        d|_	        | j                  |j                  d             | j                  d|j                  j                         | j                  |j                  d             | j                  d|j                  j                         y )	Nr   ry   r   r   r(        optional_foreign_message)
rZ   ry   Clearr   rq   r[   r\   rK   rd  rt   )r   r^   r_   r   foreigns        r   testDisconnectingBeforeClearz+ReflectionTest.testDisconnectingBeforeClear,  sz   '')E**F	KKMVU::;FIU^^$=>?Q55889'')E**FFI,,GGI	KKMVU::;We<<=Q		"Q		"FIGIU^^$=>?Q55889U^^$>?@Q66889r    c                 
   |j                         }| j                  t        t        |dd       | j	                  t        |j                        t               t        d      |_        | j	                  |j                  t        d             t        d      |_        | j	                  |j                  t        d             | j                  t        t        |dd       dj                  d      }||_        d|_        d|_        y )	Nr   zunicode objectTestingrV   s   aa   Тестutf-8r   )
rZ   r   r   r   rK   typerV   r   r   encode)r   r^   r_   
utf8_bytess       r   testStringUTF8Encodingz%ReflectionTest.testStringUTF8EncodingF  s    '')E 	iu&68IK 	T%//0#6	NEU**C	N;  	NEU**C	N; 	ju&7D ##G,J&E'E!Er    c                 ^    |j                  d      }| j                  dt        |             y )Ns    )r   z#optional_bytes: "\000\177\200\377"
)rZ   rK   r   r]   s      r   testBytesInTextFormatz$ReflectionTest.testBytesInTextFormatb  s+    ''7J'KE@#e*Mr    c                    |j                         }|j                  j                  |j                   j                                | j	                  |j                  d             |j                         }|j                  j                  |j                   j                                | j	                  |j                  d             |j                         }|j                  j                  d      }| j                  d|       | j	                  |j                  d             |j                         }|j                  j                  d       | j	                  |j                  d             |j                         }|j                         }| j                  t        |      |j                  |             | j	                  |j                  d             y )Nry   r    r   )rZ   ry   r   rz   r   r\   rQ  MergeFromStringrK   r   r   r9   )r   r^   r_   
bytes_read
serializedr   s         r   testEmptyNestedMessagez%ReflectionTest.testEmptyNestedMessagef  so   '')E	!!++##1135OOENN#<=>'')E	!!**##1135OOENN#<=>'')E..>>sCJQ
#OOENN#<=>'')E	!!11#6OOENN#<=>((*J((*FJz*, 	OOFOO$=>?r    N)1r;   r<   r=   rQ   r`   rn   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&  r6  r;  r=  r@  rF  rJ  rN  rR  rT  rV  rX  r`  rg  ro  rq  rv  rD   r    r   rH   rH   p   s    -
95!@FP(,"
=+:@A,&J
O*  B@9J	G 1DA6K*	@9$OL<7|5>%62@,'C?2'	?'0:4"8N@r    rH   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d Zd Zd Zd Zd Zd Zd Zd Zd Z ej4                  d      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(d& Z)d' Z*d( Z+d) Z,d* Z-d+ Z.d, Z/d6d.Z0d/ Z1 e2jf                   e4jj                         d0k(  d1      d2        Z6d3 Z7d4 Z8d5 Z9y-)7Proto2ReflectionTestc           	      2   t        j                  t         j                  j                  t         j                  j                        t         j                  j                  t         j                  j                        gt        j
                  d      t        j
                  d      t        j
                  d      gt         j                  j                         t         j                  j                  d      t         j                  j                  d      g	      }| j                  t         j                  j                  t         j                  j                        t         j                  j                  t         j                  j                        gt        |j                               | j                  t        j
                  d      t        j
                  d      t        j
                  d      gt        |j                               | j                  t         j                  j                         t         j                  j                  d      t         j                  j                  d      gt        |j                               y )
Nrp   rr   rs   ru   rv   rc   )ard   )rw   rx   repeatedgroup)r   rZ   rz   r{   r|   r}   RepeatedGrouprK   rm   rw   rx   r{  r   r_   s     r    testRepeatedCompositeConstructorz5Proto2ReflectionTest.testRepeatedCompositeConstructor  s   %%%%33,,00 4 2%%33,,00 4 2!3 ''#.''%0''"-"/
 %%335%%33a38%%33a38:;E 			"	"	0	0((,, 
1 
.		"	"	0	0))-- 
1 
/	0 	U**+- 			$	$s	+		$	$u	-		$	$r	*	, 	U++,	.
 			"	"	0	0	2		"	"	0	01	0	5		"	"	0	01	0	5	7 	U  !	#r    c                     | j                  t        |      t        |             t        t        |            D ]  }| j                  ||   ||           y r"   rJ   rM   s       r   rQ   z%Proto2ReflectionTest.assertListsEqual  rR   r    c                    t        j                         }| j                  |j                  d             | j	                  d|j
                         | j                  |j                  d             d|_        | j                  |j                  d             |j                  d       | j                  |j                  d             y )NrW   r   rc   )r   rZ   r[   r\   rK   rW   r   r   r}  s     r   testSimpleHasBitsz&Proto2ReflectionTest.testSimpleHasBits  s    %%'EU^^$456Q,,- 	U^^$456EOOENN#345	%&U^^$456r    c                 X      fd} |dd        |dd        |dd        |dd	       y )
Nc                    t        j                         }t        ||       }t        ||      }j                  d|       j	                  |j                  |             j	                  |j                  |              d}t        |||       j                  |t        ||             |}j                  |j                  |             j                  |j                  |              |j                  |        t        ||       }j	                  |j                  |             j	                  |j                  |              j                  dt        ||             j                  ||       t        |||       j	                  |j                  |             j	                  |j                  |              j                  dt        ||             y )Nr      )
r   rZ   r   rK   r[   r\   r   r   r   r   )composite_field_namescalar_field_namer_   composite_fieldoriginal_scalar_valuenew_valold_composite_fieldr   s          r   TestCompositeHasBitszTProto2ReflectionTest.testHasBitsWithSinglyNestedScalar.<locals>.TestCompositeHasBits  s   '')e  ';<o%o7HI
q/0
//0ABC
u~~&:;<
 go0':
w9J KL+
ooo../@AB
ooenn%9:; +,  ';<o
//0ABC
u~~&:;<
q'/3DEF
*O<!#4g>
//0ABC
u~~&:;<
q'/3DEFr    optionalgrouprz  ry   rq   rd  rt   optional_import_messagedrD   )r   r  s   ` r   !testHasBitsWithSinglyNestedScalarz6Proto2ReflectionTest.testHasBitsWithSinglyNestedScalar  s8    D'GT #.2D93S92C8r    c                    t        j                         }|j                  j                  j	                  d       | j                  dg|j                  j                         | j                  |j                  d             |j                  d       | j                  |j                  d             |j                  j                  j                          | j                  |j                  d             y r   )r   TestNestedMessageHasBitsry   nestedmessage_repeated_int32r   rK   r   r\   r   r[   %nestedmessage_repeated_foreignmessagerC  r}  s     r   &testHasBitsWhenModifyingRepeatedFieldsz;Proto2ReflectionTest.testHasBitsWhenModifyingRepeatedFields  s    113E	!!>>EEaH	
U**GGIOOENN#<=> 
./U^^$=>?	!!GGKKMOOENN#<=>r    c                    t        j                         }| j                  |j                  d             | j	                  d|j
                  j                  j
                  j                  j
                  j                         | j                  |j                  d             d|j
                  j                  j
                  j                  j
                  _        | j	                  d|j
                  j                  j
                  j                  j
                  j                         | j                  |j                  d             | j                  |j
                  j                  d             | j                  |j
                  j                  j                  d             | j                  |j
                  j                  j
                  j                  d             | j                  |j
                  j                  j
                  j                  j                  d             | j                  |j
                  j                  j
                  j                  j
                  j                  d             | j                  |j
                  j                  j
                  j                  j
                  j                  d             y )Nrq   r   r   rz  rW   )	r   TestMutualRecursionAr[   r\   rK   rq   rz  rW   r   )r   recursive_protos     r   !testHasBitsForManyLevelsOfNestingz6Proto2ReflectionTest.testHasBitsForManyLevelsOfNesting  s   "779O_--d34Q**,,//1144CCD_--d3423O  /Q**,,//1144CCDOOO,,T23OOO&&//45OOO&&((11$78OOO&&((++44S9:OOO&&((++--66t<=_'')),,..11::3?@OOO&&((++--0099:JKLr    c                 :   t        j                         }d|j                  t         j                  <   d|j                  t         j                  <   d|j                  t         j
                  <   | j                  t         j                  dft         j                  dft         j
                  dfg|j                                |j                  t         j                  = | j                  t         j                  dft         j
                  dfg|j                                y )Nrc   r   r   )r   TestAllExtensions
Extensionsoptional_fixed32_extensionoptional_int32_extensionoptional_string_extensionrK   r   r}  s     r   testSingularListExtensionsz/Proto2ReflectionTest.testSingularListExtensions,  s    **,E@AE\<<=@AE\::=@EE\;;=		.	.!4		0	0!4		/	/%8; 	
 	@@A

/
/	3

0
0%	8	:r    c                 :   t        j                         }|j                  t         j                     j	                  d       |j                  t         j
                     j	                  d       |j                  t         j
                     j	                  d       |j                  t         j                     j	                  d       |j                  t         j                     j	                  d       |j                  t         j                     j	                  d       d|j                  t         j                  <   | j                  t         j                  dft         j
                  ddgft         j                  dgft         j                  g dfg|j                                |j                  t         j
                  = |j                  t         j                  = | j                  t         j                  dft         j                  dgfg|j                                y )	Nrc   r   r   r   r   r   r   )r   r   r   )
r   r  r  repeated_fixed32_extensionr   repeated_int32_extensionrepeated_string_extensionr  rK   r   r}  s     r   testRepeatedListExtensionsz/Proto2ReflectionTest.testRepeatedListExtensions<  s   **,E	\<<=DDQG	\::=DDQG	\::=DDRH	\;;=DDUK	\;;=DDUK	\;;=DDUK@BE\::=		.	."5		.	.1b':		0	01#6		/	/2GHK  	>>???@

/
/	4

1
1A3	7	9r    c                    t        j                         }t        j                  |       t         j                   | j                  |j                  j                  d   dft         j                  df|j                  j                  d   dft         j                  df|j                  j                  d   dfg|j                                y )	Nmy_intrc   r   	my_stringr   r   my_float      ?)
r   TestFieldOrderingsr   SetAllFieldsAndExtensionsmy_extension_intrK   r   r   my_extension_stringr   r}  s     r   testListFieldsAndExtensionsz0Proto2ReflectionTest.testListFieldsAndExtensionsR  s    ++-E''.!!				(	(	5q9		&	&r:				(	(	5u=		)	)u=				(	(	5s;	>
 r    c                 ,   t        j                         }| j                  d|j                         | j                  d|j                         | j                  d|j
                         | j                  d|j                         | j                  d|j                         | j                  d|j                         | j                  d|j                         | j                  d|j                         | j                  d|j                         | j                  d|j                         | j                  d|j                         | j                  d|j                         | j                  d|j                         | j                  d|j                          | j                  d|j"                         | j                  d|j$                         | j                  d|j&                         | j                  d|j(                         | j                  d	|j*                         | j                  d
|j,                         | j                  d|j.                         | j                  d|j0                         | j                  d|j2                         | j                  d|j4                         | j                  d|j6                         | j                  d|j8                         | j                  d|j:                         | j                  d|j<                         | j                  d|j>                         | j                  d|j@                         | j                  t         j                  jB                  |jD                         | j                  t         jF                  |jH                         | j                  tJ        jL                  |jN                         t        jP                         }| j                  d|jR                         y )Nr   g        F r    )   *   +   ,   i.   /   0   1   ig     I@g     d@Thellos   worldu   ሴ)*r   rZ   rK   rW   r   r   r   optional_sint32optional_sint64r   optional_fixed64optional_sfixed32optional_sfixed64rY   rX   r   rV   r   default_int32default_int64default_uint32default_uint64default_sint32default_sint64default_fixed32default_fixed64default_sfixed32default_sfixed64default_floatdefault_doubledefault_booldefault_stringdefault_bytesr|   default_nested_enumr  default_foreign_enumr   
IMPORT_BARdefault_import_enumTestExtremeDefaultValuesutf8_stringr}  s     r   testDefaultValuesz&Proto2ReflectionTest.testDefaultValues^  s(   %%'EQ,,-Q,,-Q--.Q--.Q--.Q--.Q../Q../Q//0Q//0S%../S%//0UE//0R../S%../R,,-R,,-R--.R--.S%../R--.R../R../R//0S%001T5../T5//0T5--.We223Xu223\..22E4M4MN\--u/I/IJ(33..0 113EY 1 12r    c                 n    t        j                         }| j                  t        |j                  d       y )Nr   )r   rZ   r   r   r\   r}  s     r    testHasFieldWithUnknownFieldNamez5Proto2ReflectionTest.testHasFieldWithUnknownFieldName  s'    %%'Ej%..2EFr    c                     t        j                         t        d      D ]  }j                  j	                           t        j                         }j                  |       | j                  t        fd       y )Nr   c                  "     j                   d   S )Nr   )repeated_message)r_   s   r   r   z?Proto2ReflectionTest.testClearRemovesChildren.<locals>.<lambda>  s    %*@*@*C r    )r   TestRequiredForeignrL   r  rC  rQ  r   r  )r   rP   r   r_   s      @r   testClearRemovesChildrenz-Proto2ReflectionTest.testClearRemovesChildren  sc     ,,.E2Y #  "#--/F	NN6j"CDr    c                 6   t        j                         }|j                  d       d|_        | j	                  |j                  d             |j                  d       | j                  d|j                         | j                  |j                  d             y )NrW   rc   r   )r   rZ   r   rW   r   r\   rK   r[   r}  s     r   testSingleScalarClearFieldz/Proto2ReflectionTest.testSingleScalarClearField  sz    %%'E	%&EOOENN#345	%&Q,,-U^^$456r    c                 p   t        j                         }| j                  |j                         | j	                  dt        |j                               |j                  j                  d       |j                  j                  d       |j                  j                  d       | j                  |j                         | j	                  dt        |j                               | j	                  g d|j                         | j	                  d|j                  d          | j	                  d|j                  d          | j                  t        |j                  j                  d       | j                  t        |j                  j                  d	       | j                  t        |j                  j                  d
       | j                  t        |j                  j                  d        d|j                  d<   | j	                  g d|j                         |j                  j                  dd       | j	                  g d|j                         |j                  j                  d       | j	                  g d|j                  dd        | j	                  g d|j                  d d         d t        d      D        |j                  dd | j	                  g d|j                         g d|j                  dd | j	                  g d|j                         g }|j                  D ]  }|j                  |        | j	                  g d|       |j                  d= | j	                  g d|j                         |j                  dd = | j	                  ddg|j                         |j                  j                  ddg       | j	                  g d|j                         |j                  d       | j                  |j                         | j	                  dt        |j                               |j                  j                  d       | j	                  d|j                  d          d|j                  d<   | j	                  d|j                  d          g d|j                  d d  |j                  d= | j	                  g d|j                         |j                  d = | j	                  ddg|j                         | j                  t        |j                  j                   d!       | j                  t        |j                  j                   d"       |j                  d d= | j	                  dg|j                         |j                  d#d$= | j	                  dg|j                         y )%Nr   r   r   rb  re   )r   r   rb  r.  r   .r   r  rc   )r   r  rb     )r   r  r  rb     )r  r  rb  r/   )r   r  r  rb  r  c              3       K   | ]  }|  y wr"   rD   )r   rP   s     r   r   z;Proto2ReflectionTest.testRepeatedScalars.<locals>.<genexpr>  s      5q 5s   )r   r   rc   rd   r  )#   (   -   )r   r  r  r  r  rd   )r   r  r  r  r     )r   r  re   r  rh   )r   rc   rd   re   r   rc   rd   i,  d   '  )r   rZ   r[   rh   rK   r9   r   r   r   r  __getitem__r   insertrL   r   r   __delitem__)r   r_   r%   rP   s       r   testRepeatedScalarsz(Proto2ReflectionTest.testRepeatedScalars  s   %%'EU))*QE0012	"	#	#OOE(()QE0012[%"6"67 	Q,,Q/0R--b12j%"6"6"B"BDIj%"6"6"B"BEJi!5!5!A!A5Ii!5!5!A!A4H !E[%"6"67 
2&_e&:&:; 
#\5#7#7!#<=(%*>*>q*AB !6E!H 5E1%u';';< !-E1(%*>*>? F!! mmA(&1 	Q_e&:&:; 	QR aWe223 
B(^U%9%9: 
%&U))*QE0012	"Q,,R01 EQ,,R01 +ER Y 4 45R aVU112j%"6"6"B"BBGj%"6"6"B"BCHRU#aS%../SY'aS%../r    c                    t        j                         }| j                  |j                         | j	                  dt        |j                               |j                  j                  d       |j                  j                  d       |j                  j                  d       |j                  j                  d       | j	                  dt        |j                               |j                  j                  d       | j	                  dt        |j                               | j	                  d|j                  d          | j	                  d|j                  d          | j	                  d|j                  d          |j                  j                  d       | j	                  dt        |j                               | j	                  d|j                  d          | j	                  d|j                  d          |j                  j                  d       | j	                  dt        |j                               | j	                  d|j                  d          | j                  t        |j                  j                  d       y )	Nr   r   r   r/   re   rc   rd   r   )
r   rZ   r[   rh   rK   r9   r   r\  r   r   r}  s     r   testRepeatedScalarsRemovez.Proto2ReflectionTest.testRepeatedScalarsRemove  s   %%'EU))*QE0012	"	#	"	"QE0012	"QE0012R--a01Q,,Q/0Q,,Q/0	"QE0012R--a01Q,,Q/0	#QE0012Q,,Q/0 	j%"6"6"="=sCr    c                 ~   t        j                         }| j                  |j                         | j	                  dt        |j                               | j                  |j                  j                                | j                  |j                         | j	                  dt        |j                               y r   )r   rZ   r[   rh   rK   r9   assertIsNonereverser}  s     r    testRepeatedScalarsReverse_Emptyz5Proto2ReflectionTest.testRepeatedScalarsReverse_Empty  s    %%'EU))*QE0012e**2245U))*QE0012r    c                 b   t        j                         }| j                  |j                         | j	                  dt        |j                               |j                  j                  d       |j                  j                  d       |j                  j                  d       |j                  j                  d       | j	                  dt        |j                               | j                  |j                  j                                | j	                  dt        |j                               | j	                  d|j                  d          | j	                  d|j                  d          | j	                  d|j                  d          | j	                  d|j                  d          y )Nr   rc   rd   re   r/   )	r   rZ   r[   rh   rK   r9   r   r  r  r}  s     r   #testRepeatedScalarsReverse_NonEmptyz8Proto2ReflectionTest.testRepeatedScalarsReverse_NonEmpty#  sN   %%'EU))*QE0012	"	"	"	"QE0012e**2245QE0012Q,,Q/0Q,,Q/0Q,,Q/0Q,,Q/0r    c                    t        j                         }| j                  |j                         | j	                  dt        |j                               |j                  j                         }|j                  j                         }| j                  |j                         | j	                  dt        |j                               | j                  ||g|j                         | j                  |t         j                  j                         | j                  t        |j                  j                  d       | j                  t        |j                  j                  d       | j                  t        |j                  j                  d       | j                  t        |j                  j                  d        |j                  j                         }|j                  j                         }|j                  j                         }| j                  |||g|j                  dd        | j                  |||||g|j                  d d         | j                  ||g|j                  d d        | j                  |||g|j                  dd         | j	                  ||j                  d          | j                  |g|j                  d d        g }|j                  D ]  }|j                  |        | j                  |||||g|       |j                  d= | j                  ||||g|j                         |j                  dd = | j                  ||g|j                         t         j                  j                  d      }	t         j                  j                  d      }
|j                  j!                  |	|
g       | j	                  dt        |j                               | j	                  |	|j                  d          | j	                  |
|j                  d	          | j                  t        |j                  j                   |	       | j                  t        |j                  j                   dg       t        j                         }| j                  t        |j                  j                   |g       |j#                  d
       | j                  |j                         | j	                  dt        |j                               |j                  j                  d       | j	                  dt        |j                               | j	                  d|j                  d   j$                         | j                  t        |j                  j                  d       | j                  t&              5  d|j                  d<   d d d        y # 1 sw Y   y xY w)Nr   rd   r   r  r   rc   r/   rp   re   rw   r   )r   rZ   r[   rw   rK   r9   rC  r   rQ   r   rz   r   r  r  r   r   r   r   rq   	Exception)r   r_   m0m1m2m3m4r%   rP   n1n2wrong_message_types               r   testRepeatedCompositesz+Proto2ReflectionTest.testRepeatedComposites8  s   %%'EU223QE99:;		&	&	*	*	,B		&	&	*	*	,BOOE112QE99:;2r(E$A$AB"l77EEF 	j%"?"?"K"Kj%"?"?"K"K 	i!>!>!J!Ji!>!>!J!J 
	&	&	*	*	,B		&	&	*	*	,B		&	&	*	*	,B	Re33Aa8:	RRe;;A>@	R%//35	Re33AB79
E))!,.	e++BQ/1 F** mmA2r2r2.7 	%%a(2r2r*E,I,IJ 	%%ab)2r(E$A$AB 
	"	"	0	0A	0	6B		"	"	0	0A	0	6B	!!(("R1QE99:;R66q9:R66q9:i33::B@i33::QCA%224i33::)*,
 
./U223QE99:; 
!!%%%,QE99:;R66q9<<=i!>!>!B!BBG			9	% ,)+e##A&, , ,s   :WWc                    t        j                         }| j                  dt        |j                               |j                  j                         }t        |j                        |_        |j                  j                         }t        |j                        |_        | j                  ||k7         |j                  j                         }t        |j                        |_        | j                  |||g|j                         | j                  dt        |j                               |j                  j                  |       | j                  dt        |j                               | j                  ||j                  d          | j                  ||j                  d          | j                  t        |j                  j                  |       | j                  t        |j                  j                  d        | j                  dt        |j                               |j                  j                  |       | j                  dt        |j                               | j                  ||j                  d          y )Nr   re   rd   rc   )r   rZ   rK   r9   rw   rC  rq   r   rQ   r\  r   r   r   r_   r  r  r  s        r   testRepeatedCompositeRemovez0Proto2ReflectionTest.testRepeatedCompositeRemove  s   %%'EQE99:;		&	&	*	*	,B--.BE		&	&	*	*	,B--.BEOOB"H		&	&	*	*	,B--.BE2r2,(E(EFQE99:;	!!((,QE99:;R66q9:R66q9: 	j%"?"?"F"FKj%"?"?"F"FMQE99:;	!!((,QE99:;R66q9:r    c                 ~   t        j                         }| j                  |j                         | j	                  dt        |j                               | j                  |j                  j                                | j                  |j                         | j	                  dt        |j                               y r   )r   rZ   r[   rw   rK   r9   r  r  r}  s     r   "testRepeatedCompositeReverse_Emptyz7Proto2ReflectionTest.testRepeatedCompositeReverse_Empty  s    %%'EU223QE99:;e33;;=>U223QE99:;r    c                    t        j                         }| j                  |j                         | j	                  dt        |j                               |j                  j                         }t        |j                        |_        |j                  j                         }t        |j                        |_        |j                  j                         }t        |j                        |_        | j                  |||g|j                         | j                  |j                  j                                | j                  |||g|j                         y r   )r   rZ   r[   rw   rK   r9   rC  rq   rQ   r  r  r  s        r   %testRepeatedCompositeReverse_NonEmptyz:Proto2ReflectionTest.testRepeatedCompositeReverse_NonEmpty  s   %%'EU223QE99:;		&	&	*	*	,B--.BE		&	&	*	*	,B--.BE		&	&	*	*	,B--.BE2r2,(E(EFe33;;=>2r2,(E(EFr    c                    t        j                         dk7  ry t        j                  } |dddd|j                  |j
                  |j                  dd d d dd t        j                         t        j                        }t        j                  ddd	d g g |gg t        j                         t        j                  

       G fddt        j                  t        j                        } |       }| j!                  d|j"                         | j%                  |j'                  d             d|_        | j!                  d|j"                         | j)                  |j'                  d             y )Nr   	foo_fieldzMyProto.foo_fieldr   rc   F)name	full_namer  numberrl  cpp_typelabeldefault_valuecontaining_typemessage_type	enum_typeis_extensionextension_scopeoptions
create_keyMyProtoignored)
r  r  filenamer  nested_types
enum_typesfields
extensionsr  r  c                       e Zd ZW  Zy)DProto2ReflectionTest.testHandWrittenReflection.<locals>.MyProtoClassNr;   r<   r=   r   )mydescriptors   r   MyProtoClassr!    s    jr    r$  	metaclassr   )r   r   r   FieldDescriptor
TYPE_INT64CPPTYPE_INT64LABEL_OPTIONALr   FieldOptions_internal_create_key
DescriptorMessageOptionsr	   Messager
   GeneratedProtocolMessageTyperK   r  r[   r\   r   )r   r'  foo_field_descriptorr$  myproto_instancer#  s        @r   testHandWrittenReflectionz.Proto2ReflectionTest.testHandWrittenReflection  s@     H, 00O*$7 : : ..,,A44D++-22	4 (()i2"$%"--/224L :#J#J  $~Q(223%..{;<!#R)334OO$--k:;r     MakeDescriptor is not repeatablec                 f  	 t        j                         dk7  ry fdd_        t        j                         }d|_        t        j                  } |d|j                          |d|j                          |d|j                          |d|j                         xj                  d	z  c_        |j                  j                         }d
|_        |j                  |_        j                  |_        t        j                  j                  |_        t#        j$                  |      	| j'                  d	j(                  v        | j'                  d	j(                  v        | j'                  d	j(                  v        | j'                  d	j(                  v        | j'                  d
	j(                  v         G 	fddt*        j,                  t.        j0                        } |       }d|_        d|_        d|_        d|_        |j8                  j;                  ddg       |j=                         }t/        j>                  	|      }| jA                  ||       | jC                  ||       | jC                  |j
                  |j
                         | jC                  |j2                  |j2                         | jC                  |j4                  |j4                         | jC                  |j6                  |j6                         | jC                  |j8                  |j8                         y )Nr   c                     xj                   dz  c_         | j                  j                         }||_        ||_        j                   |_        t        j                  j                  |_	        y r  )
field_indexfieldrC  r  rl  r  r   FieldDescriptorProtor*  r  )r_   r   
field_type	new_fieldAddDescriptorFields       r   r<  zKProto2ReflectionTest.testDescriptorProtoSupport.<locals>.AddDescriptorField  sS    $$)$++//#i!in!in+77i&;;JJior    r   Carr  year	automaticpricerc   ownersc                       e Zd ZW  Zy)CProto2ReflectionTest.testDescriptorProtoSupport.<locals>.CarMessageNr"  )descs   r   
CarMessagerC    s    jr    rE  r%  priusi  Tg    @bobsusan)"r   r   r7  r   DescriptorProtor  r9  TYPE_STRINGr(  	TYPE_BOOLTYPE_DOUBLEr8  rC  rl  r  LABEL_REPEATEDr  r   MakeDescriptorr   r   r	   r/  r
   r0  r>  r?  r@  rA  r   r   ParseMessager   rK   )
r   
desc_protofdpr;  rE  rF  serialized_prius	new_priusr<  rD  s
           @@r   testDescriptorProtoSupportz/Proto2ReflectionTest.testDescriptorProtoSupport  sz     H,K &'"//1JJO

-
-Cz63??;z63>>:z;>z7COO<""a'"  $$&IIN__IN)55I$99HHIO$$Z0DOOFd1112OOFd1112OOK4#6#667OOGt2223OOH 3 334:#J#J LEEJEJEOEK	LL()..0''.>?IY&UI& 	UZZ0UZZ0U__i&9&9:U[[)//2U\\9#3#34r    c                    t        j                         }t         j                  }d|j                  |<   t         j                  }|j                  |   j                  d       t         j                  }d|j                  |   _        | j                  t        |j                        d       |j                  |= | j                  t        |j                        d       |j                  |= | j                  t        |j                        d       |j                  |= | j                  t        |j                        d       |j                  |= | j                  t        |j                        d       y )Nr   r   8   re   rd   rc   r   )
r   ExtendedMessageoptional_int_extensionr  repeated_int_extensionr   optional_message_extensionforeign_message_intrK   r9   )r   extendee_protoextension_int32extension_repeatedextension_msgs        r   testExtensionDeletez(Proto2ReflectionTest.testExtensionDelete'  s2   (88:N)@@O13No.,CC0188<'BBMCENm,@S223Q7!!-0S223Q7!!"45S223Q7
 	!!"45S223Q7!!/2S223Q7r    c                 :   t        j                         }t         j                  }d|j                  |<   t         j                  }|j                  |   j                  d       t         j                  }d|j                  |   _        d|_        |j                  j                  d       |||f}d}|j                  D ]L  }| j                  |j                  ||   j                         | j                  ||j                         |dz  }N | j                  |d       y )Nr   r   rV  rc   hir   re   )r   rW  rX  r  rY  r   rZ  r[  rW   rk   rK   r  assertIn)r   r\  r]  r^  r_  expectedcountitems           r   testExtensionIterz&Proto2ReflectionTest.testExtensionIterA  s   (88:N)@@O13No.,CC0188<'BBMCENm,@ %&N!""))$/0BCHE)) 
tyy(5/"6"67
mmD.334qje 	UAr    c                 &   t        j                         }| j                  t        |j                  j
                  d       t         j                  j                  j                  d   }| j                  t        |j                  j
                  |       y )Nr   rW   )r   rW  r   KeyErrorr  __contains__r   r   )r   r\  r8  s      r   testExtensionContainsErrorz/Proto2ReflectionTest.testExtensionContainsErrorY  sk    (88:Nh 9 9 F FJ//::IIEh 9 9 F FNr    c                 &   t        j                         }t         j                  }| j                  |j	                  |             | j                  ||j                         | j                  d|j                  |          | j                  |j	                  |             | j                  ||j                         d|j                  |<   | j                  d|j                  |          | j                  |j	                  |             | j                  ||j                         |j                  |       | j                  d|j                  |          | j                  |j	                  |             | j                  ||j                         y Nr   r   )r   r  r  r[   HasExtensionassertNotInr  rK   r   rc  ClearExtension)r   r\  	extensions      r   'testTopLevelExtensionsForOptionalScalarz<Proto2ReflectionTest.testTopLevelExtensionsForOptionalScalara  sD   !335N55I^00;<Y 9 9:Q11)<= 	^00;<Y 9 9:+-Ni(R229=>OON//	:;MM)^667!!),Q11)<=^00;<Y 9 9:r    c                    t        j                         }t         j                  }| j                  dt	        |j
                  |                | j                  ||j
                         |j
                  |   j                  d       | j                  dg|j
                  |          | j                  ||j
                         |j
                  |   }|j                  |       | j                  dt	        |j
                  |                | j                  ||j
                         | j                  ||j
                  |          | j                  t        t        j                  |j
                  |d       y )Nr   r   rz  )r   r  r  rK   r9   r  ro  r   rc  rp  r   r   r   operatorsetitem)r   r\  rq  string_lists       r   'testTopLevelExtensionsForRepeatedScalarz<Proto2ReflectionTest.testTopLevelExtensionsForRepeatedScalarv  s/   !335N66IQN55i@ABY 9 9:i(//6eWn77	BCMM)^667 ++I6K!!),QN55i@ABY 9 9:[.";";I"FGi!1!1>3L3L&r    c                 ^   t        j                         }t         j                  }| j                  |j	                  |             | j                  ||j                         | j                  d|j                  |   j                         | j                  |j	                  |             | j                  ||j                         d|j                  |   _        | j                  d|j                  |   j                         | j                  |j	                  |             | j                  ||j                         |j                  |   }|j                  |       | j                  ||j                  |          d|_        | j                  d|j                         | j                  |j                  d             | j                  |j	                  |             | j                  ||j                         | j                  t        t         j"                  |j                  |d       y )Nr   r   r  rt   rz  )r   r  "optional_foreign_message_extensionr[   rn  ro  r  rK   rt   r   rc  rp  r   r\   r   r   rt  ru  )r   r\  rq  foreign_messages       r   (testTopLevelExtensionsForOptionalMessagez=Proto2ReflectionTest.testTopLevelExtensionsForOptionalMessage  s   !335N??I^00;<Y 9 9:Q11)<>>? 	^00;<Y 9 9:-/Ni(*R229=??@OON//	:;MM)^667$//	:O!!),_n&?&?	&JK OR**+OOO,,S12^00;<Y 9 9:i!1!1>3L3L&r    c                    t        j                         }t         j                  }| j                  dt	        |j
                  |                |j
                  |   j                         }d|_        | j                  d|j
                  |   d   j                         d|_        | j                  d|j
                  |   d   j                         |j
                  |   }|j                  |       | j                  dt	        |j
                  |                | j                  ||j
                  |          | j                  t        t        j                  |j
                  |d       y )Nr   r   r  rz  )r   r  repeatedgroup_extensionrK   r9   r  rC  rz  rp  r   r   r   rt  ru  )r   r\  rq  group
group_lists        r   (testTopLevelExtensionsForRepeatedMessagez=Proto2ReflectionTest.testTopLevelExtensionsForRepeatedMessage  s,   !335N44IQN55i@AB%%i0446EEGR229=a@BBCEGR229=a@BBC**95J!!),QN55i@ABZ!:!:9!EFi!1!1>3L3L&r    c                 V   t        j                         }t         j                  j                  }| j	                  |j                  |             | j                  ||j                         |j                  |   }| j                  d|j                         | j	                  |j                  |             | j                  ||j                         d|_	        | j                  d|j                  |   j                         | j                  |j                  |             | j                  ||j                         |j                  |       | j                  ||j                  |          | j	                  |j                  |             | j                  ||j                         y rm  )r   r  TestRequiredsingler[   rn  ro  r  rK   rz  r   rc  rp  r   )r   r\  rq  requireds       r   testNestedExtensionsz)Proto2ReflectionTest.testNestedExtensions  sP   !335N))00I 	^00;<Y 9 9:((3HQ

#^00;<Y 9 9:HJR229=??@OON//	:;MM)^667!!),X~88CD^00;<Y 9 9:r    c                    t         j                  j                  }| j                  |j	                  t         j
                  j                  d             | j                  |j                  d      j                  t         j
                  j                         | j                  dt        |j                  t         j                  j                                     y )Nrc   z*protobuf_unittest.optional_int32_extensionr   )r   r   poolr   FindExtensionByNumberr  assertIsFindExtensionByNamer  rK   r9   FindAllExtensionsrZ   )r   r  s     r   testRegisteredExtensionsz-Proto2ReflectionTest.testRegisteredExtensions  s    ""''DOO""**55q	:; 	MM  8	::I/&&113 	Q|88CCDF Gr    c                    t        j                         }| j                  |j                  d             | j	                  d|j
                  j                  t         j                            | j                  |j                  d             d|j
                  j                  t         j                  <   | j	                  d|j
                  j                  t         j                            | j                  |j                  d             t        j                         }| j                  |j                  d             | j	                  g |j
                  j                  t         j                            | j                  |j                  d             |j
                  j                  t         j                     j                  d       | j	                  dg|j
                  j                  t         j                            | j                  |j                  d             t        j                         }| j                  |j                  d             | j	                  d|j
                  j                  t         j                     j                         | j                  |j                  d             d|j
                  j                  t         j                     _        | j	                  d|j
                  j                  t         j                     j                         | j                  |j                  d             t        j                         }| j                  |j                  d             | j	                  dt        |j
                  j                  t         j                                  | j                  |j                  d             |j
                  j                  t         j                     j                         }| j	                  ||j
                  j                  t         j                     d          | j                  |j                  d             y )N
submessager   r   )r   TopLevelMessager[   r\   rK   r  r  rX  r   rY  r   rZ  r[  r9   repeated_message_extensionrC  )r   toplevelrf  s      r   (testHasBitsForAncestorsOfExtendedMessagez=Proto2ReflectionTest.testHasBitsForAncestorsOfExtendedMessage  sy   "224HX&&|45Q++66224 5X&&|4568 ""224R,,77224 5OOH%%l34 #224HX&&|45R,,77224 5X&&|45""2244:F2JbT8..99224 5OOH%%l34 #224HX&&|45Q++666688K8KMX&&|45NP ""6688KR,,776688K8KMOOH%%l34 #224HX&&|45QH//::668 9 :X&&|45!!,,6688; Wh11<<66889; <OOH%%l34r    c                     t        j                         }|j                  }t         j                  }|j                  |   }|j                  |       d|_        | j                  ||j                  |          y r   )r   r  r  rZ  r  rp  r[  r   )r   r  r\  rq  extension_protos        r   *testDisconnectionAfterClearingEmptyMessagez?Proto2ReflectionTest.testDisconnectionAfterClearingEmptyMessage  sg    "224H((N#>>I$//	:O!!),*,O'_n&?&?	&JKr    c                 t   t        j                         }| j                  t        |j                  d       | j                  t        |j
                  d       | j                  t        |j                  j                  d       | j                  t        |j                  j                  dd       t        j                  t        j                  t        j                  t        j                  fD ]  }| j                  t        |j                  |       | j                  t        |j
                  |       | j                  t        |j                  j                  |       | j                  t        |j                  j                  |d        | j                  t        |j                  t         j                         y )Nr   r   )r   r  r   ri  rn  rp  r  r  r  r   rX  rZ  rY  r  r  )r   r\  unknown_handles      r   testExtensionFailureModesz.Proto2ReflectionTest.testExtensionFailureModes  sW   !335N 	h ; ;TBh = =tDh 9 9 E EtLh 9 9 E EtQO /EE.II.EE.IIK + ."="=&(
."?"?&(
.";";"G"G&(
.";";"G"G&++  	h ; ;"<<>r    c                     t        j                         }d|j                  _        t        j                         }|j	                  |       | j                  d|j                  j                         y )Nrv   )r   rZ   r  rz  r   rK   r   r   r   s      r   testMergeFromOptionalGroupz/Proto2ReflectionTest.testMergeFromOptionalGroup5  sV    &&(FF&&(F
VR--//0r    c                 
   t        j                         }d|j                  t         j                  <   t        j                         }|j	                  |       | j                  d|j                  t         j                            y r  )r   r  r  r  r   rK   r  s      r   testMergeFromExtensionsSingularz4Proto2ReflectionTest.testMergeFromExtensionsSingular=  sg    ++-F?@Fl;;<++-F
V	6\BBCEr    c                 
   t        j                         }|j                  t         j                     j	                  d       |j                  t         j                     j	                  d       t        j                         }|j                  t         j                     j	                  d       |j                  |       | j                  dt        |j                  t         j                                  | j                  d|j                  t         j                     d          | j                  d|j                  t         j                     d          | j                  d|j                  t         j                     d          y )Nrc   rd   r   re   )r   r  r  r  r   r   rK   r9   r  s      r   testMergeFromExtensionsRepeatedz4Proto2ReflectionTest.testMergeFromExtensionsRepeatedF  s1   ++-F
l;;<CCAF
l;;<CCAF++-F
l;;<CCAF
V	3v  !F!FGHJ	6\BBCAFH	6\BBCAFH	6\BBCAFHr    c                    t        j                         }|j                  t         j                     }|j	                         }d|_        |j	                         }d|_        t        j                         }|j                  t         j                     }|j	                         }d|_        |j                  |       |j                  t         j                     }| j                  dt        |             | j                  d|d   j
                         | j                  d|d   j
                         | j                  d|d   j
                         y )N   iM  o   re   r   rc   rd   )	r   r  r  !repeated_nested_message_extensionrC  rq   r   rK   r9   )r   r   ext1rD  r   ext2s         r   $testMergeFromExtensionsNestedMessagez9Proto2ReflectionTest.testMergeFromExtensionsNestedMessageW  s	   ++-F668D
AAD
AAD++-F668D
AAD
V668DQD	"S$q'**%S$q'**%S$q'**%r    c                     t        j                         dk(  ry t        j                         }t        j                         }| j                  t        |j                  |       y )Nr   )r   r   r   rZ   r  r   r   rQ  r  s      r   testCopyFromBadTypez(Proto2ReflectionTest.testCopyFromBadTypen  sJ      H,&&(F++-Fi&9r    c                 Z   t        j                         }t        j                         dk(  rt	        j
                  |       nt	        j                  |       |j                          | j                  |j                         d       t        j                         }| j                  ||       t        j                         }t	        j                  |       |j                          | j                  |j                         d       t        j                         }| j                  ||       y )Nr   r   )r   rZ   r   r   r   r8  SetAllNonLazyFieldsre  rK   r   r  SetAllExtensions)r   r_   empty_protos      r   	testClearzProto2ReflectionTest.testClearw  s    %%'E  H,U###E*	KKMU^^%q)++-KUK( **,Eu%	KKMU^^%q)002KUK(r    c                    t        j                         }d|j                  _        |j                  }| j	                  |j
                  j                  d       | j	                  |j                  j                  d       d|j
                  _        | j	                  |j                  j                  d       | j	                  |j                  d       d|_        y )Nr   r   r(     )r   
TestOneof2foo_messagemoo_intrK   foo_lazy_message)r   rD  sub_messages      r   testDisconnectingInOneofz-Proto2ReflectionTest.testDisconnectingInOneof  s    !AAMM--KQ''//3Q]]**A.!"AQ]]**A.[((!,Kr    c                     | j                  |j                                |j                          |j                          y r"   )r   IsInitializedr   SerializePartialToStringr}  s     r   assertInitializedz&Proto2ReflectionTest.assertInitialized  s/    OOE'')*		""$r    Nc                 0   g }| j                  |j                                | j                  |j                  |             | j                  |t        |             | j	                  t
        j                  |j                         |j                          y r"   )	r[   r  rK   r9   r   r	   EncodeErrorr   r  )r   r_   
error_sizeerrorss       r   assertNotInitializedz)Proto2ReflectionTest.assertNotInitialized  ss    FU((*+U((01ZV-g))5+B+BC	""$r    c                 L   t        j                         }| j                  |       t        j                         }| j                  |       t        j                         }| j                  |d       dx|_        x|_        |_        | j                  |       t        j                         }| j                  |       d|j                  _        | j                  |d       d|j                  _        d|j                  _        | j                  |       |j                  j                         }| j                  |d       dx|_        x|_        |_        | j                  |       t        j                         }t         j                  j                  }|j                  |   j                         }|j                  |   j                         }| j                  |d       d|_        d|_        d|_        | j                  |d       d|_        d|_        d|_        | j                  |       t        j                         }t         j                  j                  }d|j                  |   _        | j                  |d       d|j                  |   _        d|j                  |   _        | j                  |       g }t        j                         }| j!                  |j#                  |             | j%                  |g d       | j'                  t(        |j"                  ddd       y )Nre   rd   rc   r   r(  rz  brt   )r   rZ   r  r  r  r  rz  r  rt   r  optional_messager  rC  multir  r  r[   r  rK   r   r   )r   r_   rL  rq  rM  r  s         r   testIsInitializedz&Proto2ReflectionTest.testIsInitialized  s   %%'E5!**,E5! %%'EeQ'"##EG#eg5! ,,.E5! EeQ' E E5! %%))+HeQ'+,,HJ,hj5! **,E))//I	*..0H	*..0HeQ'HJHJHJeQ'HJHJHJ5! **,E))00I$%EY!eQ'$%EY!$%EY!5! F%%'EU((01V_-i!4!4aA>r    r   zBErrors are only available from the most recent C++ implementation.c           
         d}d}t        j                         }||_        ||_        |j                  j                         }d|_        t        j                  |||j                                d}||_        |j                  j                         }d|_        | j                  t              5 }t        j                  |||j                                | j                  t        |d      dt        |j                  d|j                        z         | j                  dt!        |j"                               | j                  d	t!        |j"                               d d d        y # 1 sw Y   y xY w)
Nz!test_file_descriptor_errors.protomsg1)serialized_pbz)another_test_file_descriptor_errors.protomsg2	exception%s not raisedr;   z test_file_descriptor_errors.msg1)r   FileDescriptorProtor  packager  rC  r   FileDescriptorr   r   r   r   hasattrr   rd  rc  r   r  )r   	file_namepackage_namefile_descriptor_protor  another_file_namer  cms           r   testFileDescriptorErrorsz-Proto2ReflectionTest.testFileDescriptorErrors  sH    4I6L*>>@!*$0!		+	+	/	/	1BBG+==?A
 D!2		+	+	/	/	1BBG			9	% K

-??AC oogb+.bkk:r{{C1D E
mm7R\\9JK mm6BLL8IJK K Ks   -B/E%%E.c                 (   t        j                         }t         j                  }|j                  }d}|j	                  d      }||j
                  |   _        |j                         }| j                  |j                         t        |             t        j                         }|j                  |      }| j                  t        |      |       t        j                         }	| j                  dt        |j                               | j                  |j                  d   j                  d       | j!                  |j                  d   j"                  j%                  |             |	j                  |j                  d   j"                        }| j                  t        |j                  d   j"                        |       | j                  t'        |	j                        t               | j                  |	j                  |       |j                  d   j"                  j)                  |t        |      dz        }
d}	 |	j                  |
       |	j                  }| j!                  |xs t'        |      t,        u        y # t*        $ r d}Y >w xY w)	Nrj  rk  rc   r   iʿ   FT)r   TestMessageSetTestMessageSetExtension2message_set_extensionrm  r  r   r   rK   r   r9   r   RawMessageSetrs  rf  type_idr   r	   endswithrl  replaceUnicodeDecodeErrorr   )r   r_   extension_messagerq  	test_utf8test_utf8_bytesru  rawrt  rM  badbytesunicode_decode_failedstring_fields                r   testStringUTF8Serializationz0Proto2ReflectionTest.testStringUTF8Serialization  s   &557E2KK!77II&&w/O '0EY# ((*J 	U^^%s:7

)
)
+C$$Z0JS_j1)BBDHQCHH&SXXa[(((3 	OOCHHQK''00AB))#((1+*=*=>JS!,,-z:T(,,'-X\\9- xx{""**_-79H "#x( <<LOO)HT,-?5-HI  #"#s   J JJc                     t        j                         }| j                  |j                  d             |j                  j                          | j                  |j                  d             y )Nr  )r   rZ   r[   r\   r  SetInParentr   r}  s     r   testSetInParentz$Proto2ReflectionTest.testSetInParent>  sN    %%'EU^^O45	##%OOENN?34r    c                     ddl m} |j                  j                         }| j	                  d|j
                  j                         y)a  Test that we can import nested messages from their __init__.py.

    Such setup is not trivial since at the time of processing of __init__.py one
    can't refer to its submodules by name in code, so expressions like
    google.protobuf.internal.import_test_package.inner_pb2
    don't work. They do work in imports, so we have assign an alias at import
    and then use that alias in generated code.
    r   )import_test_package9   N)google.protobuf.internalr  myprotoOuterrK   innerr   )r   r  msgs      r   testPackageInitializationImportz4Proto2ReflectionTest.testPackageInitializationImportD  s3     =

%
%
+
+
-CR)r    r"   ):r;   r<   r=   r~  rQ   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r	  r3  r   SkipReferenceLeakCheckerrT  r`  rg  rk  rr  rw  r{  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  unittestskipIfr   r   r  r  r  r  rD   r    r   rx  rx    sc    #D-
7O9b?M  ,
'3RG	E7X0tD:	31*Q,f;:	<G$!<F -,,-OP<5 Q<5|840O;*&"&:&";(G$/5bL>>1EH"&.:).%%9?v 8??8+JLKLK>4Jl5*r    rx  c                   $    e Zd Zd Zd Zd Zd Zy)TestAllTypesEqualityTestc                 h    t        j                         | _        t        j                         | _        y r"   )r   rZ   first_protosecond_protor)   s    r   setUpzTestAllTypesEqualityTest.setUp]  s$    #002D$113Dr    c                 N    | j                  t        t        | j                         y r"   r   r   hashr  r)   s    r   testNotHashablez(TestAllTypesEqualityTest.testNotHashablea      it'7'78r    c                 P    | j                  | j                  | j                         y r"   )rK   r  r)   s    r   testSelfEqualityz)TestAllTypesEqualityTest.testSelfEqualityd  s    T%%t'7'78r    c                 P    | j                  | j                  | j                         y r"   rK   r  r  r)   s    r   testEmptyProtosEqualz-TestAllTypesEqualityTest.testEmptyProtosEqualg      T%%t'8'89r    N)r;   r<   r=   r  r  r  r  rD   r    r   r  r  Z  s    499:r    r  c                   R    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y)FullProtosEqualityTestz@Equality tests using completely-full protos as a starting point.c                     t        j                         | _        t        j                         | _        t	        j
                  | j                         t	        j
                  | j                         y r"   )r   rZ   r  r  r   r8  r)   s    r   r  zFullProtosEqualityTest.setUpp  sL    #002D$113D4++,4,,-r    c                 N    | j                  t        t        | j                         y r"   r  r)   s    r   r  z&FullProtosEqualityTest.testNotHashablev  r   r    c                 t    | j                  | j                  d        | j                  d | j                         y r"   )r]  r  r  r)   s    r   testNoneNotEqualz'FullProtosEqualityTest.testNoneNotEqualy  s.    (($/d//0r    c                     t        j                         }| j                  | j                  |       | j                  || j                         y r"   )r   r  r]  r  r  )r   third_protos     r   testNotEqualToOtherMessagez1FullProtosEqualityTest.testNotEqualToOtherMessage}  s<    ++-K((+6T%6%67r    c                 P    | j                  | j                  | j                         y r"   r  r)   s    r   testAllFieldsFilledEqualityz2FullProtosEqualityTest.testAllFieldsFilledEquality  r  r    c                    | j                   xj                  dz  c_        | j                  | j                   | j                         | j                   j	                  d       | j                  | j                   | j                         y )Nrc   rW   )r  rW   r]  r  r   r)   s    r   testNonRepeatedScalarz,FullProtosEqualityTest.testNonRepeatedScalar  sf    ##q(#(($*;*;< 01(($*;*;<r    c                    | j                   j                  xj                  dz  c_        | j                  | j                   | j                         | j                   j                  xj                  dz  c_        | j                  | j                   | j                         | j                   j                  j                  d       | j                  | j                   | j                         | j                  j                  j                  | j                   j                  _        | j                  | j                   | j                         | j                   j                  d       | j                  | j                   | j                         y )Nrc   rq   ry   )r  ry   rq   r]  r  rK   r   r)   s    r   testNonRepeatedCompositez/FullProtosEqualityTest.testNonRepeatedComposite  s    ,,//14/(($*;*;<,,//14/T%%t'8'89,,77=(($*;*;<1144 	,,/T%%t'8'89 9:(($*;*;<r    c                    | j                   j                  j                  d       | j                  | j                   | j                         | j                   j                  d       | j                  | j                   | j                         y )Nr   rh   )r  rh   r   r]  r  r   r)   s    r   testRepeatedScalarz)FullProtosEqualityTest.testRepeatedScalar  si    ##**1-(($*;*;< 01(($*;*;<r    c                 t   | j                   j                  d   xj                  dz  c_        | j                  | j                   | j                         | j                   j                  d   xj                  dz  c_        | j                  | j                   | j                         | j                   j                  j                          | j                  | j                   | j                         | j                  j                  j                          | j                  | j                   | j                         y )Nr   rc   )r  rw   rq   r]  r  rK   rC  r)   s    r   testRepeatedCompositez,FullProtosEqualityTest.testRepeatedComposite  s    ,,Q/22a72(($*;*;<,,Q/22a72T%%t'8'89,,002(($*;*;<--113T%%t'8'89r    c                     | j                   j                  d       d| j                  _        | j	                  | j                   | j                         y )NrW   r   )r  r   r  rW   r]  r)   s    r   testNonRepeatedScalarHasBitsz3FullProtosEqualityTest.testNonRepeatedScalarHasBits  sC     	 01'(D$(($*;*;<r    c                    | j                   j                  d       | j                  j                  j                  d       | j	                  | j                   | j                         d| j                   j                  _        | j                   j                  j                  d       | j                  | j                   | j                         y )Nry   rq   r   )r  r   r  ry   r]  rq   rK   r)   s    r   testNonRepeatedCompositeHasBitsz6FullProtosEqualityTest.testNonRepeatedCompositeHasBits  s     	 9:--88>(($*;*;<23D,,/,,77=T%%t'8'89r    N)r;   r<   r=   r>   r  r  r  r  r  r  r  r  r  r  r  rD   r    r   r  r  k  s?     I.918
:== =
:=:r    r  c                       e Zd Zd Zy)ExtensionEqualityTestc                    t        j                         }t        j                         }| j                  ||       t        j                  |       | j                  ||       t        j                  |       | j                  ||       |j                  t         j                  xx   dz  cc<   | j                  ||       |j                  t         j                  xx   dz  cc<   | j                  ||       |j                  t         j                         d|j                  t         j                  <   | j                  ||       d|j                  t         j                  <   | j                  ||       t        j                         }t        j                         }| j                  d|j                  t         j                            | j                  ||       y )Nrc   r   )	r   r  rK   r   r  r]  r  r  rp  r   r  r  s      r   testExtensionEqualityz+ExtensionEqualityTest.testExtensionEquality  sy   002K113L[,/{+\2|,[,/ <@@AQFA\2<@@AQFA[,/ |DDEEFLLAAB\2DEK<@@A[,/ 002K113L	;!!,"G"GHJ[,/r    N)r;   r<   r=   r"  rD   r    r   r  r    s    0r    r  c                       e Zd Zd Zy)MutualRecursionEqualityTestc                 T   t        j                         }t        j                         }| j                  ||       d|j                  j                  j                  _        | j                  ||       d|j                  j                  j                  _        | j                  ||       y r   )r   r  rK   rq   rz  rW   r]  r!  s      r   testEqualityWithMutualRecursionz;MutualRecursionEqualityTest.testEqualityWithMutualRecursion  s~    335K446L[,/)+KNN&\2*,LOO'[,/r    N)r;   r<   r=   r&  rD   r    r   r$  r$    s    0r    r$  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d Zd Zd Zd Zd Zd Zd Zd Zd Zy)ByteSizeTestc                     t        j                         | _        t        j                         | _        t        j                         | _        t        j                         | _	        y r"   )
r   rZ   r_   r   rW  extended_protoTestPackedTypespacked_protoTestPackedExtensionspacked_extended_protor)   s    r   r  zByteSizeTest.setUp  sE    **,DJ-==?D$446D!-!B!B!DDr    c                 6    | j                   j                         S r"   )r_   r   r)   s    r   SizezByteSizeTest.Size  s    ::  r    c                 X    | j                  d| j                  j                                y r   )rK   r_   r   r)   s    r   testEmptyMessagezByteSizeTest.testEmptyMessage  s    Q

++-.r    c                     t        j                         }| j                  d|j                                t        j                  d      }| j                  d|j                                y )Nr   rc   )r   rd   )r   rZ   rK   r   )r   r_   proto_kwargss      r   testSizedOnKwargszByteSizeTest.testSizedOnKwargs 	  sP    %%'EQ(),,a@LQ--/0r    c                       fd} |dd        |dd       t        t        ddd      t        dd            D ]  \  }} |d|z  dz
  |         |dd        |d	d        |d
d       y )Nc                     j                   j                          | j                   _        j                  |dz   j	                                y r  )r_   re  r   rK   r0  )rP   expected_varint_sizer   s     r   Testz&ByteSizeTest.testVarints.<locals>.Test		  s=    
jj"#djj +a/=r    r   rc   r  ?   r  r.  r   r  r  )ziprL   )r   r9  rP   	num_bytess   `   r   testVarintszByteSizeTest.testVarints	  sr    > 	AJAJE!ROU1e_= $9
AFa<#$RLRLRr    c                    d| j                   _        | j                  d| j                                d| j                   _        | j                  dt	        | j                   j                        z   | j                                d| j                   _        | j                  dt	        | j                   j                        z   | j                                y )Nr  rd   r   ڀxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxre   )r_   rV   rK   r0  r9   r)   s    r   testStringszByteSizeTest.testStrings	  s    !#DJJQ		$!&DJJQTZZ7788$))+F!*DJJQTZZ7788$))+Fr    c                    d| j                   _        | j                  d| j                                t	        j
                         | _         d| j                   _        | j                  d| j                                t	        j
                         | _         d| j                   _        | j                  d| j                                t	        j
                         | _         d| j                   _        | j                  d| j                                t	        j
                         | _         d| j                   _	        | j                  d| j                                t	        j
                         | _         y )Nr   r   	   gX9v?@   re   )
r_   r   rK   r0  r   rZ   r  rY   rX   r  r)   s    r   testOtherNumericszByteSizeTest.testOtherNumerics$	  s    "&DJJQ		$**,DJ"&DJJQ		$**,DJ %DJJQ		$**,DJ!&DJJQ		$**,DJ!#DJJQ		$**,DJr    c                 z    d| j                   j                  _        | j                  d| j	                                y )Ni @  r  )r_   ry   rq   rK   r0  r)   s    r   testCompositeszByteSizeTest.testComposites>	  s,    -4DJJ&&) 	]DIIK0r    c                 z    d| j                   j                  _        | j                  d| j	                                y )Ni    r   )r_   r  rz  rK   r0  r)   s    r   
testGroupszByteSizeTest.testGroupsF	  s,    ")DJJ 	[$))+.r    c                     | j                   j                  j                  d       | j                   j                  j                  d       | j                  d| j	                                y Nr      r  )r_   rh   r   rK   r0  r)   s    r   r  z ByteSizeTest.testRepeatedScalarsM	  sH    JJ$$R(JJ$$S)[$))+.r    c                     | j                   j                  j                  ddg       | j                  d| j	                                y rJ  )r_   rh   r   rK   r0  r)   s    r   testRepeatedScalarsExtendz&ByteSizeTest.testRepeatedScalarsExtendS	  s4    JJ$$b#Y/[$))+.r    c                 b   | j                   j                  j                  d       | j                   j                  j                  d       | j                  d| j	                                | j                   j                  j                  d       | j                  d| j	                                y )Nr   rK  r  re   )r_   rh   r   rK   r0  r\  r)   s    r   r  z&ByteSizeTest.testRepeatedScalarsRemoveX	  sv    JJ$$R(JJ$$S)[$))+.JJ$$S)UDIIK(r    c                     | j                   j                  j                         }| j                   j                  j                         }d|_        | j	                  d| j                                y )Nr  r6   )r_   rw   rC  rq   rK   r0  )r   foreign_message_0foreign_message_1s      r   r  z#ByteSizeTest.testRepeatedComposites`	  sT    

::>>@

::>>@*DIIK8r    c                 $   | j                   j                  j                         }| j                   j                  j                         }d|_        | j	                  d| j                                t        j                  | j                   j                        }| j                   j                  d= | j	                  d| j                                | j                   j                  j                         }d|_        | j	                  d| j                                | j                   j                  d= | j	                  d| j                                | j                   j                  d= | j	                  d| j                                | j	                  dt        |             |dd= t        j                         d	k(  r| j	                  dt        |             |d
= t        j                         d	k(  r| j	                  dt        |             y y )NrB  r6   r   r   rv   r   rc   rd   r   r.  )r_   rw   rC  rq   rK   r0  rZ  r[  r9   r   r   )r   rP  rQ  rw   foreign_message_2s        r   testRepeatedCompositesDeletez)ByteSizeTest.testRepeatedCompositesDeleteh	  s   

::>>@

::>>@*DIIK8"mm

**, 	

**1-]DIIK0 

::>>@ 	2DIIK@ 	

**1-]DIIK0

**1-Q		$Q345!$ H,
q#567# H,
q#567 -r    c                     | j                   j                  j                         }| j                   j                  j                         }d|_        | j	                  d| j                                y )Nr  r   )r_   r{  rC  rz  rK   r0  )r   group_0group_1s      r   testRepeatedGroupszByteSizeTest.testRepeatedGroups	  sR    jj&&**,G jj&&**,GGI*DIIK8r    c                    t        j                         }| j                  d|j                                t         j                  }d|j
                  |<   | j                  d|j                                t         j                  j                  j                  d   }| j                  t              5  d|j
                  |<   d d d        y # 1 sw Y   y xY w)Nr   r   rd   rW   )r   r  rK   r   r  r  rZ   r   r   r   ri  )r   r_   rq  r8  s       r   testExtensionszByteSizeTest.testExtensions	  s    **,EQ()55I"$EYQ()%%00??E			8	$ # "eu# # #s   0C		Cc                 0   d| j                   _        | j                  d| j                   j                                d| j                   _        | j                  d| j                   j                                | j                   j	                  d       | j                  d| j                   j                                t
        j                  }d| j                  j                  |<   | j                  d| j                  j                                d| j                  j                  |<   | j                  d| j                  j                                | j                  j                  |       | j                  d| j                  j                                y )Nrc   rd   rK  re   rW   r   )
r_   rW   rK   r   r   r   rX  r*  r  rp  r   rq  s     r   )testCacheInvalidationForNonrepeatedScalarz6ByteSizeTest.testCacheInvalidationForNonrepeatedScalar	  s.    !DJJQ

++-. #DJJQ

++-.JJ*+Q

++-. $::I01D""9-Q++446703D""9-Q++4467&&y1Q++4467r    c                 v   | j                   j                  j                  d       | j                  d| j                   j	                                | j                   j                  j                  d       | j                  d| j                   j	                                d| j                   j                  d<   | j                  d| j                   j	                                | j                   j                  d       | j                  d| j                   j	                                t        j                  }| j                  j                  |   }|j                  d       | j                  d| j                  j	                                |j                  d       | j                  d	| j                  j	                                d|d<   | j                  d
| j                  j	                                | j                  j                  |       | j                  d| j                  j	                                y )Nrc   re   r(  rK  r  rh   r   rd   r/   r   )r_   rh   r   rK   r   r   r   rY  r*  r  rp  )r   rq  repeateds      r   &testCacheInvalidationForRepeatedScalarz3ByteSizeTest.testCacheInvalidationForRepeatedScalar	  s   JJ$$Q'Q

++-.JJ$$Q'Q

++-.#&DJJa Q

++-.JJ*+Q

++-. $::I""--i8HOOAQ++4467OOAQ++4467HQKQ++4467&&y1Q++4467r    c                 &   d| j                   j                  _        | j                  d| j                   j	                                d| j                   j                  _        | j                  d| j                   j	                                | j                   j                  j                  d       | j                  d| j                   j	                                | j                   j                  d       | j                  d| j                   j	                                t        j                         d	k(  rb| j                   j                  }| j                   j                  d       d|_        | j                  d| j                   j	                                t        j                  }| j                  j                  |   }| j                  d| j                  j	                                d|_        | j                  d
| j                  j	                                d|_        | j                  d| j                  j	                                | j                  j                  |       | j                  d| j                  j	                                y )Nrc   r   rK  r(  rt   re   rd  r   r   r/   )r_   rd  rt   rK   r   r   r   r   r   rZ  r*  r  r[  rp  )r   childrq  s      r   *testCacheInvalidationForNonrepeatedMessagez7ByteSizeTest.testCacheInvalidationForNonrepeatedMessage	  s   ,-DJJ'')Q

++-.,/DJJ'')Q

++-.JJ''2237Q

++-.JJ45Q

++-. H,jj11e
jj67eg
q$**--/0 $>>I**95EQ++4467 !EQ++4467 #EQ++4467&&y1Q++4467r    c                    | j                   j                  j                         }| j                  d| j                   j	                                | j                   j                  j                          | j                  d| j                   j	                                d|_        | j                  d| j                   j	                                | j                   j                  d       | j                  d| j                   j	                                t        j                  }| j                  j                  |   }|j                         }| j                  d| j                  j	                                |j                          | j                  d| j                  j	                                d|_        | j                  d| j                  j	                                |j                  d	       | j                  d| j                  j	                                | j                  j                  |       | j                  d| j                  j	                                y )
Nre   r(  rc   r6   rx   r   rd   r/   r[  )r_   rx   rC  rK   r   rt   r   r   r  r*  r  r[  rp  )r   child0rq  
child_lists       r   'testCacheInvalidationForRepeatedMessagez4ByteSizeTest.testCacheInvalidationForRepeatedMessage	  s   ZZ00446FQ

++-.JJ''++-Q

++-.FHQ

++-.JJ45Q

++-. $>>I$$//	:J^^FQ++4467NNQ++4467!"FQ++4467
+,Q++4467&&y1Q++4467r    c                    | j                  d| j                  j                                | j                  j                  j	                  d       | j                  j                  j	                  d       d}| j                  || j                  j                                | j                  j
                  j	                  d       | j                  j
                  j	                  d       d}| j                  ||z   | j                  j                                | j                  j                  d       | j                  || j                  j                                y )	Nr   r   rK  r(  g@g      
@   packed_int32)rK   r,  r   rj  r   packed_doubler   )r   int_sizedouble_sizes      r   testPackedRepeatedScalarsz&ByteSizeTest.testPackedRepeatedScalars
  s   Q))2245""))"-""))#. HXt0099;<##**3/##**40KXk)4+<+<+E+E+GH  0[$"3"3"<"<">?r    c                     | j                  d| j                  j                                | j                  j                  t        j
                     }|j                  g d       | j                  d| j                  j                                y )Nr   rb   ri  )rK   r.  r   r  r   packed_fixed32_extensionr   r\  s     r   testPackedExtensionsz!ByteSizeTest.testPackedExtensions
  sm    Q22;;=>**55--/I\"R33<<>?r    N)r;   r<   r=   r  r0  r2  r5  r=  r@  rD  rF  rH  r  rM  r  r  rT  rX  rZ  r]  r`  rc  rg  rn  rq  rD   r    r   r(  r(    su    E!/1G-41///
)9%8N9
#8$8.8:82@&@r    r(  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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d Zd Zd Z y) SerializationTestc                 >   t        j                         }t        j                         }|j                         }| j                  |j	                         t        |             | j                  t        |      |j                  |             | j                  ||       y r"   )r   rZ   r   rK   r   r9   rs  r   r  r  ru  s       r   testSerializeEmtpyMessagez+SerializationTest.testSerializeEmtpyMessage-
  s~    ++-K,,.L..0J[))+S_=J$$Z02 	[,/r    c                 h   t        j                         }t        j                         }t        j                  |       |j	                         }| j                  |j                         t        |             | j                  t        |      |j                  |             | j                  ||       y r"   )	r   rZ   r   r8  r   rK   r   r9   rs  ru  s       r   testSerializeAllFieldsz(SerializationTest.testSerializeAllFields7
  s    ++-K,,.L;'..0J[))+S_=J$$Z02 	[,/r    c                    t        j                         }t        j                         }t        j                  |       |j	                         }| j                  t        |      |j                  |             | j                  ||       y r"   )r   r  r   r  r   rK   r9   rs  ru  s       r   testSerializeAllExtensionsz,SerializationTest.testSerializeAllExtensionsB
  so    002K113L{+..0JJ$$Z02 	[,/r    c                    t        j                         }t        j                         }d|j                  _        |j	                         }| j                  t        |      |j                  |             | j                  ||       y )N   )r   rZ   r  rz  r   rK   r9   rs  ru  s       r   testSerializeWithOptionalGroupz0SerializationTest.testSerializeWithOptionalGroupL
  so    ++-K,,.L"%K..0JJ$$Z02 	[,/r    c                     t        j                         }d|_        d|_        d|_        d|_        d|_        d|_        t         j                  j                  |j                               }| j                  ||       y )Nr.  l     r  l     l     )r   rZ   rW   r   r  r  r  r  r9  r   rK   r!  s      r   testSerializeNegativeValuesz-SerializationTest.testSerializeNegativeValuesV
  st    ++-K!#K!+K"$K",K$&K!$.K!,,77%%')L 	[,/r    c           	         t        j                         dk7  ry t        j                         }t	        j
                  |       t        |j                               }t        t        |      dz         D ]v  }	 t        j                         }t        j                         }|j                  |d|      }| j                  ||       	 |j                  |d|      }| j                  ||       x y # t        j                  $ r | j                  d       Y )w xY w# t        j                  $ r0 | j!                  t        j                  j                  |d|       Y w xY w)Nr   rc   r   z@Parsing unknown fields failed when parsing known fields did not.)r   r   r   rZ   r   r8  
memoryviewr   rL   r9   TestEmptyMessage_InternalParserK   r	   DecodeErrorfailr   )r   r  ru  truncation_pointr  unknown_fieldspospos2s           r   testParseTruncatedz$SerializationTest.testParseTruncatede
  s:    H,++-K;'K99;<J!#j/A"56 ;;#002%668))*a9IJ)3/	 ..z1>NO$


+T
2; "" 	 
))   	     ;'--~/L/L$a)9	;;s2   6AD%C,,$DDDDA EEc                 0   t        j                         }d|_        d|j                  t         j                  <   d|_        d|j                  t         j                  <   d|_        |j                         }| j                  |j                         t        |             t        |      }|j                  }| j                  dt        j                  f |              | j                  d|j!                                | j                  dt        j                  f |              | j                  d|j#                                | j                  dt        j                  f |              | j                  d|j%                                | j                  dt        j                  f |              | j                  d|j'                                | j                  dt        j                  f |              | j                  d|j)                                y )Nr   r/   re   rd   rc   )r   OutOfOrderFieldsr  r  r   r   r   rW   r   rK   r   r9   r   r-   r   WIRETYPE_VARINTr?   r@   rA   rB   rC   r   r_   ru  r  ReadTags        r   testCanonicalSerializationOrderz1SerializationTest.testCanonicalSerializationOrder
  s   ..0E E:;E&667E9:E&556E((*JU^^%s:7Z A**Ga445wyAQ&a445wyAQ&a445wyAQ'a445wyAQ'a445wyAQ'r    c                     t        j                         }t        j                  |       |j	                         }t        j
                  |       y r"   )r   r  r   r  r   #ExpectAllFieldsAndExtensionsInOrder)r   r_   ru  s      r   (testCanonicalSerializationOrderSameAsCppz:SerializationTest.testCanonicalSerializationOrderSameAsCpp
  s:    ++-E''.((*J11*=r    c                 j   t        j                         }|j                  j                  d       d|_        d|j
                  _        |j                         }t        j                         }|j                  j                  d       d|_        d|j
                  _        |j                  |      }| j                  t        |      |       | j                  ddgt        |j                               | j                  d|j                         | j                  d|j
                  j                         y )Nfoobarr   r  r   r  rB  )r   rZ   rk   r   rW   ry   rq   r   rs  rK   r9   rm   )r   r  ru  r  bytes_parseds        r   'testMergeFromStringWhenFieldsAlreadySetz9SerializationTest.testMergeFromStringWhenFieldsAlreadySet
  s    ++-K&&x0!#K-/K''*..0J,,.L  ''."%L.1L((+//
;LS_l3 	eX&\-I-I(JKR445 	R==@@Ar    c                    t        j                         }t         j                  }t         j                  }|j                  }|j                  }t         j
                  }d|j                  |   _        d|j                  |   _        d|j                  |   _	        |j                         }t        j                         }| j                  d|j                  j                         j                          | j                  t#        |      |j%                  |             | j                  dt#        |j&                               t        j                         }	| j                  t#        |j&                  d   j(                        |	j%                  |j&                  d   j(                               | j                  d|	j                         t        j                         }
| j                  t#        |j&                  d   j(                        |
j%                  |j&                  d   j(                               | j                  d|
j                         t        j*                         }| j                  t#        |j&                  d   j(                        |j%                  |j&                  d   j(                               | j                  d|j                         t        j                         }| j                  t#        |      |j%                  |             | j                  d|j                  |   j                         | j                  d|j                  |   j                         | j                  d|j                  |   j                         | j                  |j-                         t#        |             | j                  |j-                         t#        |             y )	Nr   r   r   Fre   r   rc   rd   )r   r  TestMessageSetExtension1r  r  message_set_extension3r  rP   r   textr   r   r  rK   r   
GetOptionsmessage_set_wire_formatr9   rs  rf  r	   TestMessageSetExtension3r   )r   r_   extension_message1extension_message2
extension1
extension2
extension3ru  r  rL  rM  message3r   s                r   testMessageSetWireFormatz*SerializationTest.testMessageSetWireFormat
  s    &557E3LL3LL#99J#99J+BBJ%(EZ "',EZ $(-EZ % ((*J

)
)
+CU^^..0HHJJJ') 	QCHH&)BBDHCHHQK   !!4!457 	S(**%)BBDHCHHQK   !!4!457 	UHLL))BBDHCHHQK   !!4!457 	UHMM* (668FJz*, 	S&++J799:UF--j9==>UF--j9>>? 	V__&J8U^^%s:7r    c                 x   t        j                         }|j                  j                         }d|_        t
        j                  }t        j                         }d|_        |j                         |_	        |j                  j                         }d|_        t
        j                  }t        j                         }d|_        |j                         |_	        |j                  j                         }d|_        t        j                         }d|_        |j                         |_	        |j                         }t        j                         }| j                  t        |      |j                  |             t
        j                  }|j                   }| j                  d|j"                  |   j                         y )Nii90  ii:0  ir   )r   r  rf  rC  r  r   r  rP   r   r	   r  r   r  rK   r9   rs  r  r  )r   r  rf  r  rL  ru  r_   r  s           r   (testMessageSetWireFormatUnknownExtensionz:SerializationTest.testMessageSetWireFormatUnknownExtension
  s\    
)
)
+C 88<<>DDL3LL)BBDHHJ--/DL 88<<>DDL3LL)BBDHHJ--/DL 88<<>DDL)BBDHHL--/DL&&(J '557EJj)+
 4LL#99JUE,,Z8::;r    c                    t        j                         }t        j                  |       |j	                         }t        j
                         }| j                  t        |      |j                  |             t        j                         }d|_	        |j	                         }t        j
                         }| j                  t        |      |j                  |             y )Nl   )
r   rZ   r   r8  r   r  rK   r9   rs  r   )r   r_   ru  r   s       r   testUnknownFieldsz#SerializationTest.testUnknownFields  s    %%'E5!((*J **,F 	Jz*,
 %%'E-E((*J **,FJz*,r    c                     	  |        | j                  dt        |      z        # |$ r%}| j                  |t        |             Y d}~yd}~ww xY w)zEThis method checks if the exception type and message are as expected.r  N)failureExceptionr   rK   )r   	exc_classcallable_objr  exs        r   _CheckRaiseszSerializationTest._CheckRaises4  sR    Dn !!/C	N"BCC  
y#b'*s   & AAAc                    t        j                         }| j                  t        j                  |j
                  d       |j                         }t        j                         }| j                  |j                  d             |j                  |       | j                  |j                  d             d|_
        | j                  t        j                  |j
                  d       |j                         }d|_        | j                  t        j                  |j
                  d       |j                         }d|_        |j                         }|j                         }t        j                         }| j                  t        |      |j                  |             | j                  d|j                         | j                  d|j                         | j                  d|j                         | j                  t        |      |j                  |             | j                  d|j                         | j                  d|j                         | j                  d|j                         y )NzHMessage protobuf_unittest.TestRequired is missing required fields: a,b,crz  rc   zFMessage protobuf_unittest.TestRequired is missing required fields: b,crd   zDMessage protobuf_unittest.TestRequired is missing required fields: cre   )r   r  r  r	   r  r   r  r[   r\   r   rz  r  rt   rK   r9   rs  )r   r_   partialr   ru  s        r   testSerializeUninitializedz,SerializationTest.testSerializeUninitialized?  s   %%'E	 ,,.G&&(FV__S)*
7#V__S)*EGPR
 ,,.GEGNP
 ,,.GEG((*J,,.G&&(FJz*, 	Q!Q!Q!Gw') 	Q!Q!Q!r    c                    t        j                         }|j                          d|j                  _        | j                  t        j                  |j                  d       d|j                  _        d|j                  _	        |j                          d|j                  j                         _        d|j                  j                         _        | j                  t        j                  |j                  d       d|j                  d   _        d|j                  d   _	        d|j                  d   _        d|j                  d   _	        |j                          y )Nrc   zoMessage protobuf_unittest.TestRequiredForeign is missing required fields: optional_message.b,optional_message.crd   re   zMessage protobuf_unittest.TestRequiredForeign is missing required fields: repeated_message[0].b,repeated_message[0].c,repeated_message[1].a,repeated_message[1].cr   )r   r  r   r  rz  r  r	   r  r  rt   r  rC  r}  s     r   $testSerializeUninitializedSubMessagez6SerializationTest.testSerializeUninitializedSubMessager  s(   ,,.E 
 E	01  !E E	%&E "%&E "	67 #$E1"#E1"#E1"#E1	r    c                 v   t        j                         }t        j                         }t        j                  |       |j	                         }| j                  |j                         t        |             |j                  |      }| j                  |j                         |       | j                  ||       y r"   )	r   r+  r   SetAllPackedFieldsr   rK   r   r9   rs  r   r  r  ru  rt  s        r   testSerializeAllPackedFieldsz.SerializationTest.testSerializeAllPackedFields  s    ..0K//1L  -..0J[))+S_=--j9J\**,j9[,/r    c                 $   t        j                         }t        j                         }t        j                  |       |j	                         }|j                  |      }| j                  |j                         |       | j                  ||       y r"   )r   r-  r   SetAllPackedExtensionsr   rs  rK   r   r  s        r    testSerializeAllPackedExtensionsz2SerializationTest.testSerializeAllPackedExtensions  ss    335K446L$$[1..0J--j9J\**,j9[,/r    c                    t        j                         }|j                  j                  ddg       |j                  j                  d       |j                         }t        j                         }|j                  j                  d       |j                  j                  ddg       |j                  j                  d       | j                  t        |      |j                  |             | j                  g d|j                         | j                  g d	|j                         | j                  dg|j                         y )
Nrc   rd         @re   r         @r/   )re   rc   rd   )r  r  r  )r   r+  rj  r   rk  r   r   packed_sint32rK   r9   rs  )r   r  ru  r  s       r   1testMergePackedFromStringWhenSomeFieldsAlreadySetzCSerializationTest.testMergePackedFromStringWhenSomeFieldsAlreadySet  s   ..0K##QF+$$S)..0J//1L$$Q'%%sCj1%%a(J$$Z02 	Y 9 9:_l&@&@AaS,445r    c                    t        j                         }|j                  j                  g d       |j                  j                  ddg       |j
                  j                  d       |j                         }| j                  |j                         t        |             t        |      }|j                  }| j                  dt        j                  f |              | j                  d|j                                | j                  d|j                                | j                  d|j                                | j                  d	|j                                | j                  d
|j                                | j                  dt        j                  f |              | j                  d|j                                | j                  d|j!                                | j                  dt        j                  f |              | j                  d|j                                | j                  d|j#                                | j                  d|j#                                | j%                  |j'                                y )N)rc   rd      re   r  g     @@r  Z   r   rc   rd   r  re   r  r/   e   rc  )r   r+  rj  r   rk  packed_floatr   r   rK   r   r9   r   r-   r   WIRETYPE_LENGTH_DELIMITEDr?   r3   r7   r   r:   r  s        r   testPackedFieldsWireFormatz,SerializationTest.testPackedFieldsWireFormat  s   ((*E	n-	V}-	c"((*JU^^%s:7Z A**Gb+??@')LWakkm,Q&Q&S!++-(Q&c;@@A79MQ&S!++-(c;@@A79MS!++-(S!,,.)VQ\\^,OOAMMO$r    c                 h   t        j                         }t        j                  |       t        j                         }|j                         }| j                  t        |      |j                  |             t        j                         }t        j                  |       | j                  ||       y r"   )
r   TestUnpackedTypesr   SetAllUnpackedFieldsr+  r   rK   r9   rs  r  )r   unpackedpackedru  rd  s        r   testParsePackedFromUnpackedz-SerializationTest.testParsePackedFromUnpacked  s    --/H""8,))+F++-JJz*, ++-H  *Xv&r    c                 h   t        j                         }t        j                  |       t        j                         }|j                         }| j                  t        |      |j                  |             t        j                         }t        j                  |       | j                  ||       y r"   )
r   r+  r   r  r  r   rK   r9   rs  r  )r   r  r  ru  rd  s        r   testParseUnpackedFromPackedz-SerializationTest.testParseUnpackedFromPacked  s    ))+F  (--/H))+JJ  ,. --/H""8,Xx(r    c                 4   t        j                         }| j                  t         j                  j                  j                  d       | j                  t         j                  j
                  d       | j                  t         j                  j                  d       | j                  t         j                  j                  d       | j                  t         j                  j                  d       | j                  t         j                  j                  d       | j                  t         j                  j                  d       | j                  t         j                  j                  d       | j                  t         j                  j                  d       y )	Nrc   rc     r      r  r  3   )r   rZ   rK   rz   BB_FIELD_NUMBEROPTIONAL_INT32_FIELD_NUMBEROPTIONALGROUP_FIELD_NUMBER$OPTIONAL_NESTED_MESSAGE_FIELD_NUMBER!OPTIONAL_NESTED_ENUM_FIELD_NUMBERREPEATED_INT32_FIELD_NUMBERREPEATEDGROUP_FIELD_NUMBER$REPEATED_NESTED_MESSAGE_FIELD_NUMBER!REPEATED_NESTED_ENUM_FIELD_NUMBERr}  s     r   testFieldNumbersz"SerializationTest.testFieldNumbers  s"   %%'E\..<<LLaP\..JJAN\..II2NDDbJAA2G\..JJBO\..II2NDDbJAA2Gr    c                    | j                  t        j                  j                  j                  d       | j                  t        j                  j
                  d       | j                  t        j                  j                  j                  d       | j                  t        j                  j                  d       | j                  t        j                  j                  d       | j                  t        j                  d       | j                  t        j                  j                  d       | j                  t        j                  d       | j                  t        j                  j                  d       | j                  t        j                  d       | j                  t        j                  j                  d       | j                  t        j                  d       | j                  t        j                   j                  d       | j                  t        j"                  d       | j                  t        j$                  j                  d       | j                  t        j&                  d       | j                  t        j(                  j                  d	       | j                  t        j*                  d	       | j                  t        j,                  j                  d
       | j                  t        j.                  d
       y )Ni  i  rc   rc  r  r   r  r  r  r  )rK   r   r  r  r  SINGLE_FIELD_NUMBERr  MULTI_FIELD_NUMBERr  %OPTIONAL_INT32_EXTENSION_FIELD_NUMBERoptionalgroup_extension$OPTIONALGROUP_EXTENSION_FIELD_NUMBER!optional_nested_message_extension.OPTIONAL_NESTED_MESSAGE_EXTENSION_FIELD_NUMBERoptional_nested_enum_extension+OPTIONAL_NESTED_ENUM_EXTENSION_FIELD_NUMBERr  %REPEATED_INT32_EXTENSION_FIELD_NUMBERr}  $REPEATEDGROUP_EXTENSION_FIELD_NUMBERr  .REPEATED_NESTED_MESSAGE_EXTENSION_FIELD_NUMBERrepeated_nested_enum_extension+REPEATED_NESTED_ENUM_EXTENSION_FIELD_NUMBERr)   s    r   testExtensionFieldNumbersz+SerializationTest.testExtensionFieldNumbers  s   \..55<<dC\..BBDI\..44;;TB\..AA4H\::AA1E\GGK\99@@"E\FFK\CCJJBOAA2G\@@GGL\MM
\::AA2F\GGL\99@@"E\FFK\CCJJBOAA2G\@@GGL\MM
r    c                    t         j                  }| j                  |j                  j                  |j                  j
                  d          | j                  |j                  |j                  j                  j                         | j                  |j                  j                  |j                  j
                  d          | j                  |j                  |j                  j                  j                         | j                  |j                  j                  |j                  j
                  d          | j                  |j                  |j                  j                  j                         y )NrW   ry   rh   )r   rZ   r  rW   r   r   rK   r  r  ry   r  rh   r  )r   clss     r   testFieldPropertiesz%SerializationTest.testFieldProperties  s   

#
#CMM#$$//..//0@ACS44''2299;MM#--88..//0IJLS==00;;BBDMM#$$//..//0@ACS44''2299;r    c                    t        j                         }d|_        | j                  t         j                  j                  j	                  |      d       t         j                  j                  j                  |d       | j                  |j                  d       | j                  t              5  |`d d d        	 t         j                  j                  j	                  |       y # 1 sw Y   4xY w# t        $ r Y y w xY w)Nr  r  )r   rZ   rW   rK   __get____set__r   r   r}   rt   r   )r   r  s     r   testFieldDataDescriptorz)SerializationTest.testFieldDataDescriptor!  s    

#
#
%CC\..==EEcJBO,,44S"=S'',			>	* 

!!##++C0
    
s   0C&<)C2 &C/2	C>=C>c                    t        j                  ddddt         j                  j                  d      t        j                  d      t         j                  j                  t         j
                  g d	      }| j                  |j                                | j                  |j                  d	             | j                  |j                  d
             | j                  |j                  d             | j                  |j                  d             | j                  |j                  d             | j                  |j                  d             | j                  |j                  d             | j                  |j                  d             | j                  d|j                         | j                  d|j                         | j                  d|j                         | j                  d|j                         | j                  d|j                  j                         | j                  d|j                   j"                         | j                  t         j                  j                  |j$                         | j                  t         j
                  |j&                         | j                  g d|j(                         y )Nrc   r   Ts   barrp   rs   rc   rd   re   )	rW   rV   r   r   ry   rd  r  optional_foreign_enumrh   rW   rV   r   r   ry   rd  r  r  )r   rZ   rz   r}   r{   r  r   r  r\   rK   rW   rV   r   r   ry   rq   rd  rt   r  r  rh   r}  s     r   testInitKwargsz SerializationTest.testInitKwargs2  s   %% , 9 9 G G1 G M!-!<!<q!A)66::*66 	"E 	OOE'')*OOENN#345OOENN#456OOENN?34OOENN#345OOENN#<=>OOENN#=>?OOENN#9:;OOENN#:;<Q,,-UE112T5../VU112Q55889Q66889\..22//1\--u/J/JKY 4 45r    c                 8    d }| j                  t        |d       y )Nc                  0    t        j                  d      } y )Nunknown)r  )r   r  )unused_protos    r   (InitalizeEmptyMessageWithExtraKeywordArgz`SerializationTest.testInitArgsUnknownFieldName.<locals>.InitalizeEmptyMessageWithExtraKeywordArgR  s    !229Elr    z9Protocol message TestEmptyMessage has no "unknown" field.)r  r   )r   r  s     r   testInitArgsUnknownFieldNamez.SerializationTest.testInitArgsUnknownFieldNameQ  s     F0CEr    c                    t        j                  ddd      }| j                  |j                                | j                  |j	                  d             | j                  |j	                  d             | j                  |j	                  d             | j                  |j	                  d             | j                  d|j                         | j                  d|j                         | j                  d|j                         y )Nrc   r  rz  r  rt   dummy2)
r   r  r   r  r\   r[   rK   rz  r  rt   r}  s     r   testInitRequiredKwargsz(SerializationTest.testInitRequiredKwargsY  s    %%Q!4EOOE'')*OOENN3'(OOENN3'(OOENN3'(U^^H-.Q Q Q r    c                    t        j                  t        j                  ddd            }| j                  |j	                                | j                  |j                  d             | j                  |j                  j	                                | j                  |j                  j                  d             | j                  |j                  j                  d             | j                  |j                  j                  d             | j                  |j                  j                  d             | j                  t        j                  ddd      |j                         | j                  d|j                  j                         | j                  d|j                  j                         | j                  d|j                  j                         y )	Nrc   r  )r  r  rz  r  rt   r  )r   r  r  r   r  r\   r  r[   rK   rz  r  rt   r}  s     r   testInitRequiredForeignKwargsz/SerializationTest.testInitRequiredForeignKwargsd  s]   ,,%22Q!qACEOOE'')*OOENN#567OOE**88:;OOE**33C89OOE**33C89OOE**33C89U++44X>?\..a1=++-Q..001Q..001Q..001r    c                 ,   t        j                  g d      }| j                  |j                                | j	                  d|j
                  d          | j	                  d|j
                  d          | j	                  d|j
                  d          y )Nr  r   rc   r   rd   re   )r   rZ   r   r  rK   rh   r}  s     r   testInitRepeatedKwargsz(SerializationTest.testInitRepeatedKwargst  sx    %%Y?EOOE'')*Q,,Q/0Q,,Q/0Q,,Q/0r    N)!r;   r<   r=   rv  rx  rz  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  rD   r    r   rs  rs  *
  s    0	0000;<(2>B.48l'<R,6	D1"fB006$%0
'
)G 
4;"6>E	!2 1r    rs  c                       e Zd Zd Zd Zy)OptionsTestc                 $   t        j                         }| j                  d|j                  j	                         j
                         t        j                         }| j                  d|j                  j	                         j
                         y )NTF)r   r  rK   r   r  r  r   rZ   r}  s     r   testMessageOptionszOptionsTest.testMessageOptions  sp    &557ET%%002JJL%%'EU%%002JJLr    c                 L   t        j                         }d|_        d|_        |j	                         D ]/  \  }}| j                  d|j                         j                         1 t        j                         }|j                  j                  d       |j                  j                  d       |j	                         D ]c  \  }}| j                  d|j                         j                         | j                  t        j                  j                  |j                         e y )Nrc   r  FT)r   rZ   rW   rX   r   rK   r  r  r+  rj  r   rk  r   r'  rM  r  )r   r_   field_descriptor_s       r   testPackedOptionszOptionsTest.testPackedOptions  s    %%'EEE$//1 D!
u.99;BBCD ((*E	a 	s#$//1 /!
t-88:AAB
z11@@'--//r    N)r;   r<   r=   r
  r  rD   r    r   r  r  |  s    L/r    r  c                   "   e Zd Z ej                   ej                         dk7  d       ej                  d      d               Z	d Z
 ej                  d      d        Z ej                  d      d        Z ej                  d      d	        Zy
)ClassAPITestr   z6C++ implementation requires a call to MakeDescriptor()zMakeClass is not repeatablec                    t        j                  dddd g g g g t         j                  	      }t        j                  dddd g |gg g t         j                  	      }t        j                  dddd g g g g t         j                  	      }t        j                  d	d
dd g ||gg g t         j                  	      }t        j                  |       y )Nleafzpackage.parent.child.leafr  )r  r  r  r  r  r  rb  zpackage.parent.childsiblingzpackage.parent.siblingparentzpackage.parent)r   r-  r,  r
   	MakeClass)r   	leaf_desc
child_descsibling_descparent_descs        r   !testMakeClassWithNestedDescriptorz.ClassAPITest.testMakeClassWithNestedDescriptor  s    
 %%+RRB224I &&'R[R224J ((+
DB224L ''"BR ,/"224K %r    c                     d|z   dz   }t        j                         }t        j                  ||       |j	                         S )a   Get a serialized representation of a test FileDescriptorProto.

    Args:
      name: All calls to this must use a unique message name, to avoid
          collisions in the cpp descriptor pool.
    Returns:
      A string containing the serialized form of a test FileDescriptorProto.
    zmessage_type {  name: "ai  "  field {    name: "flat"    number: 1    label: LABEL_REPEATED    type: TYPE_UINT32  }  field {    name: "bar"    number: 2    label: LABEL_OPTIONAL    type: TYPE_MESSAGE    type_name: "Bar"  }  nested_type {    name: "Bar"    field {      name: "baz"      number: 3      label: LABEL_OPTIONAL      type: TYPE_MESSAGE      type_name: "Baz"    }    nested_type {      name: "Baz"      enum_type {        name: "deep_enum"        value {          name: "VALUE_A"          number: 0        }      }      field {        name: "deep"        number: 4        label: LABEL_OPTIONAL        type: TYPE_UINT32      }    }  }})r   r  r   Merger   )r   r  file_descriptor_strfile_descriptors       r   _GetSerializedFileDescriptorz)ClassAPITest._GetSerializedFileDescriptor  sO    		()	 V %88:O)?;,,..r    r4  c                    t        j                         dk7  ryt        j                         }|j	                  | j                  d             t        j                  |j                  d          G fddt        j                  t        j                        } |       }d}t        j                  ||       | j                  |j                   g d	       y)
7Test that the generated class can parse a flat message.r   NAr   c                       e Zd ZW  Zy)SClassAPITest.testParsingFlatClassWithExplicitClassDeclaration.<locals>.MessageClassNr"  )msg_descriptors   r   MessageClassr$    s    !jr    r&  r%  flat: 0 flat: 1 flat: 2 r  )r   r   r   r  r   r  r   rN  r  r	   r/  r
   r0  r   r  rK   flat)r   r  r&  r  msg_strr%  s        @r   0testParsingFlatClassWithExplicitClassDeclarationz=ClassAPITest.testParsingFlatClassWithExplicitClassDeclaration  s      H,$88:O##D$E$Ec$JK..$$Q')N":#J#J" .C	  gs#SXXy)r    c                 T   t        j                         }|j                  | j                  d             t	        j
                  |j                  d         }t        j                  |      } |       }d}t        j                  ||       | j                  |j                  g d       y)r!  Br   r'  r  N)r   r  r   r  r   rN  r  r
   r  r   r  rK   r(  r   r  r%  	msg_classr  r)  s         r   testParsingFlatClassz!ClassAPITest.testParsingFlatClass  s     %88:O##D$E$Ec$JK..$$Q')N$$^4I
+C	  gs#SXXy)r    c                 x   t        j                         }|j                  | j                  d             t	        j
                  |j                  d         }t        j                  |      } |       }d}t        j                  ||       | j                  |j                  j                  j                  d       y)z9Test that the generated class can parse a nested message.Cr   zbar {  baz {    deep: 4  }}r/   N)r   r  r   r  r   rN  r  r
   r  r   r  rK   r   r   deepr-  s         r   testParsingNestedClassz#ClassAPITest.testParsingNestedClass"  s     %88:O##D$E$Ec$JK..$$Q')N$$^4I
+C	  gs#SWW[[%%q)r    N)r;   r<   r=   r  r  r   r   r   r  r  r  r*  r/  r3  rD   r    r   r  r    s     8??8+>@ -,,-JK& L@&>6/p -,,-OP* Q*2 -,,-OP* Q* -,,-OP* Q*r    r  __main__).r>   rZ  r   rt  r1   r   warningsr  google.protobufr   r   r   r   r   r   r	   r
   r   r  r   r   r   r   r   r   r   r   r   simplefilterDeprecationWarningobjectr   named_parametersTestCaserH   rx  r  r  r  r$  r(  rs  r  r  r;   mainrD   r    r   <module>r=     sa  @  	   
   / - ( 5 * & # & ' 7 8 6 ? 0 . 5 , 3   g1 2*)6 *)Z !  )*, K@X&& K@ ,K@^ P*8,, P* P*l& :x00 : :  S:X.. S: S:l 0H-- 0 0B 	0("3"3 	0 	0 j@8$$ j@ j@p	 N	1)) N	1 N	1b /(## / /6 Y*8$$ Y* Y*v z(--/ r    