
    iS                       d Z 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	Z	ddl
Z
d 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Z e
j:                  de        ej>                  defdef      ej@                   G d de	j@                                      Z!ej@                   G d de	j@                               Z"ej@                   G d de	j@                               Z#ej@                   G d de	j@                               Z$ej@                   G d d e	j@                               Z% e	jL                   ejN                         d!k(  d"      ej@                   G d# d$e	j@                                      Z(e)d%k(  r e	jT                          yy)&a  Tests python protocol buffers against the golden message.

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

TODO(kenton):  Merge with wire_format_test?  It doesn't make a whole lot of
sense to call this a test of the "message" module, which only declares an
abstract interface.
z!gps@google.com (Gregory P. Smith)    Nc                     | |kD  | |k  z
  S N )xys     w/var/www/catia.catastroantioquia-mas.com/valormas/lib/python3.12/site-packages/google/protobuf/internal/message_test.py<lambda>r	   7   s    AEa!e$     )map_proto2_unittest_pb2)map_unittest_pb2)unittest_pb2)unittest_proto3_arena_pb2)
descriptor)api_implementation)encoder)more_extensions_pb2)packed_field_test_pb2)	test_util)test_proto3_optional_pb2)testing_refleaks)message)_parameterizedi  error_proto2_proto3c                   J   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. Z0d/ Z1d0 Z2d1 Z3d2 Z4d3 Z5d4 Z6d5 Z7d6 Z8d7 Z9d8 Z:d9 Z;d: Z<d; Z=d<d=d>d?d@dA e>       g i  e?       g
Z@dB ZAdC ZBdD ZCdE ZDdF ZEdG ZFdH ZG G dI dJeH      ZIdK ZJdL ZKdM ZL G dN dOeH      ZMdP ZNdQ ZOdR ZPdS ZQdT ZRdU ZSdV ZTdW ZUdX ZVdY ZWdZ ZXd[ ZYy<)\MessageTestc                 R   t        j                         dk7  r| j                  d       t        j                  d      }| j                  t              5 }|j                  j                  |       d d d        | j                  dt        j                               y # 1 sw Y   /xY w)NpythonzSkipping testBadUtf8String, currently only the python api implementation raises UnicodeDecodeError when a string field contains bad utf-8.bad_utf8_stringzTestAllTypes.optional_string)r   TypeskipTestr   GoldenFileDataassertRaisesUnicodeDecodeErrorTestAllTypes
FromStringassertInstr	exception)selfmessage_modulebad_utf8_datacontexts       r   testBadUtf8StringzMessageTest.testBadUtf8StringR   s     H,
mm 7 8 ,,->?M			-	. <'!!,,];<MM0#g6G6G2HI< <s   BB&c                    |t         u rt        j                  d      }nt        j                  d      }|j                         }|j	                  |       |t         u rt        j
                  | |       | j                  ||j                                t        j                  |      }| j                  ||j                                y )N golden_message_oneof_implementedgolden_message_proto3)
r   r   r#   r&   ParseFromStringExpectAllFieldsSetassertEqualSerializeToStringcopydeepcopy)r+   r,   golden_datagolden_messagegolden_copys        r   testGoldenMessagezMessageTest.testGoldenMessage\   s     %,,-OPk,,-DEk#002N"";/%""48[."B"B"DE--/K[+"?"?"ABr
   c                    t        j                  d      }|j                         }|j                  |      }|j                         }t        j                  |       | j                  |t        |             | j                  ||       | j                  ||j                                t        j                  |      }| j                  ||j                                y Ngolden_packed_fields_message)
r   r#   TestPackedTypesr3   SetAllPackedFieldsr5   lenr6   r7   r8   )r+   r,   r9   r:   parsed_bytesall_setr;   s          r   testGoldenPackedMessagez#MessageTest.testGoldenPackedMessagem   s    **+IJK#335N!11+>L,,.G  )\3{#34Wn-['";";"=>--/K[+"?"?"ABr
   c                    |j                         }| j                  t        |j                  d       | j                  t        |j                  d       t        j                  dd      }t        j                         dk(  st        j                         dk(  ru| j                  t        j                        5 }|j                  |       d d d        t        j                         dk(  r%| j                  dt        j                               | j                  t        j                  |j                  d       y # 1 sw Y   qxY w)	Nr   0      r   upbzUnexpected end-group tag.s   )r&   r$   	TypeErrorr'   	Exceptionr   TagBytesr   r!   r   DecodeErrorr5   r)   r*   )r+   r,   msgend_tagr.   s        r   testParseErrorszMessageTest.testParseErrorsy   s    

%
%
'Ci3i5 q!$G!X-!U*W001  Ww 		 	 	"h	.4c':K:K6LM 	g))3>>7C   s   6D88Ec                    d}|j                         }|j                  j                  g d       | j                  ||j	                  d              | j                  ||j	                  d             | j                  ||j	                  d              G d dt
               G fdd	t              }| j                        5  |j	                   |              d d d        y # 1 sw Y   y xY w)
Ns5   
One string
Two string
Red stringBlue string)z
One stringz
Two stringz
Red stringzBlue stringdeterministicFTc                       e Zd Zy):MessageTest.testDeterminismParameters.<locals>.BadArgErrorN)__name__
__module____qualname__r   r
   r   BadArgErrorrV      s    
r
   rZ   c                   "    e Zd Z fdZ fdZy)5MessageTest.testDeterminismParameters.<locals>.BadArgc                             r   r   r+   rZ   s    r   __nonzero__zAMessageTest.testDeterminismParameters.<locals>.BadArg.__nonzero__       mr
   c                             r   r   r^   s    r   __bool__z>MessageTest.testDeterminismParameters.<locals>.BadArg.__bool__   r`   r
   N)rW   rX   rY   r_   rb   )rZ   s   r   BadArgr\      s    r
   rc   )r&   repeated_stringextendr5   r6   rL   objectr$   )r+   r,   r9   r:   rc   rZ   s        @r   testDeterminismParametersz%MessageTest.testDeterminismParameters   s    .K $002N"")) +  	[#55D5IK[#55E5JL[#55D5IKi   
		;	' ?&&VX&>? ? ?s   C))C2c                     t        j                  d      }|j                         }|j                  |       t	        j
                  |      }t	        j                  |      }| j                  ||       y Nr:   )r   r#   r&   r3   pickledumpsloadsr5   )r+   r,   r9   r:   pickled_messageunpickled_messages         r   testPickleSupportzMessageTest.testPickleSupport   s]    **+;<K#002N"";/ll>2O_5&7r
   c                     |j                   j                  d      }t        j                  |      }t        j                  |      }| j                  ||       y )NrH   bb)TestPickleNestedMessageNestedMessagerj   rk   rl   r5   )r+   r,   r:   rm   rn   s        r   testPickleNestedMessagez#MessageTest.testPickleNestedMessage   sI    #;;IIQIONll>2O_5&7r
   c                     |j                   j                  }|j                  d      }t        j                  |      }t        j
                  |      }| j                  ||       y )NrH   )cc)rs   rt   NestedNestedMessagerj   rk   rl   r5   )r+   r,   clsr:   rm   rn   s         r   testPickleNestedNestedMessagez)MessageTest.testPickleNestedNestedMessage   sT    

0
0
>
>C,,,2Nll>2O_5&7r
   c                    |t         u rd}nd}|j                         }|j                  |       | j                  |j                  t
        j                         | j                  |j                  t
        j                         | j                  |j                  d   t
        j                         | j                  |j                  d   t
        j                         | j                  ||j                                y )Ns   ]  a              s    ]  a              r   r   r&   r3   r5   optional_floatmathinfoptional_doublerepeated_floatrepeated_doubler6   r+   r,   r9   r:   s       r   testPositiveInfinityz MessageTest.testPositiveInfinity   s    %Ak
Ek
 $002N"";/^22DHH=^33TXX>^2215txx@^33A6A[."B"B"DEr
   c                    |t         u rd}nd}|j                         }|j                  |       | j                  |j                  t
        j                          | j                  |j                  t
        j                          | j                  |j                  d   t
        j                          | j                  |j                  d   t
        j                          | j                  ||j                                y )Ns   ]  a              s    ]  a              r   r|   r   s       r   testNegativeInfinityz MessageTest.testNegativeInfinity   s    %Ak
Ek
 $002N"";/^22TXXI>^33dhhY?^2215yA^33A6	B[."B"B"DEr
   c                    d}|j                         }|j                  |       | j                  t        j                  |j
                               | j                  t        j                  |j                               | j                  t        j                  |j                  d                | j                  t        j                  |j                  d                |j                         }|j                         } |j                  |       | j                  t        j                  |j
                               | j                  t        j                  |j                               | j                  t        j                  |j                  d                | j                  t        j                  |j                  d                y )Ns   ]  a              r   )
r&   r3   
assertTruer~   isnanr}   r   r   r   r6   r+   r,   r9   r:   
serializedr   s         r   testNotANumberzMessageTest.testNotANumber   sA   ?K $002N"";/OODJJ~<<=>OODJJ~==>?OODJJ~<<Q?@AOODJJ~==a@AB  113J))+GGJ'OODJJw5567OODJJw6678OODJJw55a89:OODJJw66q9:;r
   c                 >   d}|j                         }|j                  |       | j                  |j                  d   t        j
                         | j                  |j                  d   t        j
                         | j                  ||j                                y )Ns           r   r@   r3   r5   packed_floatr~   r   packed_doubler6   r   s       r   testPositiveInfinityPackedz&MessageTest.testPositiveInfinityPacked  s}    CK#335N"";/^003TXX>^11!4dhh?[."B"B"DEr
   c                 B   d}|j                         }|j                  |       | j                  |j                  d   t        j
                          | j                  |j                  d   t        j
                          | j                  ||j                                y )Ns           r   r   r   s       r   testNegativeInfinityPackedz&MessageTest.testNegativeInfinityPacked  s    CK#335N"";/^003dhhY?^11!4txxi@[."B"B"DEr
   c                 6   d}|j                         }|j                  |       | j                  t        j                  |j
                  d                | j                  t        j                  |j                  d                |j                         }|j                         } |j                  |       | j                  t        j                  |j
                  d                | j                  t        j                  |j                  d                y )Ns           r   )r@   r3   r   r~   r   r   r   r6   r   s         r   testNotANumberPackedz MessageTest.testNotANumberPacked  s    CK#335N"";/OODJJ~::1=>?OODJJ~;;A>?@113J,,.GGJ'OODJJw33A678OODJJw44Q789r
   c                    |j                         }t        j                  dd      }||_         |j                   |j
                                | j                  |j                  |k(         dt        j                  dd      z  }||_         |j                   |j
                                | j                  |j                  |k(         | |_         |j                   |j
                                | j                  |j                  | k(         | |_         |j                   |j
                                | j                  |j                  | k(         t        j                  dd      }||_         |j                   |j
                                | j                  |j                  |k(         dt        j                  dd      z  }||_         |j                   |j
                                | j                  |j                  |k(         | |_         |j                   |j
                                | j                  |j                  | k(         | |_         |j                   |j
                                | j                  |j                  | k(         t        j                  d      }||_        | j                  |j                  |        |j
                         } |j                  |       | j                  |j                  |       d|_        | j                  |j                  t        d              |j
                         } |j                  |       | j                  |j                  t        d             d|_        | j                  |j                  t        d	             d
|_        | j                  |j                  d
       y )N            ?iz0x1.fffffep+127gP#Hr   gP#z-infg 7)r&   r~   powr}   r3   r6   r   floatfromhexassertAlmostEqualr5   )	r+   r,   r   kMostPosExponentNoSigBitskMostPosExponentOneSigBitkMostNegExponentNoSigBitskMostNegExponentOneSigBit	max_floatserialized_datas	            r   testExtremeFloatValuesz"MessageTest.testExtremeFloatValues%  se   ))+G !%C 06GG5G5578OOG**.GGH !$dhhq#&6 66GG5G5578OOG**.GGH 87GG5G5578OOG**/H.HHI77GG5G5578OOG**/H.HHI !%D 16GG5G5578OOG**.GGH !$dhhq$&7 76GG5G5578OOG**.GGH 87GG5G5578OOG**/H.HHI77GG5G5578OOG**/H.HHI /0I&G7119=/g//1OGO,7119= +GW++U5\:/g//1OGO,W++U5\:+GW++U6];*G711=Ar
   c                 P   |j                         }t        j                  dd      }||_         |j                   |j
                                | j                  |j                  |k(         dt        j                  dd      z  }||_         |j                   |j
                                | j                  |j                  |k(         | |_         |j                   |j
                                | j                  |j                  | k(         | |_         |j                   |j
                                | j                  |j                  | k(         t        j                  dd      }||_         |j                   |j
                                | j                  |j                  |k(         dt        j                  dd      z  }||_         |j                   |j
                                | j                  |j                  |k(         | |_         |j                   |j
                                | j                  |j                  | k(         | |_         |j                   |j
                                | j                  |j                  | k(         y )Nr   i  r   i)r&   r~   r   r   r3   r6   r   )r+   r,   r   r   r   r   r   s          r   testExtremeDoubleValuesz#MessageTest.testExtremeDoubleValuesg  sb   ))+G !%D 17GG5G5578OOG++/HHI !$dhhq$&7 77GG5G5578OOG++/HHI  98GG5G5578OOG++0I/IIJ88GG5G5578OOG++0I/IIJ !%E 27GG5G5578OOG++/HHI !$dhhq%&8 87GG5G5578OOG++/HHI  98GG5G5578OOG++0I/IIJ88GG5G5578OOG++0I/IIJr
   c                 h    |j                         }d|_        | j                  t        |      d       y )N       @zoptional_float: 2.0
)r&   r}   r5   r)   r+   r,   r   s      r   testFloatPrintingzMessageTest.testFloatPrinting  s-    ))+G GS\#:;r
   c                     |j                         }d|_        |j                  }|j                  |j                                | j	                  ||j                         y )N^!7ݚ?)r&   r}   r3   r6   r5   )r+   r,   rO   	old_floats       r   testHighPrecisionFloatPrintingz*MessageTest.testHighPrecisionFloatPrinting  sP    

%
%
'C,C""I--/0Y 2 23r
   c                 h    |j                         }d|_        | j                  t        |      d       y )Nr   z%optional_double: 0.12345678912345678
)r&   r   r5   r)   r+   r,   rO   s      r   testHighPrecisionDoublePrintingz+MessageTest.testHighPrecisionDoublePrinting  s-    

%
%
'C-CSXGHr
   c                     |j                         }t        j                  |       |j                         }|j	                  |j                                | j                  t        |      d       y )N )r&   r   SetAllNonLazyFieldsTestEmptyMessager3   r6   r5   r)   )r+   r,   	populatedemptys       r   testUnknownFieldPrintingz$MessageTest.testUnknownFieldPrinting  sW    ++-I!!),++-E	)5578SZ$r
   c                    |j                         }|j                  j                  |j                   j                  d             |j                   j                  d      }|j                  j                  |       	 |j                  j                  d       | j                  dt        |j                               | j                  ddg|j                  D cg c]  }|j                   c}       y # t        $ r Y gw xY wc c}w )NrH   rq   r   )r&   repeated_nested_messageappendrt   rK   r5   rB   rr   )r+   r,   rO   nestedms        r    testAppendRepeatedCompositeFieldz,MessageTest.testAppendRepeatedCompositeField  s    

%
%
'C&&##11Q179((66!6<F&&v.	!!((+ 	QC7789aVC,G,GHqaddHI  
 Is   >C5 D
5	D Dc                    |j                         }|j                  j                  d|j                   j                  d             |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d
       | j                  dt        |j                               | j                  g d|j                  D cg c]  }|j                   c}       | j                  t        |      d       | j                  |j                  d       y # t        $ r Y w xY wc c}w )NrH   rq   r   r   c           )r   r   r   rH   r   zrepeated_nested_message {
  bb: -1000
}
repeated_nested_message {
  bb: 2
}
repeated_nested_message {
  bb: -1
}
repeated_nested_message {
  bb: 1
}
repeated_nested_message {
  bb: 3
}
)	r&   r   insertrt   rK   r5   rB   rr   r)   )r+   r,   rO   sub_msgr   s        r    testInsertRepeatedCompositeFieldz,MessageTest.testInsertRepeatedCompositeField  s   

%
%
'C&&
N''555;=))!,G&&	>&&444:<&&
N''555;=&&
N''555<>&&~**88E8BD	!!((C0 	QC7789)$'$?$?@qadd@BC   	WZZ#+  
 As   /G G-
	G*)G*c                 P   |j                         }|j                  j                  d       |j                  j                  d       |j                  j	                  d       |j                  j	                  d       |j                         }|j                  j	                  d       |j                  j	                  d       |j                  j                  d       |j                  j                  d       |j                  j                  |j                         | j                  dt        |j                               |j                  j                  |j                         | j                  g d|j                  D cg c]  }|j                   c}       y c c}w )	NrH   r   rq   r   rI   r      rH   r   r   rI   )	r&   repeated_int32r   r   add	MergeFromr5   rB   rr   )r+   r,   rO   	other_msgr   s        r   testMergeFromRepeatedFieldz&MessageTest.testMergeFromRepeatedField  sA   

%
%
'Ca a ##q#)##q#)++-I%%))Q)/%%))Q)/##A&##A&  !9!9:QC../0)))*K*KL\#2M2M#NQADD#NO#Ns   F#
c                    |j                         }	 |j                  j                  d       	 |j                  j                  d       | j                  t        |j                        d       y # t        $ r Y Nw xY w# t        $ r Y @w xY w)Nwrong)value_fieldr   )r&   r   r   rK   
ValueErrorr5   rB   r   s      r   testAddWrongRepeatedNestedFieldz+MessageTest.testAddWrongRepeatedNestedField  s    

%
%
'C	!!%%g.	!!%%'%: 	S445q9  
  
s"   A0 A? 0	A<;A<?	B
Bc                    |j                         }|j                  j                  g d       | j                  d|j                         | j	                  d|j                         |j
                  j                  d       |j
                  d   }|j                   j                  d      }|j                   j                  d      }|j
                  j                  |       |j
                  j                  d|       | j                  ||j
                         | j                  ||j
                         | j                  ||j
                         y )NrH   r   r   r   r   rH   rq   r   )
r&   r   re   r(   assertNotInr   r   rt   r   r   )r+   r,   rO   sub_msg1sub_msg2sub_msg3s         r   testRepeatedContainsz MessageTest.testRepeatedContains  s   

%
%
'Ci(MM!S''(Q**+##q#)**1-H**88A8>H**88A8>H&&x0&&q(3MM(C778MM(C778MM(C778r
   c                     |j                         }|j                  j                  g d       d}|j                  D ]  }||z  }	 | j                  |d       y )Nr   r      r&   r   re   r5   )r+   r,   rO   r   items        r   testRepeatedScalarIterablez&MessageTest.testRepeatedScalarIterable  sW    

%
%
'Ci(
C"" 	TkcS!r
   c                    |j                         }|j                  j                  d       |j                  j                  d       |j                  j                  d       |j                  j                  d       | j                  g d|j                  D cg c]  }|j                   c}       | j                  g dt        |j                        D cg c]  }|j                   c}       | j                  g d|j                  d d d   D cg c]  }|j                   c}       y c c}w c c}w c c}w )	NrH   rq   r   r   rI   r   )rI   r   r   rH   r   )r&   r   r   r5   rr   reversed)r+   r,   rO   r   s       r    testRepeatedNestedFieldIterationz,MessageTest.testRepeatedNestedFieldIteration  s    

%
%
'C##q#)##q#)##q#)##q#)\#2M2M#NQADD#NO\$,S-H-H$IJqaddJL\$'$?$?"$EFqaddFH $OJFs   D3
D8
D=
c                    |j                         }|j                  j                  d       |j                  j                  d       |j                  j                  d       |j                  j                          | j	                  |j                  d   d       | j	                  |j                  d   d       | j	                  |j                  d   d       | j	                  t        |j                        t        g d             |j                  j                  d       |j                  j                  d       |j                  j                  d       |j                  j                          | j                  |j                  d   d       | j                  |j                  d   d       | j                  |j                  d   d       |j                  j                  d	       |j                  j                  d
       |j                  j                  d       |j                  j                          | j	                  |j                  d   d	       | j	                  |j                  d   d       | j	                  |j                  d   d
       | j	                  t        |j                        t        g d             |j                  j                  d       |j                  j                  d       |j                  j                  d       |j                  j                          | j	                  |j                  d   d       | j	                  |j                  d   d       | j	                  |j                  d   d       | j	                  t        |j                        t        g d             y)z7Check some different types with the default comparator.rH   r   r   r   r   皙?g?333333?acbr   r   r      a   c   b)r   r   r   N)
r&   r   r   sortr5   r)   r   r   rd   repeated_bytesr   s      r   0testSortingRepeatedScalarFieldsDefaultComparatorz<MessageTest.testSortingRepeatedScalarFieldsDefaultComparator"  s   ))+G !!!$!!!$!!!$!W++A.2W++A.2W++A.2S//0#i.A!!#&!!#&!!#&!711!4c:711!4c:711!4c:""3'""3'""3'  "W,,Q/5W,,Q/5W,,Q/5S00137I3JK!!$'!!$'!!$'!W++A.5W++A.5W++A.5S//0#6H2IJr
   c                 \   |j                         }|j                  j                  d       |j                  j                  d       |j                  j                  d       |j                  j                  t               | j                  |j                  d   d       | j                  |j                  d   d       | j                  |j                  d   d       |j                  j                  d       |j                  j                  d	       |j                  j                  d
       |j                  j                  t               | j                  |j                  d   d
       | j                  |j                  d   d	       | j                  |j                  d   d       y)z2Check some different types with custom comparator.r   r   keyr   rH   r   aaarr   r   N)r&   r   r   r   absr5   rd   rB   r   s      r   /testSortingRepeatedScalarFieldsCustomComparatorz;MessageTest.testSortingRepeatedScalarFieldsCustomComparatorJ  sX   ))+G!!"%!!"%!!"%C(W++A.3W++A.3W++A.3""5)""4(""3'  S )W,,Q/5W,,Q/6W,,Q/7r
   c                 ,   |j                         }d|j                  j                         _        d|j                  j                         _        d|j                  j                         _        d|j                  j                         _        d|j                  j                         _        d|j                  j                         _        |j                  j	                  t        j                  d             | j                  |j                  d	   j                  d       | j                  |j                  d   j                  d       | j                  |j                  d   j                  d       | j                  |j                  d   j                  d       | j                  |j                  d   j                  d       | j                  |j                  d   j                  d       | j                  t        |j                        d
       y)ECheck passing a custom comparator to sort a repeated composite field.rH   r   r   r   r   rI   rr   r   r   z0[bb: 1
, bb: 2
, bb: 3
, bb: 4
, bb: 5
, bb: 6
]N)	r&   r   r   rr   r   operator
attrgetterr5   r)   r   s      r   2testSortingRepeatedCompositeFieldsCustomComparatorz>MessageTest.testSortingRepeatedCompositeFieldsCustomComparator^  s   ))+G/0G##''),/0G##''),/0G##''),/0G##''),/0G##''),/0G##''),##((X-@-@-F(GW44Q7::A>W44Q7::A>W44Q7::A>W44Q7::A>W44Q7::A>W44Q7::A>G++,@Br
   c                 d   |j                         }d|j                  j                         _        d|j                  j                         _        d|j                  j                         _        d|j                  j                         _        d|j                  j                         _        d|j                  j                         _        d|j                  j                         _        |j                  j	                  d 	       | j                  g d
|j                  D cg c]  }|j                   c}        |j                         } |j                           |j                  |       | j                  g d
|j                  D cg c]  }|j                   c}       yc c}w c c}w )r            !         
   c                      | j                   dz  S )Nr  rq   )zs    r   r	   zFMessageTest.testSortingRepeatedCompositeFieldsStable.<locals>.<lambda>~  s    qttrz r
   r   )r  r  r  r   r  r  r  N)	r&   r   r   rr   r   r5   r6   ClearMergeFromString)r+   r,   r   npbs        r   (testSortingRepeatedCompositeFieldsStablez4MessageTest.testSortingRepeatedCompositeFieldsStables  sV   ))+G/1G##''),/1G##''),/1G##''),/1G##''),/1G##''),/1G##''),/1G##''),##((-A(B1$+$C$CDqaddDF
 
#	"	"	$BGMMOGB1$+$C$CDqaddDF E Es   #F(
F-
c                     |j                         }t        j                  d      }d|j                  j	                         _        d|j                  j	                         _        d|j                  j	                         _        d|j                  j	                         _        d|j                  j	                         _        d|j                  j	                         _        |j                  j                  |       | j                  |j                  D cg c]  }|j
                   c}g d	       |j                  j                  |d
       | j                  |j                  D cg c]  }|j
                   c}g d       yc c}w c c}w )zECheck sorting a repeated composite field using list.sort() arguments.rr   rH   r   r   r   r   rI   r   )rH   r   r   rI   r   r   Tr   reverse)r   r   rI   r   r   rH   N)r&   r   r   r   r   rr   r   r5   )r+   r,   r   get_bbks        r   'testRepeatedCompositeFieldSortArgumentsz3MessageTest.testRepeatedCompositeFieldSortArguments  s6   ))+G  &F/0G##''),/0G##''),/0G##''),/0G##''),/0G##''),/0G##''),##((V(4G$C$CDqaddD')##((VT(BG$C$CDqaddD') E Es   F(Fc                    |j                         }|j                  j                  d       |j                  j                  d       |j                  j                  d       |j                  j                  t               | j                  t        |j                        g d       |j                  j                  t        d       | j                  t        |j                        g d       |j                  j                  d	       |j                  j                  d
       |j                  j                  d       |j                  j                  t               | j                  t        |j                        g d       |j                  j                  t        d       | j                  t        |j                        g d       y)z9Check sorting a scalar field using list.sort() arguments.r   r   r   r   )r   r   r   Tr  )r   r   r   r   rr   r   )r   rr   r   )r   rr   r   N)	r&   r   r   r   r   r5   listrd   rB   r   s      r   $testRepeatedScalarFieldSortArgumentsz0MessageTest.testRepeatedScalarFieldSortArguments  sV   ))+G!!"%!!"%!!"%C(T'001<@C6T'001<@""5)""4(""3'  S )T'1124FG  S$ 7T'1124FGr
   c                    |j                         }|j                         }|j                  j                  d       |j                  j                  d       |j                  j                  d       |j                  j                  d       |j                  j                  d       |j                  j                  d       d|j                  j	                         _        d|j                  j	                         _        d|j                  j	                         _        d|j                  j	                         _        d|j                  j	                         _        d|j                  j	                         _        y )Nr   rH   r   r   )r&   r   r   r   r   rr   r+   r,   m1m2s       r   testRepeatedFieldsComparablez(MessageTest.testRepeatedFieldsComparable  s    		$	$	&B		$	$	&BQQQQQQ*+B""$'*+B""$'*+B""$'*+B""$'*+B""$'*+B""$'r
   c                     |j                         }| j                  |j                  t        j                  j
                         | j                  |j                  t        j                  j
                         y r   )r&   assertIsInstancer   collectionsabcMutableSequencer   r+   r,   r   s      r   testRepeatedFieldsAreSequencesz*MessageTest.testRepeatedFieldsAreSequences  sS    ##%A!**KOO,K,KL!33%//99;r
   c                     |j                         }| j                  t              5  t        |j                         d d d        | j                  t              5  t        |j
                         d d d        y # 1 sw Y   =xY w# 1 sw Y   y xY wr   )r&   r$   rK   hashr   r   r!  s      r   testRepeatedFieldsNotHashablez)MessageTest.testRepeatedFieldsNotHashable  sw    ##%A			9	% 
1			9	% &
1$$%& & & &s   A8B8BBc                     |j                         }|j                  j                  j                  g        | j	                  |j                  d             y )Npayload)NestedTestAllTypesr'  r   re   r   HasFieldr!  s      r   $testRepeatedFieldInsideNestedMessagez0MessageTest.testRepeatedFieldInsideNestedMessage  s=    ))+AII##B'OOAJJy)*r
   c                    |j                         }|j                         }|j                  }| j                  d|j                         d|j                  _        |j	                  |       | j                  d|j                         |j                         }|j                         }|j                  j                  j                  }| j                  d|j                         d|j                  j                  j                  _        |j	                  |       | j                  d|j                         | j                  |j                  j                  |j                  j                         |j                  j                  j                         }d|_        |j	                  |       | j                  dt        |j                  j                               | j                  d|j                         y Nr   rH   )r&   optional_nested_messager5   rr   r   r(  childr'  r   r   rB   )r+   r,   r  r  r   msg1msg2s          r   testMergeFromzMessageTest.testMergeFrom  ss   		$	$	&B		$	$	&B''FQ		"$%B! LLQ		" ,,.D,,.DZZ77FQ		"45DJJ..1NN4Q		" 	T\\99\\99;\\11557FFINN4QDLL@@ABQ		"r
   c                 <   |j                         }|j                         }| j                  d|j                  j                         d|j                  _        |j	                  |j                                | j                  d|j                  j                         y r,  )r&   r5   r-  rr   r
  r6   r  s       r   testMergeFromStringzMessageTest.testMergeFromString  s}    		$	$	&B		$	$	&BQ22556$%B! r++-.Q22556r
   c                    |j                         }d|_        |j                  j                  d       d|_        |j
                  j                  d       |j                         }t        |      }|j                   j                  |      }| j                  |j                  d       | j                  |j
                  dg       | j                  |j                  d       | j                  |j                  dg       | j                  |j                  t               | j                  |j
                  d   t               | j                  |j                  t               | j                  |j                  d   t               y )Nzscalar stringzrepeated strings   scalar bytess   repeated bytesr   )r&   optional_stringrd   r   optional_bytesr   r6   
memoryviewr'   r5   r  bytesr)   )r+   r,   r  r   memviewr  s         r   "testMergeFromStringUsingMemoryViewz.MessageTest.testMergeFromStringUsingMemoryView  s<   		$	$	&B(B/0'B./%%'J$G		$	$	/	/	8BR&&8R&&):(;<R''9R''*;)<= 	"++U3"++A.6",,c2",,Q/5r
   c                    |j                         }| j                  d|j                  j                         | j	                  |j                  d             |j                  d       | j	                  |j                  d             y )Nr   r-  r
   )r&   r5   r-  rr   assertFalser)  r
  )r+   r,   r  s      r   testMergeFromEmptyzMessageTest.testMergeFromEmpty  sj    		$	$	&BQ22556R[[!:;<sR[[!:;<r
   c                 \    t        ||       | j                  |j                  |             y)zMake sure that a nested message object exists.

    As soon as a nested message attribute is accessed, it will be present in the
    _fields dict, without being marked as actually being set.
    N)getattrr<  r)  )r+   rO   	attributes      r   ensureNestedMessageExistsz%MessageTest.ensureNestedMessageExists  s%     CS\\),-r
   c                     |j                         }| j                  t        |j                  d       | j                  t        |j                  d       y )Nno_such_oneof_fieldr   )r&   r$   r   
WhichOneofrL   r!  s      r    testOneofGetCaseNonexistingFieldz,MessageTest.testOneofGetCaseNonexistingField#  s=    ##%Aj!,,0EFiq1r
   c                    |j                         }| j                  d |j                  d             | j                  |j	                  d             | j                  |j	                  d             d|_        | j                  d|j                  d             | j                  |j	                  d             | j                  |j	                  d             | j                  |j	                  d             d|_        | j                  d|j                  d             | j                  |j	                  d             | j                  |j	                  d             y )Noneof_fieldoneof_uint32r   oneof_stringr   )	r&   assertIsrD  r<  r)  rH  r5   r   rI  r!  s      r   testOneofDefaultValuesz"MessageTest.testOneofDefaultValues(  s   ##%AMM$]34QZZ./QZZ/0 AN^Q\\-%@AOOAJJ}-.OOAJJ~./QZZ/0AN^Q\\-%@AOOAJJ~./QZZ/0r
   c                 B   |j                         }| j                  d |j                  d             d|_        | j	                  d|j                  d             | j                  |j                  d             d|_        | j	                  d|j                  d             | j                  |j                  d             | j                  |j                  d             |j                   | j	                  d|j                  d             | j                  |j                  d             | j                  |j                  d             |j                  j                   | j	                  d|j                  d             | j                  |j                  d             | j                  |j                  d             d|j                  _
        | j	                  d|j                  d             | j                  |j                  d             | j                  |j                  d             d|_        | j	                  d|j                  d             | j                  |j                  d             | j                  |j                  d             y )	NrG  r  rH  foorI  oneof_nested_message   bboneof_bytes)r&   rJ  rD  rH  r5   r   r)  rI  r<  rN  rr   rP  r!  s      r   testOneofSemanticszMessageTest.testOneofSemantics:  s   ##%AMM$]34AN^Q\\-%@AOOAJJ~./AN^Q\\-%@AQZZ/0OOAJJ~./ ^Q\\-%@AOOAJJ~./QZZ 678 ^Q\\-%@AOOAJJ~./QZZ 678 "A+Q\\--HIQZZ/0OOAJJ567AM]ALL$?@QZZ 678OOAJJ}-.r
   c                     |j                         }d|_        | j                  |d       | j                  d|j	                  d             | j                  d|j                         y )Nr  rN  rH  rG  )r&   rH  rA  r5   rD  r!  s      r   !testOneofCompositeFieldReadAccessz-MessageTest.testOneofCompositeFieldReadAccess]  sU    ##%AAN""1&<=^Q\\-%@AR(r
   c                 \   |j                         }| j                  d |j                  d             |t        u r | j	                  |j                  d             d|_        | j                  d|j                  d             |t        u r | j                  |j                  d             d|_	        | j                  d|j                  d             |j                  d       | j                  d |j                  d             |t        u r!| j	                  |j                  d             y y )NrG  r  rH  rO  rP  )r&   rJ  rD  r   r<  r)  rH  r5   r   rP  
ClearFieldr!  s      r   testOneofWhichOneofzMessageTest.testOneofWhichOneofe  s    ##%AMM$]34%
qzz-01AN^Q\\-%@A%
ooajj/0AM]ALL$?@LLMM$]34%
qzz-01 &r
   c                 &   |j                         }d|_        |j                  d       |t        u r | j	                  |j                  d             | j	                  |j                  d             | j                  d |j                  d             y )Nr  rG  rH  r&   rH  rU  r   r<  r)  rJ  rD  r!  s      r   testOneofClearFieldzMessageTest.testOneofClearFieldx  sp    ##%AANLL%
qzz-01QZZ/0MM$]34r
   c                 &   |j                         }d|_        |j                  d       |t        u r | j	                  |j                  d             | j	                  |j                  d             | j                  d |j                  d             y Nr  rH  rG  rX  r!  s      r   testOneofClearSetFieldz"MessageTest.testOneofClearSetField  sp    ##%AANLL %
qzz-01QZZ/0MM$]34r
   c                    |j                         }d|_        | j                  |d       |j                  d       | j	                  d|j                         |t
        u r | j                  |j                  d             | j                  |j                  d             | j	                  d|j                  d             y )Nr  rN  rG  rH  )	r&   rH  rA  rU  r5   r   r   r)  rD  r!  s      r   testOneofClearUnsetFieldz$MessageTest.testOneofClearUnsetField  s    ##%AAN""1&<=LL'(R(%
ooajj/0OOAJJ~./^Q\\-%@Ar
   c                     |j                         }d|_        |j                         }|j                  |j                                | j	                  d|j                  d             y r[  )r&   rH  r3   r6   r5   rD  r+   r,   r   r  s       r   testOneofDeserializez MessageTest.testOneofDeserialize  sU    ##%AAN		$	$	&Bq**,-^R]]=%ABr
   c                     |j                         }d|_        |j                         }|j                  |       | j                  d|j	                  d             y r[  )r&   rH  CopyFromr5   rD  r`  s       r   testOneofCopyFromzMessageTest.testOneofCopyFrom  sI    ##%AAN		$	$	&BKKN^R]]=%ABr
   c                    |j                         }d|j                  _        |j                         }d|j                  _        d|j                  j                  _        |j                  |       | j                  d|j                  j                  d             | j                  d|j                  j                  j                  d             y )Nr  rO  rH  rG  rP  )r(  r'  rH  rP  r.  r   r5   rD  r`  s       r   testOneofNestedMergeFromz$MessageTest.testOneofNestedMergeFrom  s    ))+AAII		*	*	,B"BJJ#(BHH LLO^RZZ%:%:=%IJ]BHH$4$4$?$?$NOr
   c                    |j                         }d|j                  j                  _        d|j                  j                  j                  _        |j                         }d|j                  _        |j                  |       | j                  d|j                  j                  d             | j                  d|j                  j                  j                  d             y )Nr     r  rN  rG  )	r(  r'  rN  rr   r.  rH  r   r5   rD  r`  s       r   testOneofMessageMergeFromz%MessageTest.testOneofMessageMergeFrom  s    ))+A(*AII""%.0AGGOO((+		*	*	,B BJJLLO+ZZ**=9;+XX%%00?Ar
   c                     |j                  |j                   j                               }| j                  d|j                  d             y )N)rN  rN  rG  )r&   rt   r5   rD  r!  s      r   testOneofNestedMessageInitz&MessageTest.testOneofNestedMessageInit  sD    ##+88FFH 	$ 	JA+Q\\--HIr
   c                     |j                         }d|_        |j                          | j                  |j	                  d             d|_        | j                  d|j	                  d             y )Nr  rG  rO  rP  )r&   rH  r	  assertIsNonerD  rP  r5   r!  s      r   testOneofClearzMessageTest.testOneofClear  sW    ##%AANGGIall=12AM]ALL$?@r
   c                     |j                         }t        d      |_        | j                  |j                  t               y)zsAssigning a byte string to a string field should result

    in the value being converted to a Unicode string.
    r   N)r&   r)   r5  r  r!  s      r   "testAssignByteStringToUnicodeFieldz.MessageTest.testAssignByteStringToUnicodeField  s4    
 	##%ABA!++S1r
   c                     |j                         }|j                  j                  d       |j                  t        d      t        t	        |j                               }| j                  t	        |j                        t	        |             d|j                  j                         _        |j                  t        d      t        t	        |j                               }| j                  t	        |j                        t	        |             y)z{It should be possible to use int-valued indices in slices.

    This didn't used to work in the v2 C++ implementation.
    rH   r   r   N)	r&   r   r   intrB   r5   r   r   rr   )r+   r,   r   sls       r   testLongValuedSlicezMessageTest.testLongValuedSlice  s    
 	##%A A	
		#a&S)9)9%:!;	<BS))*CG4 *+A!!#&	
	"	"3q6#c!2K2K.L*M	NBS223SW=r
   c                 x   |j                         }| j                  t              5 }|j                  j	                  d t        d      D               ddd       | j                  t              5 }|j                  j	                  d t        d      D               ddd       y# 1 sw Y   SxY w# 1 sw Y   yxY w)z5This didn't use to work in the v2 C++ implementation.c              3   (   K   | ]
  }t           y wr   r   .0is     r   	<genexpr>zCMessageTest.testExtendShouldNotSwallowExceptions.<locals>.<genexpr>  s     3Aaa3   r  Nc              3   (   K   | ]
  }t           y wr   rw  rx  s     r   r{  zCMessageTest.testExtendShouldNotSwallowExceptions.<locals>.<genexpr>  s     #9!AA#9r|  )r&   r$   	NameErrorr   re   rangerepeated_nested_enumr+   r,   r   _s       r   $testExtendShouldNotSwallowExceptionsz0MessageTest.testExtendShouldNotSwallowExceptions  s    ##%A			9	% 43r334			9	% :###9uRy#99: :4 4: :s   ,B$/,B0$B-0B9NFr           r
   r   c                 b   |j                         }| j                  g |j                         t        j                  D ]9  }|j                  j                  |       | j                  g |j                         ; |j                  j                  g        | j                  g |j                         y)z,Test no-ops extending repeated int32 fields.N)r&   assertSequenceEqualr   r   FALSY_VALUESre   r+   r,   r   falsy_values       r   testExtendInt32WithNothingz&MessageTest.testExtendInt32WithNothing      ##%AR!1!12 #// 5k*
r1#3#345 BR!1!12r
   c                 b   |j                         }| j                  g |j                         t        j                  D ]9  }|j                  j                  |       | j                  g |j                         ; |j                  j                  g        | j                  g |j                         y)z,Test no-ops extending repeated float fields.N)r&   r  r   r   r  re   r  s       r   testExtendFloatWithNothingz&MessageTest.testExtendFloatWithNothing  r  r
   c                 b   |j                         }| j                  g |j                         t        j                  D ]9  }|j                  j                  |       | j                  g |j                         ; |j                  j                  g        | j                  g |j                         y)z-Test no-ops extending repeated string fields.N)r&   r  rd   r   r  re   r  s       r   testExtendStringWithNothingz'MessageTest.testExtendStringWithNothing  s    ##%AR!2!23 #// 6{+
r1#4#456 R R!2!23r
   c                    |j                         }| j                  g |j                         |j                  j                  dg       | j                  dg|j                         |j                  j                  ddg       | j                  g d|j                         |j                  j                  ddg       | j                  g d|j                         y)	z7Test extending repeated int32 fields with python lists.r   rH   r   r   rH   r   r   rI   r   rH   r   r   rI   N)r&   r  r   re   r!  s      r   testExtendInt32WithPythonListz)MessageTest.testExtendInt32WithPythonList  s    ##%AR!1!12QC aS!"2"23QF#Y(8(89QF#_a.>.>?r
   c                    |j                         }| j                  g |j                         |j                  j                  dg       | j                  dg|j                         |j                  j                  ddg       | j                  g d|j                         |j                  j                  ddg       | j                  g d|j                         y)	z7Test extending repeated float fields with python lists.r        ?r   r  r  r         @      @r  r  r   r  r  N)r&   r  r   re   r!  s      r   testExtendFloatWithPythonListz)MessageTest.testExtendFloatWithPythonList  s    ##%AR!1!12SE"cUA$4$45S#J'_a.>.>?S#J'68H8HIr
   c                    |j                         }| j                  g |j                         |j                  j                  dg       | j                  dg|j                         |j                  j                  ddg       | j                  g d|j                         |j                  j                  ddg       | j                  g d|j                         y)	z8Test extending repeated string fields with python lists.r   1122)r   r  r  3344)r   r  r  r  r  Nr&   r  rd   re   r!  s      r   testExtendStringWithPythonListz*MessageTest.testExtendStringWithPythonList'  s    ##%AR!2!23bT"bT1#4#45dD\*-q/@/@AdD\*91;L;LMr
   c                     |j                         }| j                  g |j                         |j                  j                  d       | j                  g d|j                         y)zDTest extending repeated string fields with characters from a string.r  r   Nr  r!  s      r   testExtendStringWithStringz&MessageTest.testExtendStringWithString2  sP    ##%AR!2!23U#_a.?.?@r
   c                   *    e Zd ZdZddZd Zd Zd Zy)MessageTest.TestIterablezThis iterable object mimics the behavior of numpy.array.

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

    Nc                     |xs g | _         y r   )_list)r+   valuess     r   __init__z!MessageTest.TestIterable.__init__@  s    <Rdjr
   c                     t        | j                        }|dk(  ry|dk(  rt        | j                  d         S t        d      )Nr   FrH   zTruth value is ambiguous.)rB   r  boolr   )r+   sizes     r   r_   z$MessageTest.TestIterable.__nonzero__C  s?    _d		DJJqM""233r
   c                 ,    t        | j                        S r   )rB   r  r+   s    r   __len__z MessageTest.TestIterable.__len__K  s    _r
   c                 6    | j                   j                         S r   )r  __iter__r  s    r   r  z!MessageTest.TestIterable.__iter__N  s    ZZ  ""r
   r   )rW   rX   rY   __doc__r  r_   r  r  r   r
   r   TestIterabler  9  s     4#r
   r  c                    |j                         }| j                  g |j                         |j                  j                  t        j                  g              | j                  g |j                         |j                  j                  t        j                  dg             | j                  dg|j                         |j                  j                  t        j                  ddg             | j                  g d|j                         |j                  j                  t        j                  ddg             | j                  g d|j                         y)	z3Test extending repeated int32 fields with iterable.r   rH   r   r  r   rI   r  N)r&   r  r   re   r   r  r!  s      r   testExtendInt32WithIterablez'MessageTest.testExtendInt32WithIterableQ  s   ##%AR!1!12K44R89R!1!12K44aS9:aS!"2"23K44aV<=Y(8(89K44aV<=_a.>.>?r
   c                    |j                         }| j                  g |j                         |j                  j                  t        j                  g              | j                  g |j                         |j                  j                  t        j                  dg             | j                  dg|j                         |j                  j                  t        j                  ddg             | j                  g d|j                         |j                  j                  t        j                  ddg             | j                  g d|j                         y)	z3Test extending repeated float fields with iterable.r  r  r   r  r  r  r  N)r&   r  r   re   r   r  r!  s      r   testExtendFloatWithIterablez'MessageTest.testExtendFloatWithIterable^  s   ##%AR!1!12K44R89R!1!12K44cU;<cUA$4$45K44c3Z@A_a.>.>?K44c3Z@A68H8HIr
   c                    |j                         }| j                  g |j                         |j                  j                  t        j                  g              | j                  g |j                         |j                  j                  t        j                  dg             | j                  dg|j                         |j                  j                  t        j                  ddg             | j                  g d|j                         |j                  j                  t        j                  ddg             | j                  g d|j                         y)	z4Test extending repeated string fields with iterable.r   12)r   r  r  34)r   r  r  r  r  N)r&   r  rd   re   r   r  r!  s      r   testExtendStringWithIterablez(MessageTest.testExtendStringWithIterablek  s   ##%AR!2!23[55b9:R!2!23[55rd;<bT1#4#45[55sCjAB^Q->->?[55sCjAB5q7H7HIr
   c                       e Zd ZdZddZd Zy)MessageTest.TestIndexzEThis index object mimics the behavior of numpy.int64 and other types.Nc                     || _         y r   value)r+   r  s     r   r  zMessageTest.TestIndex.__init__{  s	    djr
   c                     | j                   S r   r  r  s    r   	__index__zMessageTest.TestIndex.__index__~  s    ZZr
   r   )rW   rX   rY   r  r  r  r   r
   r   	TestIndexr  x  s    Or
   r  c                     |j                         }|j                  j                  g d       | j                  d|j                  t        j                  d                y )Nr   rH   r   r&   r   re   r5   r   r  r   s      r    testRepeatedIndexingWithIntIndexz,MessageTest.testRepeatedIndexingWithIntIndex  sJ    

%
%
'Ci(Q**;+@+@+CDEr
   c                     |j                         }|j                  j                  g d       | j                  d|j                  t        j                  d                y Nr   r   r   r  r   s      r   )testRepeatedIndexingWithNegative1IntIndexz5MessageTest.testRepeatedIndexingWithNegative1IntIndex  sJ    

%
%
'Ci(Q**;+@+@+DEFr
   c                     |j                         }|j                  j                  g d       | j                  d|j                  d          y r  r   r   s      r   $testRepeatedIndexingWithNegative1Intz0MessageTest.testRepeatedIndexingWithNegative1Int  s?    

%
%
'Ci(Q**2./r
   c                     |j                         }| j                  t        j                        5 }t        j                  |j
                  t        j                         d d d        y # 1 sw Y   y xY wr   )r&   r$   rj   PickleErrorrk   r   HIGHEST_PROTOCOLr  s       r   !testPickleRepeatedScalarContainerz-MessageTest.testPickleRepeatedScalarContainer  sU    ##%A			6--	. >!ll1##V%<%<=> > >s   /A((A1c                 X    |j                         }|j                  j                          y)z:Exercise a scenario that has led to segfaults in the past.N)r&   r   r   r!  s      r   'testSortEmptyRepeatedCompositeContainerz3MessageTest.testSortEmptyRepeatedCompositeContainer  s"    ##%A""$r
   c                     |j                         }| j                  t              5 }|j                  d       ddd       y# 1 sw Y   yxY w)z=Using HasField on a repeated field should raise an exception.r   N)r&   r$   r   r)  r  s       r   testHasFieldOnRepeatedFieldz'MessageTest.testHasFieldOnRepeatedField  sB    ##%A			:	& #!jj!"# # #s   AA
c                 0   |j                         }| j                  t              5 }|j                  j	                          d d d        |j                  j                  t        d             | j                  d|j                  j	                                | j                  d|j                  j	                  d             | j                  d|j                  j	                  d             | j                  ddg|j                         y # 1 sw Y   xY w)Nr   rI   r   r   rH   r   )r&   r$   
IndexErrorr   popre   r  r5   r  s       r   testRepeatedScalarFieldPopz&MessageTest.testRepeatedScalarFieldPop  s    ##%A			:	& !E!H%Q((,,./Q((,,Q/0Q((,,Q/0aVQ--. s   DDc                 N   |j                         }| j                  t              5 }|j                  j	                          d d d        | j                  t
              5 }|j                  j	                  d       d d d        t        d      D ]#  }|j                  j                         }||_        % | j                  d|j                  j	                         j                         | j                  d|j                  j	                  d      j                         | j                  d|j                  j	                  d      j                         | j                  ddg|j                  D cg c]  }|j                   c}       y # 1 sw Y   IxY w# 1 sw Y   xY wc c}w )NrG   r   rI   r   r   rH   r   )
r&   r$   r  r   r  rK   r  r   rr   r5   )r+   r,   r   r  rz  r  s         r   testRepeatedCompositeFieldPopz)MessageTest.testRepeatedCompositeFieldPop  sQ   ##%A			:	& &!##%&			9	% )##C()1X 

#
#
'
'
)aad 	Q11557::;Q1155a8;;<Q1155a8;;<aVA,E,EFqaddFG& &) ) Gs   FF-F"
FFc                 V   |j                         }t        d      D ]?  }|j                  j                  ||       |j                  j                         }||_        A | j                  |j                  |j                         | j                  |j                  |j                         y )Nr   )	r&   r  r   r   r   r   rr   r  r5   )r+   r,   r   rz  r  s        r   testRepeatedCompareWithSelfz'MessageTest.testRepeatedCompareWithSelf  s    ##%A1X a#

#
#
'
'
)aad 	Q--q/?/?@Q..0I0IJr
   c                     |j                         }|j                  j                         }|j                  }|j                  j                         }| j	                  |j
                  j                  d       y)zxA case that lead to a segfault when a message detached from its parent

    container has itself a child container.
    r   N)r(  repeated_childr   r.  r5   r'  optional_int32r!  s      r   testReleasedNestedMessagesz&MessageTest.testReleasedNestedMessages  s]    
 	))+A	A	A	AQYY--q1r
   c                    |j                         }| j                  t              5  g |_        d d d        |j                  j	                  d       | j                  t              5  g |_        d d d        y # 1 sw Y   JxY w# 1 sw Y   y xY w)NrH   )r&   r$   AttributeErrorr   r   r!  s      r   testSetRepeatedCompositez$MessageTest.testSetRepeatedComposite  s    ##%A			>	* aA			>	* a   s   A7&B7B Bc                    |j                         }| j                  t        t        |j                               | j                  t        t        |j
                               | j                  t        t        |j                               d|_        d|_        d|_        |j                  j                  d       |j                  j                  d       |j                  j                  d       |j                  |j                                | j                  t        t        |j                               | j                  t        t        |j
                               | j                  dt        |j
                               | j                  t        t        |j                               | j                  t        t        |j                  d                | j                  t        t        |j                  d                | j                  t        t        |j                  d                | j                  d|j                  d          y )NrH   z1.0r   T)r&   r5   r   typer}   r   r  optional_boolr   r   r   repeated_boolr3   r6   r)   r!  s      r   testReturningTypezMessageTest.testReturningType  s   ##%AUD!1!123UD!2!234T401AAAOAQOO1a))+,UD!1!123UD!2!234UC 1 123T401UD!1!1!!456UD!2!21!567T4 234T1??1-.r
   )ZrW   rX   rY   r/   r<   rE   rQ   rg   ro   ru   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"  r%  r*  r1  r3  r:  r=  rA  rE  rK  rQ  rS  rV  rY  r\  r^  ra  rd  rf  ri  rk  rn  rp  rt  r  	bytearraysetr  r  r  r  r  r  r  r  rf   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r
   r   r   r   M   s   
JC"
CD$"?H888F(F(<0FF:@BD+KZ<
4I
%J$$LP$
:9 H&KP8(B*F.)$H(, ;&+
#<	76,=.2
1$!/F)2&55	BCCP
AJ
A2>": q#sCb"ceL,334	@	J	NA#V #0@JJ& F
G
0
>%
#/HK	2/r
   r   c                   T    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)
Proto2Testc                    t        j                         }| j                   |j                  d             | j                   |j                  d             | j                   |j                  d             | j	                  t
              5   |j                  d       d d d        | j	                  t
              5   |j                  d       d d d        | j	                  t
              5   |j                  d       d d d        | j                  d|j                         | j                  d|j                         | j                  d|j                  j                         d|_        d|_        d|j                  _
        | j                   |j                  d             | j                   |j                  d             | j                   |j                  d             d	|_        d
|_        d|j                  _
        | j                   |j                  d             | j                   |j                  d             | j                   |j                  d              |j                  d        |j                  d        |j                  d       | j                   |j                  d             | j                   |j                  d             | j                   |j                  d             | j                  d|j                         | j                  d|j                         | j                  d|j                  j                         y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   ~xY w)Nr  r  r-  field_doesnt_existr   r   r   Fr   T   )r   r&   r<  r)  r$   r   r5   r  r  r-  rr   r   rU  r+   r   s     r   testFieldPresencezProto2Test.testFieldPresence  s   '')G%W%%&678%W%%o67%W%%&?@A			:	& -g+,- 
		:	& )g'()			:	& 2g012 	Q../UG112Q77::; G!G)*G##&OO$G$$%567OO$G$$_56OO$G$$%>?@ G G)+G##&OO$G$$%678OO$G$$_56OO$G$$%>?@ G'(G'(G01%W%%&678%W%%o67%W%%&?@AQ../UG112Q77::;O- -) )2 2s$   M"=M/-M<"M,/M9<Nc                    t        j                         }| j                  t              5 }d|_        ddd       | j                  t        |j
                  j                  d       |j
                  j                  d       d|j
                  d<   | j                  t              5  d|j
                  d<   ddd       t        j                         }d|_        |j
                  j                  d       |j                         }t        j                         }|j                  |       | j                  |j                  d             | j                  d|j                         | j                  dt        |j
                               |j                          |j                  |j                                | j                  d|j                         | j                  d|j
                  d          y# 1 sw Y   xY w# 1 sw Y   NxY w)	z:Assigning an invalid enum number is not allowed in proto2. Nr   r   i@ t optional_nested_enumrH   )r   r&   r$   r   r  r  r   r   r6   r3   r<  r)  r5   rB   r	  )r+   r   r  r  r   m3s         r   testAssignInvalidEnumz Proto2Test.testAssignInvalidEnum  s   !!#A 
		:	& '!&a'j!"8"8"?"?I!!!$ !A1			:	& )"(aQ) 
#	/	/	1B%B""7+%%'J		"	"	$Bz"R[[!789Q//0QB3345HHJr++-.Wb556Wb55a891' ') )s   G3$H 3G= H
c                     t        j                         }d|j                  d<   | j                  t              5  d|j
                  d<   d d d        y # 1 sw Y   y xY w)Nr   {   rH   )r   TestEnumMapknown_map_fieldr$   r   unknown_map_field)r+   r   s     r   testUnknownEnumMapzProto2Test.testUnknownEnumMap>  sS    ++-AAc			:	& #"a!# # #s   AAc                 d    t        j                         }| j                  t        t        |d       y )N
Extensions)r   r&   r$   r  r?  r+   rO   s     r   testExtensionsErrorszProto2Test.testExtensionsErrorsD  s$    

#
#
%CngsLAr
   c                    t        j                         }t        j                         }| j                  d|j                  j                  t         j
                            | j                  |j                  d             d|j                  j                  t         j
                  <   |j                  |       | j                  d|j                  j                  t         j
                            y )Nr   
submessager  )	r   TopLevelMessager5   r  r   optional_int_extensionr<  r)  r   r+   r/  r0  s      r   testMergeFromExtensionsz"Proto2Test.testMergeFromExtensionsH  s    ..0D..0D	""#6#M#MNP 	T]]<01MPDOO2IIJ 	NN4""#6#M#MNPr
   c                    t        j                  d      }t        j                         }|j	                  |       t        j                         }t        j
                  |       | j                  ||       | j                  ||j                                t        j                  |      }| j                  ||j                                y ri   )
r   r#   r   TestAllExtensionsr3   SetAllExtensionsr5   r6   r7   r8   r+   r9   r:   rD   r;   s        r   testGoldenExtensionszProto2Test.testGoldenExtensionsX  s    **+;<K!335N"";/,,.Gw'Wn-[."B"B"DE--/K[+"?"?"ABr
   c                    t        j                  d      }t        j                         }|j	                  |       t        j                         }t        j
                  |       | j                  ||       | j                  ||j                                t        j                  |      }| j                  ||j                                y r>   )
r   r#   r   TestPackedExtensionsr3   SetAllPackedExtensionsr5   r6   r7   r8   r  s        r   testGoldenPackedExtensionsz%Proto2Test.testGoldenPackedExtensionsc  s    **+IJK!668N"";///1G$$W-Wn-['";";"=>--/K[+"?"?"ABr
   c                 4   t        j                  d      }t        j                  |      }t        j                  |      }| j                  ||       | j                  |j                  d       | j                  t        j                  |j                         y )NrH   rw  )r   TestRequiredrj   rk   rl   r5   r   r$   r   EncodeErrorr6   )r+   r:   rm   rn   s       r   testPickleIncompleteProtoz$Proto2Test.testPickleIncompleteProton  st    !..3Nll>2O_5&7&((!,g))+<+N+NOr
   c                    t        j                         t        j                         t        j                         g}d|d   _        d|d   _        d|d   _        d|d   _        t        j                         }d|_        d|_        d|_        t         j
                  j                         }|j                  j                  |       |j                  j                  |       |j                  j                  |       |j                  j                  |       |j                  j                  |       |j                  j                         j                  j                  |d          |j                  j                         j                  j                  |d          |j                  j                         j                  j                  |d          |j                   j                         j                  j                  |d          |j                   j                         j                  j                  |d          |j                   j                         j                  j                  |d          |j#                         }t        j
                         }|j%                  |       | j'                  |j(                  |       | j'                  |j*                  |       | j'                  |j,                  j.                  |       | j'                  |j0                  t         j
                  j2                     |       | j'                  t5        |j6                        d       | j'                  t5        |j8                        d       | j'                  t5        |j0                  t         j
                  j:                           d       y)ziCheck the merge behavior when a required or optional field appears

    multiple times in the input.
    rH   r   r   r   helloN)r   r&   r  optional_int64r5  TestParsingMergeRepeatedFieldsGeneratorfield1re   field2field3ext1ext2group1r   r   group2r6   r3   r5   required_all_typesoptional_all_typesoptionalgroupoptional_group_all_typesr   optional_extrB   repeated_all_typesrepeatedgrouprepeated_ext)r+   messagesmerged_message	generatordataparsing_merges         r   testParsingMergezProto2Test.testParsingMerge{  s    	!!#!!#!!#H
 "#HQK!"HQK!"HQK")HQK!..0N$%N!$%N!%,N"--EEGIH%H%H%NN(#NN(#!!++HQK8!!++HQK8!!++HQK8!!++HQK8!!++HQK8!!++HQK8&&(D 113M!!$' 	]55~F]55~F]00II#%  !>!>!K!KL
 	S99:A>S445q9M$$))668 	9:;=r
   c                 	   t        j                  ddddddiddii d	dd
iddigdt         j                  j                  gdd      }| j                  |t         j                         | j	                  d|j
                         | j	                  d|j                         | j	                  d|j                         | j	                  d|j                         | j	                  d|j                  j                         | j                  |j                  t         j                  j                         | j	                  d|j                  j                         | j                   |j                  d             | j	                  |j                   t        j"                                | j	                  t         j                  j$                  |j&                         | j	                  dt)        |j*                               | j	                  d
|j*                  d   j                         | j	                  d|j*                  d   j                         | j	                  dt)        |j,                               | j	                  t         j                  j.                  |j,                  d          | j	                  t         j                  j                  |j,                  d          | j	                  d|j0                         | j	                  d|j2                         | j5                   |j                  d             | j	                  dt)        |j6                               | j	                  d|j8                         t        j                  d	      }| j	                  t         j                  j$                  |j&                         | j;                  t<              5  t        j                  ddi       d d d        | j;                  t>              5  t        j                  ddi       d d d        | j;                  t<              5  t        j                  d       d d d        | j;                  t<              5  t        j                  d       d d d        y # 1 sw Y   xY w# 1 sw Y   ~xY w# 1 sw Y   VxY w# 1 sw Y   y xY w)Nd      g     r@   xr   i  rr   i  BAZiX  i  FOOi   r   )r  optional_fixed32r}   r6  r$  r-  optional_foreign_messager  r(  r  default_int32rI  r7  r   r   rH   r  *   )r  INVALID_NESTED_FIELD   )r-  INVALID_VALUE_TYPEINVALID_LABEL)r  ) r   r&   BARr  r5   r  r6  r}   r6  r$  r   r-  rt   rr   r   r)  r7  ForeignMessager4  r  rB   r(  r  r5  r8  rI  r<  r   default_int64r$   r   rK   r  s     r   testPythonicInitzProto2Test.testPythonicInit  s   ''Cj!%s!#"
 

 $\%>%>%B%BC!G" 	'<#<#<=S'001S'223UG223T7112S'//112'99&33AACS'99<<=OO$G$$%?@AW55!0024\..22113QG1123S'//2445S'//2445QG889:\..2211!46\..2211!46S'//0S'../%W%%&678QG2234R../''VDG\..22113 
		:	& @#92">@@ 
		9	% @#')=">@@ 
		:	& F_EF 
		:	& <U;< <@ @@ @F F< <s0   RR(R4<S R%(R14R= S	c                     ddd}t        j                  di |}| j                  d|j                         | j                  d|j                         y )Nr1  r2  )r  r6  r   )r   r&   r5   r  r6  )r+   kwargsrO   s      r   testPythonicInitWithDictz#Proto2Test.testPythonicInitWithDict  sR      F 
#
#
-f
-CS#,,-S#../r
   c                 >   t         j                  j                  t        j                  d      }| j                  d|       | j                  d|       | j                  d|       t        j                  j                  d   }| j                  t        t        |d       y )Nr   zclass TestAllTypesSerializePartialToStringr   r   _extensions_by_name)
pydochtmldocumentr   r&   r(   	__bases__r$   r  r?  )r+   docbases      r   test_documentationzProto2Test.test_documentation  sv    
**

l77
CCMM&,MM,c2MM"C($$..q1Dngt5JKr
   N)rW   rX   rY   r  r  r  r  r  r  r  r  r/  rA  rD  rN  r   r
   r   r  r    sG    .<`:>#BP 	C	CP3=j><@0Lr
   r  c                   H   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) e*jV                  e,jZ                  e.k(  d(      d)        Z/d* Z0y+),
Proto3Testc                     t        |      }|D ]  \  }}| j                  |||          ||=  | j                  i |       y r   )dictr5   )r+   map_iter
dict_valuer  vs        r   assertMapIterEqualszProto3Test.assertMapIterEquals
  sL    j!J 1
q*Q-(
Q- 	R$r
   c                    t        j                         }| j                  t              5   |j                  d       d d d        | j                  t              5   |j                  d       d d d        | j                  t              5   |j                  d       d d d        | j                  t              5   |j                  d       d d d        | j                   |j                  d             | j                  t              5   |j                  d       d d d        | j                  t              5   |j                  d       d d d        | j                  t              5   |j                  d       d d d        | j                  d	|j                         | j                  d	|j                         | j                  d
|j                         | j                  d|j                         | j                  d	|j                  j                         d	|j                  _        | j                   |j                  d             d|_        d|_        d|_	        d|_
        d|j                  _         |j                  d        |j                  d        |j                  d        |j                  d        |j                  d       | j                  d	|j                         | j                  d	|j                         | j                  d
|j                         | j                  d|j                         | j                  d	|j                  j                         y # 1 sw Y   1xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   axY w# 1 sw Y   >xY w)Nr  r}   r5  r  r-  r  r   r   r   r   Fr   r   r  Tr  )r   r&   r$   r   r)  r<  r5   r  r}   r5  r  r-  rr   r   rU  r  s     r   r  zProto3Test.testFieldPresence  s<   '446G 
		:	& )g'()			:	& )g'()			:	& *g()*			:	& (g'( 	%W%%&?@A 
		:	& -g+,- 
		:	& )g'()			:	& 2g012 	Q../Q../R001UG112Q77::; *+G##&OO$G$$%>?@ G G#G G)+G##& G'(G'(G()G'G01Q../Q../R001UG112Q77::;g) )) )* *( (- -) )2 2sS   M,M9
N:NN ;N-+N:,M69NNN N*-N7:Oc                 `   t        j                         }d|_        d|_        d|_        | j                  t        |j                               d       t        j                         }|j                  |j                                | j                  t        |j                               d       y )Nr   r   r
   r   )r   r&   r  r5  r6  r5   rB   
ListFieldsr   r3   r6   )r+   message_proto2message_proto3s      r   !testProto3ParserDropDefaultScalarz,Proto3Test.testProto3ParserDropDefaultScalarM  s    !..0N$%N!%'N"$'N!S2245q9.;;=N"">#C#C#EFS2245q9r
   c                 H   t        j                         }| j                  |j                  d             | j                  |j                  d             | j                  |j                  d             | j                  |j                  d             | j                  |j                  j                  d             d|_        d|_        d|_        d|j                  _        | j                  |j                  d             | j                  |j                  d             | j                  |j                  d             | j                  |j                  d             | j                  |j                  j                  d             d	|_        d
|_        d|_        d	|j                  _        | j                  |j                  d             | j                  |j                  d             | j                  |j                  d             | j                  |j                  d             | j                  |j                  j                  d             t        j                         }|j                  |j                                | j                  |j                  d             | j                  |j                  d             | j                  |j                  d             | j                  |j                  d             | j                  |j                  j                  d             | j                  |j                  d      d       |j                  d       |j                  d       |j                  d       |j                  d       | j                  |j                  d             | j                  |j                  d             | j                  |j                  d             | j                  |j                  d             | j                  |j                  j                  d             | j                  |j                  d      d        t         j                  j                  j                   D ]  }| j                  |j"                          t$        j&                  j                  j                   D ]`  }|j(                  t*        j,                  j.                  k(  r| j                  |j"                         F| j                  |j"                         b t0        j&                  j                  }|j2                  d   }| j                  |j"                         |j2                  d   }| j                  |j"                         |j2                  d   }| j                  |j"                         |j2                  d   }| j                  |j"                         |j2                  d   }	| j                  |	j"                         y )Nr  r}   r5  r-  rr   rH   r  123r   r  r   _optional_int32r   proto3_optional_int32rH  )r   TestProto3Optionalr<  r)  r-  r  r}   r5  rr   r   r3   r6   r5   rD  rU  
DESCRIPTORfieldshas_presencer   r&   labelr   FieldDescriptorLABEL_REPEATEDr   fields_by_name)
r+   rO   r0  fieldproto3_descriptorrepeated_fieldsingular_fieldoptional_fieldmessage_fieldrG  s
             r   testProto3OptionalzProto3Test.testProto3OptionalX  s   
"
5
5
7CS\\"234S\\"234S\\"345S\\";<=S0099$?@ CCC%&C"OOCLL!123OOCLL!123OOCLL!234OOCLL!:;<OOC//88>?CCC%&C"OOCLL!123OOCLL!123OOCLL!234OOCLL!:;<OOC//88>? $668D..01OODMM"234OODMM"234OODMM"345OODMM";<=OOD0099$?@S^^$568HI NN#$NN#$NN$%NN,-S\\"234S\\"234S\\"345S\\";<=S0099$?@S^^$56= *<<GGNN *
ooe(()***55<< ,	
22AA	A++,**+	,
 2>>II&556FGN^001&556FGN^001&556MNNOON//0%445NOMOOM../#22>BKOOK,,-r
   c                 "   t        j                         }d|_        | j                  d|j                         |j                  j                  d       | j                  d|j                  d          d|j                  d<   | j                  d|j                  d          |j                         }t        j                         }|j                  |       | j                  d|j                         | j                  d|j                  d          y)zCAssigning an unknown enum value is allowed and preserves the value.r  iTr   r  N)r   r&   r  r5   r  r   r6   r3   )r+   r   r   r  s       r   testAssignUnknownEnumz Proto3Test.testAssignUnknownEnum  s    !..0A %AWa445!!(+Xq55a89 'A1Wa44Q78$$&J	"	/	/	1Bz"Wb556Wb55a89r
   c                 F   t        j                         }| j                  d|j                  v        | j                  d|j                  v        | j                  d|j
                  v        | j                  d|j                  v        | j                  d|j                  v        | j                  d|j                  v        | j                  d|j                  v        | j                  d|j                  v        | j                  d|j                  v        | j                  d	|j                  d          | j                  d	|j                  d          | j                  d	|j
                  d          | j                  d	|j                  d          | j                  d
|j                  d          | j                  t        |j                  d   t                     | j                  d|j                  d          | j                  t        |j                  d   t                      | j                  d|j                  d          | j                  d|j                  d          | j                  d	|j                  d          | j                  d|j                  v        | j                  d|j                  v        | j                  d|j
                  v        | j                  d|j                  v        | j                  d|j                  v        | j                  d|j                  v        | j                  d|j                  v        | j                  d|j                  v        | j                  d|j                  v        | j#                  |j                  d   t$               | j'                  t(              5  |j                  d    d d d        | j'                  t(              5  d|j                  v  d d d        y # 1 sw Y   6xY w# 1 sw Y   y xY w)N     r          Fr  o   x  r   r  r   r
   )r   TestMapr<  map_int32_int32map_int64_int64map_uint32_uint32map_uint64_uint64map_int32_doublemap_bool_boolmap_string_stringmap_int32_bytesmap_int32_enumr5   r   
isinstancer   r  r  r)   r$   rK   r  s     r   testScalarMapDefaultsz Proto3Test.testScalarMapDefaults  s{   

"
"
$C 	TS0001Vs2223SC1112Uc3334SC0001Uc///0Uc3334SC///0SC.../ 	Q++D12Q++F34Q--c23Q--e45S#..s34OOJs33C8%@AUC--e45OOJs007>?R..u56S#--c23Q**3/0 	OODC///0OOFc1112OOC30001OOES2223OOC3///0OOES.../OOES2223OOC3.../OOC3---.#//6< 
		9	% !	C ! 
		9	% #	S"""# #! !# #s   P3PPP c                    t        j                         }| j                  |j                  j	                  d             | j                  d|j                  j	                  dd             | j                  d|j                  j	                  dd             | j                  |j                  j	                  d             d|j                  d<   | j                  d|j                  j	                  d             | j                  d|j                  j	                  d             | j                  t              5  |j                  j	                  d       d d d        | j                  |j                  j	                  d             | j                  d|j                  j	                  dd             | j                  d|j                  j	                  dd             |j                  d   }| j                  ||j                  j	                  d             | j                  t              5  |j                  j	                  d       d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)Nr   r  )r   defaultr  r   )
r   rx  rm  ry  getr5   r$   rK   map_int32_foreign_messagerJ  )r+   rO   submsgs      r   
testMapGetzProto3Test.testMapGet  s    
"
"
$Cc))--a01R,,00B78R,,00Q0CDc))--a01CR,,0034R,,0034			9	% "	b!" 	c3377:;R66::1bABR66::q":MN**1-FMM&#77;;A>?			9	% ,	##''+, ," ", ,s   <I2I$I!$I-c                    t        j                         }| j                  dt        |j                               | j                  d|j                  v        d|j                  d<   d|j                  d<   d|j                  d<   d	|j                  d
<   d|j                  d<   d|j                  d<   d|j                  d<   d|j                  d<   d|j                  d<   d|j                  d<   | j                  g |j                                | j                  dt        |j                               | j                  t               5  d|j                  d<   d d d        | j                  dt        |j                               | j                  t               5  d|j                  d<   d d d        |j#                         }t        j                         }|j%                  |       | j                  t               5  d|j                  d<   d d d        | j                  t               5  d|j                  d<   d d d        | j                  d|j                  d          | j                  d|j                  d          | j                  d|j                  d          | j                  d	|j                  d
          | j'                  d|j                  d          | j                  d|j                  d          | j                  d|j                  d          | j                  d|j                  d          | j                  d|j                  d          | j                  d|j                  d          | j                  dt)        |j                               y # 1 sw Y   GxY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w)Nr   r   8rs       rt    r          ru  r   r   gffffff
@rH   r^  r  Trw  z{-123: -456})r   rx  r5   rB   ry  r<  rz  r{  r|  map_int32_floatr}  r  r~  r  FindInitializationErrorsr$   rK   r6   r3   r   r)   r+   rO   r   r0  s       r   testScalarMapzProto3Test.testScalarMap  sa   

"
"
$CQC//01Q#---. $C"(C!$C##(C%  C!C#(C% "CdCs!CsR5578QC1123 
		9	% )#(cC )
 	QC1123 
		9	% )%(cE") &&(J##%D$ 
		9	% *$)dS!* 
		9	% *&)dU#* 	T4//56VT11&9:S$0056UD2259:3 3 3A 67S#..q12UD2259:T4--d34Q++C01S$--c23^S)=)=%>?C) )) )* ** *s0   NN);N6(ON&)N36O Oc                     t        j                         }d|j                  d<   d|j                  d<   | j	                  |j                         d       | j	                  d|j                                y )Nr   r   rh  s   
  r
  )r   rx  ry  r  r5   ByteSizer6   r  s     r   testMapEntryAlwaysSerializedz'Proto3Test.testMapEntryAlwaysSerialized<  sc    

"
"
$CC "C"S\\^R(A**,.r
   c                 b   t        j                         }d}|j                  d      }||j                  |<   t	        |j                  j                               d   \  }}| j                  ||       | j                  ||       | j                  |t               | j                  |t               y )Nu   ሴutf8r   )	r   rx  encoder  r  itemsr5   r  r)   )r+   rO   unicode_obj	bytes_objr   r  s         r    testStringUnicodeConversionInMapz+Proto3Test.testStringUnicodeConversionInMapD  s    

"
"
$CK""6*I'0C)$--3356q9LS%S+&UK(#s#%%r
   c                 4   t        j                         }| j                  dt        |j                               | j                  d|j                  v        |j                  d    |j                  j                  d       | j                  dt        |j                               | j                  d|j                         | j                  d|j                         | j                  dt        |j                               | j                  t              5  |j                  d    d d d        | j                  t              5  |j                  d   |j                  d<   d d d        | j                  dt        |j                               |j                         }t        j                         }|j                  |       | j                  dt        |j                               | j                  d|j                         | j                  d|j                         | j                  dt        |j                               d|j                  d   _        | j                  t        |j                        d	       y # 1 sw Y   ZxY w# 1 sw Y   -xY w)
Nr   r   r  r  r   r^  r   rH   )z{-456: , 123: c: 1
}z{123: c: 1
, -456: })r   rx  r5   rB   r  r<  get_or_creater(   r$   rK   r   r6   r3   r   r)   r  s       r   testMessageMapzProto3Test.testMessageMapT  s   

"
"
$CQC99:;Q#7778!!#&!!//5QC99:;MM#s445MM$556QC99:; 
		9	% +	##E*+ 
		:	& N+.+H+H+Mc##C(N
 	QC99:;&&(J##%D$QD::;<MM#t556MM$667QD::;<,-D""3')MMD**+:<++ +N Ns   J J J
Jc                 (   t        j                         }d|j                  d   j                  _        |j                  d= d|j                  d   j                  _        | j                  dt        |j                               d|j                  d   j                  _        | j                  dt        |j                               |j                         }t        j                         }|j                  |       ddg}|D ]  }|j                  |=  y )NrH   r   )	r   rx  map_int32_all_typesr-  rr   r5   rB   r6   r3   )r+   rO   r   r0  keysr   s         r   testNestedMessageMapItemDeletez)Proto3Test.testNestedMessageMapItemDelete}  s    

"
"
$C<=CA669"<=CA669QC3345<=CA669QC3345&&(J##%D$q6D (

"
"3
'(r
   c                    t        j                         }d|j                  d<   |j                         }d|j                  d<   | j	                  |j                         |dz          d|j
                  d   _        |j                         }d|j
                  d   _        | j	                  |j                         |dz          y )NrH         )r   rx  ry  r  r5   r  r   )r+   rO   r  s      r   testMapByteSizezProto3Test.testMapByteSize  s    

"
"
$CC<<>D CS\\^TAX.*+C!!"%'<<>D*-C!!"%'S\\^TAX.r
   c                 v   t        j                         }d|j                  d<   d|j                  d<   d|j                  d<   d|j                  d   _        d	|j                  d
   _        t        j                         }d|j                  d<   d|j                  d<   d|j                  d
   _        d|j                  d
   _        |j                  d
   }|j                  |       t        j                         }|j                  |       d|j                  d<   | j                  ||       | j                  d|j                  d          | j                  d|j                  d          | j                  d|j                  d          | j                  d|j                  d          | j                  d|j                  d   j
                         | j                  d	|j                  d
   j
                         | j                  |j                  d
   j                  d             t        j                         dk7  r| j                  d|j
                         i }|j                  D ]1  }| j                  ||v        |j                  |   j
                  ||<   3 | j                  dd	d|       |j                  d= | j                  d|j                  v        |j                  d
= | j                  d
|j                  v        | j                  t              5  |j                  d= d d d        y # 1 sw Y   y xY w)N"   rh  N   8   r     r   rv  r     7   r   X   r  r  dcpp)rv  r  r   )r   rx  ry  rz  r  r   r  r   rc  r5   r<  r)  r   r!   r$   rK   )r+   rO   r0  old_map_valueexpected_msgas_dictr   s          r   r1  zProto3Test.testMergeFrom  s   

"
"
$C C C C+,C!!#&(+-C!!#&(##%D!D!D,.D""3'),.D""3')2237MNN3 $++-L#')L  $T<(R--b12R--b12R--b12R--b12Q66s;==>R77<>>?T33C8AA#FG E) r=??+
 G-- ;
sg~&33C8::gcl; 	12&0 	R R4///0&&s+SD:::;			9	% -

(
(
,- - -s   L//L8c                 l   t        j                         }d|j                  d<   d|j                  d<   d|j                  d<   d|j                  d   _        d	|j                  d
   _        t        j                         }d|j                  d<   d|j                  d<   d|j                  d
   _        d|j                  d
   _        |j                  j                  |j                         | j                  d|j                  d          | j                  d|j                  d          |j                  j                  |j                         | j                  d|j                  d          | j                  d|j                  d          |j                  j                  |j                         t        j                         }|j                  |       d|j                  d<   | j                  ||       t        j                         }t        j                         }| j                  |j                  |j                         d	|j                  d   _        |j                  |       | j                  d	|j                  d   j
                         t        j                         }t        j                         }d	|j                  d   _        |j                  j                  |j                         | j                  d	|j                  d   j                         t        j                         }d|j                  d
   _        t        j                         }d|j                  d
   _        |j                  |j                                | j                  |j                  d
   j                  d       | j!                  |j                  d
   j
                  d       | j#                  t$              5  |j                  j                  dt'        j(                         i       d d d        y # 1 sw Y   y xY w)Nr  rh  r  r  r  r  r   rv  r  r  r  r   r  r  r  r  rH   )r   rx  ry  rz  r  r   r  r   r5   rc  TestMessageMapmap_int32_messager  r  r
  r6   assertNotEqualr$   r  r   r&   )r+   rO   r0  r  r  r  s         r   testMapMergeFromzProto3Test.testMapMergeFrom  s   

"
"
$C C C C+,C!!#&(+-C!!#&(##%D!D!D,.D""3'),.D""3')""3#6#67R--b12R--b12""3#6#67R--b12R--b12"",,S-J-JK $++-L#')L  $T<( 
	!	!	#B		!	!	#BR1123O3OP*,B  %'LLR55c:<<= 
	!	!	#B		(	(	*B/1B,$$R%9%9:R//4CCD 
"
"
$C+.C!!#&(##%D,.D""3')..01S2237992>55c:<<cB 
		>	* 9&&'446
799 9 9s   10P**P3c                     t        j                         }| j                  t        d      5  |j	                  d       d d d        y # 1 sw Y   y xY w)NzWParameter to MergeFrom\(\) must be instance of same class: expected .+TestMap got int\.rH   )r   rx  assertRaisesRegexrK   r   r  s     r   testMergeFromBadTypezProto3Test.testMergeFromBadType  sI    

"
"
$C				
   
mmA	     AAc                     t        j                         }| j                  t        d      5  |j	                  d       d d d        y # 1 sw Y   y xY w)Nz[Parameter to [A-Za-z]*From\(\) must be instance of same class: expected .+TestMap got int\.rH   )r   rx  r  rK   rc  r  s     r   testCopyFromBadTypezProto3Test.testCopyFromBadType  sH    

"
"
$C				(
)  
ll1o	  r  c                    t        j                         }t        d      |j                  t        d      <   t        d      |j                  t        d      <   t        d      |j
                  t        d      <   t        d      |j                  t        d      <   |j                         }t        j                         }|j                  |       | j                  d|j                  d          | j                  d|j                  d          | j                  d|j
                  d          | j                  d|j                  d          y )	Nr  rs  r  rt  r  r  r  ru  )
r   rx  rr  ry  rz  r{  r|  r6   r3   r5   r  s       r   testIntegerMapWithLongsz"Proto3Test.testIntegerMapWithLongs%  s   

"
"
$C%(YCD	"'*6{CF$&)#hC#c(#(+E
C#e*%&&(J##%D$T4//56VT11&9:S$0056UD2259:r
   c                 2   t        j                         }d|j                  j                  d<   |j	                         }t        j                         }|j                  |       | j                  ||       d|j                  j                  d<   |j	                         }|j                  |       | j                  ||       |j                  j                  j                          |j	                         }|j                  |       | j                  ||       y )Nr  r  r   rw  )r   TestMapSubmessagetest_mapry  r6   r3   r5   clearr  s       r   testMapAssignmentCausesPresencez*Proto3Test.testMapAssignmentCausesPresence5  s    

,
,
.C(+CLL  %&&(J--/D$S$ ),CLL  %&&(J$S$LL  &&(&&(J$S$r
   c                 *   t        j                         }d|j                  j                  d   _        |j                         }t        j                         }|j                  |       | j                  ||       d|j                  j                  d   _        |j                         }|j                  |       | j                  ||       |j                  j                  d   j                  |j                  j                  d          |j                         }|j                  |       | j                  ||       |j                  j                  j                          |j                         }|j                  |       | j                  ||       y )Nr   r  r   rw  )
r   r  r  r  r   r6   r3   r5   r   r  r  s       r   -testMapAssignmentCausesPresenceForSubmessagesz8Proto3Test.testMapAssignmentCausesPresenceForSubmessagesK  sC   

,
,
.C45CLL**3/1&&(J--/D$S$ 56CLL**3/1&&(J$S$LL**3/99..s35&&(J$S$LL**002&&(J$S$r
   c                    t        j                         }t        |j                        }t        |j                        }d|j                  d<   d|j                  d   _        | j                  t              5  |D ]  } 	 d d d        | j                  t              5  |D ]  } 	 d d d        y # 1 sw Y   0xY w# 1 sw Y   y xY w)Nr^  r  r   )r   rx  iterr  r  r   r$   RuntimeError)r+   rO   string_string_iterint32_foreign_iterr   s        r   testModifyMapWhileIteratingz&Proto3Test.testModifyMapWhileIteratingg  s    

"
"
$Cc334c;;<#(C% )*C!!!$&			<	( # # 
		<	( # # 	  s   7B/B;/B8;Cc                 t   t        j                         }d|j                  d<   d|j                  d<   d|j                  d<   d|j                  d   _        d|j                  d   _        d	|j                  d	   _        t        |j                  j                               }t        |j                  j                               }g }|j                  D ]"  }|j                  |       d
|j                  |<   $ | j                  ||       | j                  |t        |j                  j                                      g }|j                  D ]'  }|j                  |       d|j                  |   _        ) | j                  ||       | j                  |t        |j                  j                                      y )Nr^  r  456def789ghir   r   r   000r   )	r   rx  r  r  r   r  r  r   r5   )r+   rO   string_string_keysint32_foreign_keysr  r   s         r    testModifyMapEntryWhileIteratingz+Proto3Test.testModifyMapEntryWhileIteratingx  s   

"
"
$C#(C% #(C% #(C% )*C!!!$&)*C!!!$&)*C!!!$&c3388:;c;;@@BCD$$ )
kk##(cC ) 	T-.T4 5 5 : : <=>D,, /
kk#-.c##C(*/ 	T-.T4 = = B B DEFr
   c                 (   t        j                         }|j                  d   }| j                  ||j                  d          | j	                  |t
        j                         d|_        |j                         }t        j                         }|j                  |       | j                  d|j                  d   j                         | j                  t              5  t        j                         |j                  d<   d d d        y # 1 sw Y   y xY w)Nrv  r   r  )r   rx  r  rJ  r  r   r?  r   r6   r3   r5   r$   r   )r+   rO   r  r   r0  s        r   testSubmessageMapzProto3Test.testSubmessageMap  s    

"
"
$C**3/FMM&#77<=&,"="=>FH&&(J##%D$Q66s;==> 
		:	& H*6*E*E*Gc##B'H H Hs   "DDc                    t        j                         }|j                  j                         D ]  \  }}| j	                  d        d|j                  d<   d|j                  d<   d|j                  d<   | j                  dt        |j                               dddd}| j                  |j                  j                         |       y )NFrI   r   r   r      r   r   rI   )r   rx  ry  r  r   r5   rB   rV  )r+   rO   r  rU  matching_dicts        r   testMapIterationzProto3Test.testMapIteration  s    

"
"
$C##))+ 1
ooe CCCQC//01aA&MS00668-Hr
   c                 N   t        j                         }d|j                  d<   d|j                  d<   d|j                  d<   d|j                  d<   d|j                  d<   |j                  j                         }|j                  j                         }| j	                  ||       y )Nr   local_init_optrainable_variables	variablesinit_op	summaries)r   rx  r  r  r5   )r+   rO   items1items2s       r   testMapItemszProto3Test.testMapItems  s    
 
"
"
$C-/C/*35C/0)+C+&')C)$)+C+&""((*F""((*FVV$r
   c                    d}t        j                         }d|j                  d<   d|j                  d<   d|j                  d<   d|j                  d	<   d
|j                  d<   d
|j                  d<   d|j                  d<   d|j                  d<   d|j                  d<   | j                  ||j	                  d             y )Ns   r
init_opdr

item1er

item2fr

item3gr
item4QQr
local_init_opar
	summarieser
trainable_variablesbr
	variablescr   r  r   r  r   r  r  r  er  item1fitem2gitem3QQitem4TrS   )r   rx  r  r5   r6   )r+   r9   rO   s      r   !testMapDeterministicSerializationz,Proto3Test.testMapDeterministicSerialization  s    2K 
"
"
$C-0C/*36C/0),C+&'*C)$),C+&%(C'"%(C'"%(C'"%)C'" 	[#"7"7d"7"KLr
   c                     t        j                         }d|j                  d<   d|j                  d<   d|j                  d<   |j                  j                         }~dddd}| j	                  ||       y )NrI   r   r   r   r  r  )r   rx  ry  r  rV  )r+   rO   itr  s       r   testMapIterationClearMessagez'Proto3Test.testMapIterationClearMessage  ss    

"
"
$CCCC				"	"	$BaA&MR/r
   c                 \   t        j                  ddd      }| j                  d|j                  d          | j                  d|j                  d          t        j                  dt	        j
                  d      i	      }| j                  d|j                  d   j                         y )
Nr   rI   )rH   r   ry  rH   r   r   )r   )r  )r   rx  r5   ry  r   r?  r  r   r  s     r   testMapConstructionzProto3Test.testMapConstruction  s    

"
"qQ<
@CQ++A./Q++A./

"
"#$l&A&AA&F"GICQ55a8::;r
   c                     t        j                         }d|j                  d<   t        j                  |j                        }| j                  d|j                  d          y )Nr9  rH   r  )r   rx  ry  r5   r  s      r   testMapScalarFieldConstructionz)Proto3Test.testMapScalarFieldConstruction  sQ    ##%D D##D4H4HIDR--a01r
   c                     t        j                         }d|j                  d   _        t        j                  |j                        }| j	                  d|j                  d   j                         y )Nr9  testmap_string_foreign_message)r   rx  r  r   r5   r  s      r   testMapMessageFieldConstructionz*Proto3Test.testMapMessageFieldConstruction  s^    ##%D02D##F+-###'#B#BDDR88@BBCr
   c                     | j                  t              5  t        j                  d       d d d        y # 1 sw Y   y xY w)NrH   r  )r$   rK   r   rx  r  s    r   testMapFieldRaisesCorrectErrorz)Proto3Test.testMapFieldRaisesCorrectError	  s3    			9	% =!<= = =s   6?c                    t        j                         }|j                  }d|d<   d|d<   d|d<   |j                  d       | j	                  d|j                                dddd}| j                  |j                         |       y )	NrI   r   r   r   r  ry  r
   r  )r   rx  ry  rU  r5   r6   rV  r  )r+   rO   	int32_mapr  s       r   testMapValidAfterFieldClearedz(Proto3Test.testMapValidAfterFieldCleared	  s     
"
"
$C##IIaLIaLIaLNN$%S#//12aA&MY__.>r
   c                     t        j                         }|j                  }d|d   _        |j	                  d       | j                  d|j                                | j                  d|j                         v        y )Nr   r   r  r
   )	r   rx  r  r   rU  r5   r6   r   r  )r+   rO   int32_foreign_messages      r   $testMessageMapValidAfterFieldClearedz/Proto3Test.testMessageMapValidAfterFieldCleared	  sm     
"
"
$C99!"!NN./S#//12OOA.33556r
   c                 8   t        j                         }d|j                  d   _        t	        j
                         dk(  r|j                  }|j                  d   }|j                          d|j                  d   _        | j                  |j                  d       y )Nbarr   r  rM  r   )r   rx  r  r5  r   r!   r	  r5   )r+   rO   
unused_map	msg_values       r   -testMessageMapItemValidAfterTopMessageClearedz8Proto3Test.testMessageMapItemValidAfterTopMessageCleared(	  s     
"
"
$C16CA. E) **j''*IIIK 27CA.Y..6r
   c                    t        j                         }t        |j                        }|j	                  d       | j                  t              5  |D ]  } 	 d d d        t        |j                        }|j	                  d       | j                  t              5  |D ]  } 	 d d d        y # 1 sw Y   VxY w# 1 sw Y   y xY w)Nry  r  )r   rx  r  ry  rU  r$   r  r  )r+   rO   r  r  s       r   "testMapIterInvalidatedByClearFieldz-Proto3Test.testMapIterInvalidatedByClearField:	  s    
 
"
"
$C	c!!	"BNN$%			<	(  ! 
c++	,BNN./			<	(  !   s   B.B:.B7:Cc                    t        j                         }| j                  dt        |j                               d|j                  d<   | j                  dt        |j                               | j                  t              5  |j                  d= d d d        |j                  d= | j                  dt        |j                               | j                  t              5  |j                  d= d d d        y # 1 sw Y   gxY w# 1 sw Y   y xY w)Nr   r   rI   rH   r      )r   rx  r5   rB   ry  r$   KeyErrorr  r  s     r   testMapDeletezProto3Test.testMapDeleteN	  s    

"
"
$CQC//01CQC//01			8	$ "


b
!" 	AQC//01			8	$ &

!
!"
%& &" "& &s   C7 D7D Dc                    t        j                         }| j                  |j                  t        j
                  j                         | j                  |j                  t        j
                  j                         | j                  |j                  t        j
                  j                         | j                  |j                  t        j
                  j                         y r   )	r   rx  r  ry  r  r  MappingMutableMappingr  r  s     r   testMapsAreMappingzProto3Test.testMapsAreMapping_	  s    

"
"
$C#--{/F/FG#--{/M/MN#77%//113#77%//88:r
   c                    t        j                         }d|j                  d<   | j                  |j                  |j                         | j                  |j                  |j                         | j                  |j                  d       y )Nr  rs  r   )r   rx  ry  r5   r  r  r  s     r   testMapsComparezProto3Test.testMapsCompareh	  sq    

"
"
$C $CS((#*=*=>S22224++Q/r
   c                     t        j                         }d|j                  d<   d|j                  d<   d|j                  d   _        | j                  dt        |j                                      y )Nr^  r  @   #   r   rM  r   )	r   rx  r  ry  r  r   r5   rB   r  r  s     r   (testMapFindInitializationErrorsSmokeTestz3Proto3Test.testMapFindInitializationErrorsSmokeTestp	  sa    

"
"
$C#(C%  C./C""5)+QC88:;<r
   zSkip for ucs2c                    d}t        j                         }| j                  t              5 }|j	                  |       d d d        t        j                         dk(  r&| j                  dt        j                               n%| j                  dt        j                               t        j                  d      j                         }t        j                         }|j	                  |       | j                  |j                  d       t        j                  d      }| j                  |j                  d       y # 1 sw Y   xY w)Ns   rr   r5  Error parsing messageu   😍r5  u   퀁)r   r&   r$   rL   r
  r   r!   r(   r)   r*   r6   r5   r5  )r+   r   rO   r.   r0  s        r   testStrictUtf8CheckzProto3Test.testStrictUtf8Checkw	  s    'J
#
0
0
2C			9	% &	*%& H,
mm%s7+<+<'=>
mm+S1B1B-CD +77!!2!2!4 $113D$T))73
#
0
0
KCS(()4& &s   E  E
c                    | j                  t              5  t        j                  d       d d d        | j                  t              5  t        j                  d       d d d        | j                  t              5  t        j                  d       d d d        | j                  t              5  t        j                  d       d d d        y # 1 sw Y   xY w# 1 sw Y   ~xY w# 1 sw Y   VxY w# 1 sw Y   y xY w)Nu   r  s   u   u   )r$   r   r   r&   r  s    r   testSurrogatesInPython3z"Proto3Test.testSurrogatesInPython3	  s    			:	& N,,_MN			:	& N,,_MN			:	& H,,YGH			:	& N,,_MN NN NN NH HN Ns/   C
C>C*2C6CC'*C36C?N)1rW   rX   rY   rV  r  r\  ro  rq  r  r  r  r  r  r  r  r  r1  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  unittestskipIfsys
maxunicodeUCS2_MAXUNICODEr  r!  r   r
   r   rP  rP    s   %7<r	:G.R:0.#`,28@t.& '<R("
/=-~:9x;  , 8"G8H&I%M:0<2D=
? 77$(&":0= 8??3>>_4oF5 G5*	Nr
   rP  c                       e Zd Zd Zd Zy)ValidTypeNamesTestc                 (   t        t        |            j                  d      d   d|z  d|z  f}| j                  t	        fd|D              d|       j                  d      }|d   }dj                  |d d       }t        ||g	       y )
N'rH   zRepeated%sContainerzRepeated%sFieldContainerc              3   @   K   | ]  }j                  |        y wr   )endswith)ry  rU  tp_names     r   r{  z:ValidTypeNamesTest.assertImportFromName.<locals>.<genexpr>	  s     5AGQ5s   z does end with any of .r   )fromlist)r)   r  splitr   anyjoin
__import__)r+   rO   	base_namevalid_namesparts
class_namemodule_namer-  s          @r   assertImportFromNamez'ValidTypeNamesTest.assertImportFromName	  s    $s)n""3'*G(94-	9;KOO555(/=? MM#ErJ((5":&K{j\2r
   c                     t        j                         }| j                  |j                  d       | j                  |j                  d       y )NScalar	Composite)r   r&   r9  r   r   )r+   r  s     r   testTypeNamesCanBeImportedz-ValidTypeNamesTest.testTypeNamesCanBeImported	  s<    		"	"	$Bb//:b88+Fr
   N)rW   rX   rY   r9  r=  r   r
   r   r(  r(  	  s    3Gr
   r(  c                       e Zd Zd Zd Zd Zy)PackedFieldTestc                    |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       y )NrH   r  T)r   r   repeated_int64repeated_uint32repeated_uint64repeated_sint32repeated_sint64repeated_fixed32repeated_fixed64repeated_sfixed32repeated_sfixed64r   r   r  r  r  s     r   
setMessagezPackedFieldTest.setMessage	  s   !!!$!!!$""1%""1%""1%""1%##A&##A&$$Q'$$Q'!!#&""3'  &  ''*r
   c                     t        j                         }| j                  |       d}| j                  | |j                                y )NsH   
"*2:   B       J   R       Z  ?b      ?jr)r   r@   rJ  r5   r6   r+   r   r9   s      r   testPackedFieldsz PackedFieldTest.testPackedFields	  sA    #335GOOG#K 	[";'";";"=>r
   c                     t        j                         }| j                  |       d}| j                  | |j                                y )Ns:    (0=   A       M   Q       ]  ?a      ?hp)r   TestUnpackedTypesrJ  r5   r6   rL  s      r   testUnpackedFieldsz"PackedFieldTest.testUnpackedFields	  sA    #557GOOGK 	[";'";";"=>r
   N)rW   rX   rY   rJ  rM  rP  r   r
   r   r?  r?  	  s    + ?&?r
   r?  r   z(explicit tests of the C++ implementationc                   $    e Zd Zd Zd Zd Zd Zy)OversizeProtosTestc                     t        j                         }|}t        |      D ]  }|j                  } d|_        |j                         S )Nr   )r   TestRecursiveMessager  r   rz  r6   )r+   r  rO   subr  s        r   GenerateNestedProtoz&OversizeProtosTest.GenerateNestedProto	  sG    

+
+
-C
C1X EEcCE  ""r
   c                 l    t        j                         }|j                  | j                  d             y )Nr1  )r   rT  r3   rV  r  s     r   testSucceedOkSizedProtoz*OversizeProtosTest.testSucceedOkSizedProto	  s)    

+
+
-C0056r
   c                 \   t         j                  j                  d       t        j                         }| j                  t        j                        5 }|j                  | j                  d             d d d        | j                  dt        j                               y # 1 sw Y   /xY w)NFe   r  )r   	_c_moduleSetAllowOversizeProtosr   rT  r$   r   rN   r3   rV  r(   r)   r*   )r+   rO   r.   s      r   testAssertOversizeProtoz*OversizeProtosTest.testAssertOversizeProto	  s      77>

+
+
-C			7..	/ 97	$223789MM)3w/@/@+AB9 9s   !B""B+c                     t         j                  j                  d       t        j                         }|j                  | j                  d             y )NTrZ  )r   r[  r\  r   rT  r3   rV  r  s     r   testSucceedOversizeProtoz+OversizeProtosTest.testSucceedOversizeProto
  s=      77=

+
+
-C0056r
   N)rW   rX   rY   rV  rX  r]  r_  r   r
   r   rR  rR  	  s    
#7C7r
   rR  __main__)+r  
__author__r  r7   r~   r   rj   rH  r$  r"  warningscmpgoogle.protobufr   r   r   r   r   google.protobuf.internalr   r   r   r   r   r   r   r   r   r&  simplefilterDeprecationWarningnamed_parametersTestCaser   r  rP  r(  r?  r#  r!   rR  rW   mainr   r
   r   <module>rk     s  @	 1
       
  $ 3 , ( 5 & 7 , 8 : . = 5 # 3   g1 2 !  )\!:!*,E FHX/(## X/ HX/x$ UL"" UL ULr ON"" ON ONh G** G G. 6?h'' 6? 6?r (#((*h6;=7** 7 =76 z(--/ r
   