ó
X¾÷Xc           @   sõ   d  Z  d Z d d l Z d d l Z d d l Z d d l Z d d l m Z d d l m	 Z	 d d l m
 Z
 d „  Z d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d e j f d „  ƒ  YZ d S(   sp   Utilities for Python proto2 tests.

This is intentionally modeled on C++ code in
//google/protobuf/test_util.*.
s#   robinson@google.com (Will Robinson)iÿÿÿÿN(   t   unittest_import_pb2(   t   unittest_pb2(   t   descriptor_pb2c         C   s   |  j  j d k S(   Nt   proto2(   t
   DESCRIPTORt   syntax(   t   message(    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   IsProto23   s    c         C   sœ  d |  _  d |  _ d |  _ d |  _ d |  _ d |  _ d |  _ d |  _ d	 |  _ d
 |  _	 d |  _
 d |  _ t |  _ d |  _ d |  _ t |  ƒ r¢ d |  j _ n  d |  j _ d |  j _ d |  j _ d |  j _ t j j |  _ t j |  _  t |  ƒ rt! j" |  _# n  d |  _$ d |  _% |  j& j' d ƒ |  j( j' d ƒ |  j) j' d ƒ |  j* j' d ƒ |  j+ j' d ƒ |  j, j' d ƒ |  j- j' d ƒ |  j. j' d ƒ |  j/ j' d ƒ |  j0 j' d ƒ |  j1 j' d  ƒ |  j2 j' d! ƒ |  j3 j' t ƒ |  j4 j' d" ƒ |  j5 j' d# ƒ t |  ƒ r+d$ |  j6 j7 ƒ  _ n  d% |  j8 j7 ƒ  _ d& |  j9 j7 ƒ  _ d' |  j: j7 ƒ  _ d( |  j; j7 ƒ  _ |  j< j' t j j= ƒ |  j> j' t j? ƒ t |  ƒ r¾|  j@ j' t! jA ƒ n  |  jB j' d) ƒ |  jC j' d* ƒ |  j& j' d+ ƒ |  j( j' d, ƒ |  j) j' d- ƒ |  j* j' d. ƒ |  j+ j' d/ ƒ |  j, j' d0 ƒ |  j- j' d1 ƒ |  j. j' d2 ƒ |  j/ j' d3 ƒ |  j0 j' d4 ƒ |  j1 j' d5 ƒ |  j2 j' d6 ƒ |  j3 j' tD ƒ |  j4 j' d7 ƒ |  j5 j' d8 ƒ t |  ƒ rïd9 |  j6 j7 ƒ  _ n  d: |  j8 j7 ƒ  _ d; |  j9 j7 ƒ  _ d< |  j: j7 ƒ  _ d= |  j; j7 ƒ  _ |  j< j' t j j ƒ |  j> j' t j ƒ t |  ƒ r‚|  j@ j' t! j" ƒ n  |  jB j' d> ƒ |  jC j' d? ƒ t |  ƒ rqd@ |  _E dA |  _F dB |  _G dC |  _H dD |  _I dE |  _J dF |  _K dG |  _L dH |  _M dI |  _N dJ |  _O dK |  _P tD |  _Q dL |  _R dM |  _S t j jT |  _U t jV |  _W t! jX |  _Y dN |  _Z dO |  _[ n  dP |  _\ dQ |  j] _ dR |  _^ dS |  __ dT S(U   sm   Sets every non-lazy field in the message to a unique value.

  Args:
    message: A TestAllTypes instance.
  ie   if   ig   ih   ii   ij   ik   il   im   in   io   ip   u   115t   116iu   iv   iw   ix   i~   u   124u   125iÉ   iÊ   iË   iÌ   iÍ   iÎ   iÏ   iÐ   iÑ   iÒ   iÓ   iÔ   u   215t   216iÙ   iÚ   iÛ   iÜ   iã   u   224u   225i-  i.  i/  i0  i1  i2  i3  i4  i5  i6  i7  i8  u   315t   316i=  i>  i?  i@  iG  u   324u   325i‘  i’  i“  i”  i•  i–  i—  i˜  i™  iš  i›  iœ  t   415t   416t   424t   425iY  iZ  t   603t   604N(`   t   optional_int32t   optional_int64t   optional_uint32t   optional_uint64t   optional_sint32t   optional_sint64t   optional_fixed32t   optional_fixed64t   optional_sfixed32t   optional_sfixed64t   optional_floatt   optional_doublet   Truet   optional_boolt   optional_stringt   optional_bytesR   t   optionalgroupt   at   optional_nested_messaget   bbt   optional_foreign_messaget   ct   optional_import_messaget   dt   optional_public_import_messaget   eR   t   TestAllTypest   BAZt   optional_nested_enumt   FOREIGN_BAZt   optional_foreign_enumR    t
   IMPORT_BAZt   optional_import_enumt   optional_string_piecet   optional_cordt   repeated_int32t   appendt   repeated_int64t   repeated_uint32t   repeated_uint64t   repeated_sint32t   repeated_sint64t   repeated_fixed32t   repeated_fixed64t   repeated_sfixed32t   repeated_sfixed64t   repeated_floatt   repeated_doublet   repeated_boolt   repeated_stringt   repeated_bytest   repeatedgroupt   addt   repeated_nested_messaget   repeated_foreign_messaget   repeated_import_messaget   repeated_lazy_messaget   repeated_nested_enumt   BARt   repeated_foreign_enumt   FOREIGN_BARt   repeated_import_enumt
   IMPORT_BARt   repeated_string_piecet   repeated_cordt   Falset   default_int32t   default_int64t   default_uint32t   default_uint64t   default_sint32t   default_sint64t   default_fixed32t   default_fixed64t   default_sfixed32t   default_sfixed64t   default_floatt   default_doublet   default_boolt   default_stringt   default_bytest   FOOt   default_nested_enumt   FOREIGN_FOOt   default_foreign_enumt
   IMPORT_FOOt   default_import_enumt   default_string_piecet   default_cordt   oneof_uint32t   oneof_nested_messaget   oneof_stringt   oneof_bytes(   R   (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   SetAllNonLazyFields6   sÔ    																																			c         C   s   t  |  ƒ d |  j _ d  S(   Ni   (   Rn   t   optional_lazy_messageR$   (   R   (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   SetAllFieldsÅ   s    
c         C   s÷  |  j  } t } t } d | | j <d | | j <d | | j <d | | j <d | | j <d | | j <d | | j	 <d | | j
 <d	 | | j <d
 | | j <d | | j <d | | j <t | | j <d | | j <d | | j <d | | j _ d | | j _ d | | j _ d | | j _ d | | j _ d | | j _ | j j | | j  <| j j | | j  <| j! | | j" <| j# | | j$ <d | | j% <d | | j& <| | j' j( d ƒ | | j) j( d ƒ | | j* j( d ƒ | | j+ j( d ƒ | | j, j( d ƒ | | j- j( d ƒ | | j. j( d ƒ | | j/ j( d ƒ | | j0 j( d ƒ | | j1 j( d  ƒ | | j2 j( d! ƒ | | j3 j( d" ƒ | | j4 j( t ƒ | | j5 j( d# ƒ | | j6 j( d$ ƒ d% | | j7 j8 ƒ  _ d& | | j9 j8 ƒ  _ d' | | j: j8 ƒ  _ d( | | j; j8 ƒ  _ d) | | j< j8 ƒ  _ | | j= j( | j j> ƒ | | j? j( | j@ ƒ | | jA j( | jB ƒ | | jC j( d* ƒ | | jD j( d+ ƒ | | j' j( d, ƒ | | j) j( d- ƒ | | j* j( d. ƒ | | j+ j( d/ ƒ | | j, j( d0 ƒ | | j- j( d1 ƒ | | j. j( d2 ƒ | | j/ j( d3 ƒ | | j0 j( d4 ƒ | | j1 j( d5 ƒ | | j2 j( d6 ƒ | | j3 j( d7 ƒ | | j4 j( tE ƒ | | j5 j( d8 ƒ | | j6 j( d9 ƒ d: | | j7 j8 ƒ  _ d; | | j9 j8 ƒ  _ d< | | j: j8 ƒ  _ d= | | j; j8 ƒ  _ d> | | j< j8 ƒ  _ | | j= j( | j j ƒ | | j? j( | j! ƒ | | jA j( | j# ƒ | | jC j( d? ƒ | | jD j( d@ ƒ dA | | jF <dB | | jG <dC | | jH <dD | | jI <dE | | jJ <dF | | jK <dG | | jL <dH | | jM <dI | | jN <dJ | | jO <dK | | jP <dL | | jQ <tE | | jR <dM | | jS <dN | | jT <| j jU | | jV <| jW | | jX <| jY | | jZ <dO | | j[ <dP | | j\ <dQ | | j] <dR | | j^ _ dS | | j_ <dT | | j` <dU S(V   sz   Sets every extension in the message to a unique value.

  Args:
    message: A unittest_pb2.TestAllExtensions instance.
  ie   if   ig   ih   ii   ij   ik   il   im   in   io   ip   u   115R   iu   iv   iw   ix   i~   i   u   124u   125iÉ   iÊ   iË   iÌ   iÍ   iÎ   iÏ   iÐ   iÑ   iÒ   iÓ   iÔ   u   215R	   iÙ   iÚ   iÛ   iÜ   iã   u   224u   225i-  i.  i/  i0  i1  i2  i3  i4  i5  i6  i7  i8  u   315R
   i=  i>  i?  i@  iG  u   324u   325i‘  i’  i“  i”  i•  i–  i—  i˜  i™  iš  i›  iœ  u   415R   u   424R   iY  iZ  u   603R   N(a   t
   ExtensionsR   R    t   optional_int32_extensiont   optional_int64_extensiont   optional_uint32_extensiont   optional_uint64_extensiont   optional_sint32_extensiont   optional_sint64_extensiont   optional_fixed32_extensiont   optional_fixed64_extensiont   optional_sfixed32_extensiont   optional_sfixed64_extensiont   optional_float_extensiont   optional_double_extensionR   t   optional_bool_extensiont   optional_string_extensiont   optional_bytes_extensiont   optionalgroup_extensionR"   t!   optional_nested_message_extensionR$   t"   optional_foreign_message_extensionR&   t!   optional_import_message_extensionR(   t(   optional_public_import_message_extensionR*   t   optional_lazy_message_extensionR+   R,   t   optional_nested_enum_extensionR.   t   optional_foreign_enum_extensionR0   t   optional_import_enum_extensiont   optional_string_piece_extensiont   optional_cord_extensiont   repeated_int32_extensionR5   t   repeated_int64_extensiont   repeated_uint32_extensiont   repeated_uint64_extensiont   repeated_sint32_extensiont   repeated_sint64_extensiont   repeated_fixed32_extensiont   repeated_fixed64_extensiont   repeated_sfixed32_extensiont   repeated_sfixed64_extensiont   repeated_float_extensiont   repeated_double_extensiont   repeated_bool_extensiont   repeated_string_extensiont   repeated_bytes_extensiont   repeatedgroup_extensionRE   t!   repeated_nested_message_extensiont"   repeated_foreign_message_extensiont!   repeated_import_message_extensiont   repeated_lazy_message_extensiont   repeated_nested_enum_extensionRK   t   repeated_foreign_enum_extensionRM   t   repeated_import_enum_extensionRO   t   repeated_string_piece_extensiont   repeated_cord_extensionRR   t   default_int32_extensiont   default_int64_extensiont   default_uint32_extensiont   default_uint64_extensiont   default_sint32_extensiont   default_sint64_extensiont   default_fixed32_extensiont   default_fixed64_extensiont   default_sfixed32_extensiont   default_sfixed64_extensiont   default_float_extensiont   default_double_extensiont   default_bool_extensiont   default_string_extensiont   default_bytes_extensionRb   t   default_nested_enum_extensionRd   t   default_foreign_enum_extensionRf   t   default_import_enum_extensiont   default_string_piece_extensiont   default_cord_extensiont   oneof_uint32_extensiont   oneof_nested_message_extensiont   oneof_string_extensiont   oneof_bytes_extension(   R   t
   extensionst   pb2t
   import_pb2(    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   SetAllExtensionsÊ   sÐ    	c         C   s?   d |  _  d |  _ d |  _ d |  j t j <d |  j t j <d S(   sƒ   Sets every field and extension in the message to a unique value.

  Args:
    message: A unittest_pb2.TestAllExtensions message.
  i   t   foog      ð?i   t   barN(   t   my_intt	   my_stringt   my_floatRq   R   t   my_extension_intt   my_extension_string(   R   (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   SetAllFieldsAndExtensionsX  s
    			c         C   s"  t  j } t  j } g  } t  j ƒ  } d | _ | j | j ƒ  ƒ | j ƒ  d | j | <| j | j ƒ  ƒ | j ƒ  d | _	 | j | j ƒ  ƒ | j ƒ  d | j | <| j | j ƒ  ƒ | j ƒ  d | _
 | j | j ƒ  ƒ | j ƒ  d j | ƒ } | |  k rt d | |  f ƒ ‚ n  d S(	   sÇ   Ensures that serialized is the serialization we expect for a message
  filled with SetAllFieldsAndExtensions().  (Specifically, ensures that the
  serialization is in canonical, tag-number order).
  i   i   RÁ   RÂ   g      ð?t    s   Expected %r, found %rN(   R   RÆ   RÇ   t   TestFieldOrderingsRÃ   R5   t   SerializeToStringt   ClearRq   RÄ   RÅ   t   joint
   ValueError(   t
   serializedRÆ   RÇ   t   expected_stringsR   t   expected(    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt#   ExpectAllFieldsAndExtensionsInOrdere  s,    			

	

	
c         C   s¡  |  j  | j d ƒ ƒ |  j  | j d ƒ ƒ |  j  | j d ƒ ƒ |  j  | j d ƒ ƒ |  j  | j d ƒ ƒ |  j  | j d ƒ ƒ |  j  | j d ƒ ƒ |  j  | j d ƒ ƒ |  j  | j d	 ƒ ƒ |  j  | j d
 ƒ ƒ |  j  | j d ƒ ƒ |  j  | j d ƒ ƒ |  j  | j d ƒ ƒ |  j  | j d ƒ ƒ |  j  | j d ƒ ƒ t | ƒ ro|  j  | j d ƒ ƒ n  |  j  | j d ƒ ƒ |  j  | j d ƒ ƒ |  j  | j d ƒ ƒ |  j  | j j d ƒ ƒ |  j  | j j d ƒ ƒ |  j  | j j d ƒ ƒ |  j  | j j d ƒ ƒ |  j  | j d ƒ ƒ |  j  | j d ƒ ƒ t | ƒ rf|  j  | j d ƒ ƒ n  |  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& | j ƒ |  j d' | j ƒ |  j d( | j ƒ |  j t | j ƒ |  j d) | j ƒ |  j d* | j ƒ t | ƒ rÔ|  j d+ | j j ƒ n  |  j d, | j j ƒ |  j d- | j j ƒ |  j d. | j j ƒ |  j d/ | j j ƒ |  j d0 | j j ƒ |  j t j  j! | j" ƒ |  j t j# | j$ ƒ t | ƒ r–|  j t% j& | j' ƒ n  |  j d1 t( | j) ƒ ƒ |  j d1 t( | j* ƒ ƒ |  j d1 t( | j+ ƒ ƒ |  j d1 t( | j, ƒ ƒ |  j d1 t( | j- ƒ ƒ |  j d1 t( | j. ƒ ƒ |  j d1 t( | j/ ƒ ƒ |  j d1 t( | j0 ƒ ƒ |  j d1 t( | j1 ƒ ƒ |  j d1 t( | j2 ƒ ƒ |  j d1 t( | j3 ƒ ƒ |  j d1 t( | j4 ƒ ƒ |  j d1 t( | j5 ƒ ƒ |  j d1 t( | j6 ƒ ƒ |  j d1 t( | j7 ƒ ƒ t | ƒ r5|  j d1 t( | j8 ƒ ƒ n  |  j d1 t( | j9 ƒ ƒ |  j d1 t( | j: ƒ ƒ |  j d1 t( | j; ƒ ƒ |  j d1 t( | j< ƒ ƒ |  j d1 t( | j= ƒ ƒ t | ƒ rÚ|  j d1 t( | j> ƒ ƒ n  |  j d1 t( | j? ƒ ƒ |  j d1 t( | j@ ƒ ƒ |  j d2 | j) d3 ƒ |  j d4 | j* d3 ƒ |  j d5 | j+ d3 ƒ |  j d6 | j, d3 ƒ |  j d7 | j- d3 ƒ |  j d8 | j. d3 ƒ |  j d9 | j/ d3 ƒ |  j d: | j0 d3 ƒ |  j d; | j1 d3 ƒ |  j d< | j2 d3 ƒ |  j d= | j3 d3 ƒ |  j d> | j4 d3 ƒ |  j t | j5 d3 ƒ |  j d? | j6 d3 ƒ |  j d@ | j7 d3 ƒ t | ƒ rŽ|  j dA | j8 d3 j ƒ n  |  j dB | j9 d3 j ƒ |  j dC | j: d3 j ƒ |  j dD | j; d3 j ƒ |  j dE | jA d3 j ƒ |  j t j  jB | j< d3 ƒ |  j t jC | j= d3 ƒ t | ƒ rV	|  j t% jD | j> d3 ƒ n  |  j dF | j) dG ƒ |  j dH | j* dG ƒ |  j dI | j+ dG ƒ |  j dJ | j, dG ƒ |  j dK | j- dG ƒ |  j dL | j. dG ƒ |  j dM | j/ dG ƒ |  j dN | j0 dG ƒ |  j dO | j1 dG ƒ |  j dP | j2 dG ƒ |  j dQ | j3 dG ƒ |  j dR | j4 dG ƒ |  j tE | j5 dG ƒ |  j dS | j6 dG ƒ |  j dT | j7 dG ƒ t | ƒ rØ
|  j dU | j8 dG j ƒ n  |  j dV | j9 dG j ƒ |  j dW | j: dG j ƒ |  j dX | j; dG j ƒ |  j dY | jA dG j ƒ |  j t j  j! | j< dG ƒ |  j t j# | j= dG ƒ t | ƒ r |  j t% j& | j> dG ƒ n  t | ƒ r|  j  | j dZ ƒ ƒ |  j  | j d[ ƒ ƒ |  j  | j d\ ƒ ƒ |  j  | j d] ƒ ƒ |  j  | j d^ ƒ ƒ |  j  | j d_ ƒ ƒ |  j  | j d` ƒ ƒ |  j  | j da ƒ ƒ |  j  | j db ƒ ƒ |  j  | j dc ƒ ƒ |  j  | j dd ƒ ƒ |  j  | j de ƒ ƒ |  j  | j df ƒ ƒ |  j  | j dg ƒ ƒ |  j  | j dh ƒ ƒ |  j  | j di ƒ ƒ |  j  | j dj ƒ ƒ |  j  | j dk ƒ ƒ |  j dl | jF ƒ |  j dm | jG ƒ |  j dn | jH ƒ |  j do | jI ƒ |  j dp | jJ ƒ |  j dq | jK ƒ |  j dr | jL ƒ |  j ds | jM ƒ |  j dt | jN ƒ |  j du | jO ƒ |  j dv | jP ƒ |  j dw | jQ ƒ |  j tE | jR ƒ |  j dx | jS ƒ |  j dy | jT ƒ |  j t j  jU | jV ƒ |  j t jW | jX ƒ |  j t% jY | jZ ƒ n  dz S({   sF   Check all fields for correct values have after Set*Fields() is called.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   R2   R3   ie   if   ig   ih   ii   ij   ik   il   im   in   io   ip   t   115R   iu   iv   iw   ix   i~   i   i   iÉ   i    iÊ   iË   iÌ   iÍ   iÎ   iÏ   iÐ   iÑ   iÒ   iÓ   iÔ   t   215R	   iÙ   iÚ   iÛ   iÜ   iã   i-  i   i.  i/  i0  i1  i2  i3  i4  i5  i6  i7  i8  t   315R
   i=  i>  i?  i@  iG  RS   RT   RU   RV   RW   RX   RY   RZ   R[   R\   R]   R^   R_   R`   Ra   Rc   Re   Rg   i‘  i’  i“  i”  i•  i–  i—  i˜  i™  iš  i›  iœ  R   R   N([   t
   assertTruet   HasFieldR   R!   R#   R%   R'   t   assertEqualR   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R    R"   R$   R&   R(   R)   R*   Ro   R   R+   R,   R-   R.   R/   R    R0   R1   t   lenR4   R6   R7   R8   R9   R:   R;   R<   R=   R>   R?   R@   RA   RB   RC   RD   RF   RG   RH   RJ   RL   RN   RP   RQ   RI   RK   RM   RO   RR   RS   RT   RU   RV   RW   RX   RY   RZ   R[   R\   R]   R^   R_   R`   Ra   Rb   Rc   Rd   Re   Rf   Rg   (   t	   test_caseR   (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   ExpectAllFieldsSetƒ  sj   



c         C   sÇ   d } xq t  j j | ƒ ry t  j j t  j j | d ƒ ƒ ra t  j j | d |  ƒ } t | d ƒ St  j j | d ƒ } q	 Wd } t  j j | d |  ƒ } t  j j | ƒ r· t | d ƒ St d ƒ ‚ d S(	   sF   Finds the given golden file and returns a file object representing it.t   .s   src/google/protobufs   src/google/protobuf/testdatat   rbs   ..s'   third_party/py/google/protobuf/testdatas™   Could not find golden files.  This test must be run from within the protobuf source package so that it can read test data files from the C++ source tree.N(   t   ost   patht   existsRÍ   t   opent   RuntimeError(   t   filenameRß   t	   full_path(    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt
   GoldenFileT  s    !	c         C   s#   t  |  ƒ  } | j ƒ  SWd QXd S(   s5   Finds the given golden file and returns its contents.N(   Rå   t   read(   Rã   t   f(    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   GoldenFileDatan  s    c         C   s>  |  j  j d d g ƒ |  j j d d g ƒ |  j j d d g ƒ |  j j d d g ƒ |  j j d	 d
 g ƒ |  j j d d g ƒ |  j j d d g ƒ |  j j d d g ƒ |  j	 j d d g ƒ |  j
 j d d g ƒ |  j j d d g ƒ |  j j d d g ƒ |  j j t t g ƒ |  j j t j t j g ƒ d S(   sg   Sets every field in the message to a unique value.

  Args:
    message: A TestPackedTypes instance.
  iY  i½  iZ  i¾  i[  i¿  i\  iÀ  i]  iÁ  i^  iÂ  i_  iÃ  i`  iÄ  ia  iÅ  ib  iÆ  g     ƒ@g     8†@g      ƒ@g     @†@N(   t   packed_int32t   extendt   packed_int64t   packed_uint32t   packed_uint64t   packed_sint32t   packed_sint64t   packed_fixed32t   packed_fixed64t   packed_sfixed32t   packed_sfixed64t   packed_floatt   packed_doublet   packed_boolR   RR   t   packed_enumR   RM   R.   (   R   (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   SetAllPackedFieldst  s    c         C   s…  |  j  } t } | | j j d d g ƒ | | j j d d g ƒ | | j j d d g ƒ | | j j d d g ƒ | | j j d	 d
 g ƒ | | j j d d g ƒ | | j	 j d d g ƒ | | j
 j d d g ƒ | | j j d d g ƒ | | j j d d g ƒ | | j j d d g ƒ | | j j d d g ƒ | | j j t t g ƒ | | j j t j t j g ƒ d S(   s}   Sets every extension in the message to a unique value.

  Args:
    message: A unittest_pb2.TestPackedExtensions instance.
  iY  i½  iZ  i¾  i[  i¿  i\  iÀ  i]  iÁ  i^  iÂ  i_  iÃ  i`  iÄ  ia  iÅ  ib  iÆ  g     ƒ@g     8†@g      ƒ@g     @†@N(   Rq   R   t   packed_int32_extensionRê   t   packed_int64_extensiont   packed_uint32_extensiont   packed_uint64_extensiont   packed_sint32_extensiont   packed_sint64_extensiont   packed_fixed32_extensiont   packed_fixed64_extensiont   packed_sfixed32_extensiont   packed_sfixed64_extensiont   packed_float_extensiont   packed_double_extensiont   packed_bool_extensionR   RR   t   packed_enum_extensionRM   R.   (   R   R½   R¾   (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   SetAllPackedExtensions‹  s"    	c         C   s>  |  j  j d d g ƒ |  j j d d g ƒ |  j j d d g ƒ |  j j d d g ƒ |  j j d	 d
 g ƒ |  j j d d g ƒ |  j j d d g ƒ |  j j d d g ƒ |  j	 j d d g ƒ |  j
 j d d g ƒ |  j j d d g ƒ |  j j d d g ƒ |  j j t t g ƒ |  j j t j t j g ƒ d S(   sv   Sets every field in the message to a unique value.

  Args:
    message: A unittest_pb2.TestUnpackedTypes instance.
  iY  i½  iZ  i¾  i[  i¿  i\  iÀ  i]  iÁ  i^  iÂ  i_  iÃ  i`  iÄ  ia  iÅ  ib  iÆ  g     ƒ@g     8†@g      ƒ@g     @†@N(   t   unpacked_int32Rê   t   unpacked_int64t   unpacked_uint32t   unpacked_uint64t   unpacked_sint32t   unpacked_sint64t   unpacked_fixed32t   unpacked_fixed64t   unpacked_sfixed32t   unpacked_sfixed64t   unpacked_floatt   unpacked_doublet   unpacked_boolR   RR   t   unpacked_enumR   RM   R.   (   R   (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   SetAllUnpackedFields¥  s    t   NonStandardIntegerc           B   s‚  e  Z d  Z d* d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z 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, RS(+   sÝ  An integer object that does not subclass int.

  This is used to verify that both C++ and regular proto systems can handle
  integer others than int and long and that they handle them in predictable
  ways.

  NonStandardInteger is the minimal legal specification for a custom Integral.
  As such, it does not support 0 < x < 5 and it is not hashable.

  Note: This is added here instead of relying on numpy or a similar library with
  custom integers to limit dependencies.
  c         C   sI   t  | t j ƒ s t ‚ t  | t ƒ r3 | j } n  | |  _ | |  _ d  S(   N(   t
   isinstancet   numberst   Integralt   AssertionErrorR  t   valt   error_string_on_conversion(   t   selfR  R  (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   __init__Ê  s
    	c         C   s(   |  j  r t |  j  ƒ ‚ n  t |  j ƒ S(   N(   R  Râ   t   longR  (   R  (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   __long__Ñ  s    	c         C   s   t  t j |  j ƒ ƒ S(   N(   R  t   operatort   absR  (   R  (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   __abs__Ö  s    c         C   s   t  t j |  j | ƒ ƒ S(   N(   R  R"  RE   R  (   R  t   y(    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   __add__Ù  s    c         C   s   t  t j |  j | ƒ ƒ S(   N(   R  R"  t   divR  (   R  R%  (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   __div__Ü  s    c         C   s   t  j |  j | ƒ S(   N(   R"  t   eqR  (   R  R%  (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   __eq__ß  s    c         C   s   t  t j |  j | ƒ ƒ S(   N(   R  R"  t   floordivR  (   R  R%  (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   __floordiv__â  s    c         C   s   t  t j |  j | ƒ ƒ S(   N(   R  R"  t   truedivR  (   R  R%  (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   __truediv__å  s    c         C   s   t  t j |  j ƒ ƒ S(   N(   R  R"  t   invertR  (   R  (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt
   __invert__è  s    c         C   s   t  t j |  j | ƒ ƒ S(   N(   R  R"  t   modR  (   R  R%  (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   __mod__ë  s    c         C   s   t  t j |  j | ƒ ƒ S(   N(   R  R"  t   mulR  (   R  R%  (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   __mul__î  s    c         C   s   t  t j |  j ƒ ƒ S(   N(   R  R"  t   negR  (   R  (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   __neg__ñ  s    c         C   s   t  t j |  j ƒ ƒ S(   N(   R  R"  t   posR  (   R  (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   __pos__ô  s    c         C   s   t  t j |  j | ƒ ƒ S(   N(   R  R"  t   powR  (   R  R%  (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   __pow__÷  s    c         C   s   t  |  j ƒ S(   N(   t   intR  (   R  (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt	   __trunc__ú  s    c         C   s   t  t j | |  j ƒ ƒ S(   N(   R  R"  RE   R  (   R  R%  (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   __radd__ý  s    c         C   s   t  t j | |  j ƒ ƒ S(   N(   R  R"  R'  R  (   R  R%  (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   __rdiv__   s    c         C   s   t  t j | |  j ƒ ƒ S(   N(   R  R"  R1  R  (   R  R%  (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   __rmod__  s    c         C   s   t  t j | |  j ƒ ƒ S(   N(   R  R"  R3  R  (   R  R%  (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   __rmul__  s    c         C   s   t  t j | |  j ƒ ƒ S(   N(   R  R"  R9  R  (   R  R%  (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   __rpow__	  s    c         C   s   t  t j | |  j ƒ ƒ S(   N(   R  R"  R+  R  (   R  R%  (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   __rfloordiv__  s    c         C   s   t  t j | |  j ƒ ƒ S(   N(   R  R"  R-  R  (   R  R%  (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   __rtruediv__  s    c         C   s   t  t j |  j | ƒ ƒ S(   N(   R  R"  t   lshiftR  (   R  R%  (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt
   __lshift__  s    c         C   s   t  t j |  j | ƒ ƒ S(   N(   R  R"  t   rshiftR  (   R  R%  (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt
   __rshift__  s    c         C   s   t  t j | |  j ƒ ƒ S(   N(   R  R"  RD  R  (   R  R%  (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   __rlshift__  s    c         C   s   t  t j | |  j ƒ ƒ S(   N(   R  R"  RF  R  (   R  R%  (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   __rrshift__  s    c         C   s.   t  | t ƒ r | j } n  t j |  j | ƒ S(   N(   R  R  R  R"  t   le(   R  R%  (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   __le__  s    c         C   s.   t  | t ƒ r | j } n  t j |  j | ƒ S(   N(   R  R  R  R"  t   lt(   R  R%  (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   __lt__#  s    c         C   s   t  t j |  j | ƒ ƒ S(   N(   R  R"  t   and_R  (   R  R%  (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   __and__(  s    c         C   s   t  t j |  j | ƒ ƒ S(   N(   R  R"  t   or_R  (   R  R%  (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   __or__+  s    c         C   s   t  t j |  j | ƒ ƒ S(   N(   R  R"  t   xorR  (   R  R%  (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   __xor__.  s    c         C   s   t  t j | |  j ƒ ƒ S(   N(   R  R"  RN  R  (   R  R%  (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   __rand__1  s    c         C   s   t  t j | |  j ƒ ƒ S(   N(   R  R"  RP  R  (   R  R%  (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   __ror__4  s    c         C   s   t  t j | |  j ƒ ƒ S(   N(   R  R"  RR  R  (   R  R%  (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   __rxor__7  s    c         C   s   |  j  S(   N(   R  (   R  (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   __bool__:  s    c         C   s   |  j  S(   N(   R  (   R  (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   __nonzero__=  s    c         C   s   |  S(   N(    (   R  (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   __ceil__@  s    c         C   s   |  S(   N(    (   R  (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt	   __floor__C  s    c         C   s(   |  j  r t |  j  ƒ ‚ n  t |  j ƒ S(   N(   R  Râ   R;  R  (   R  (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   __int__F  s    	c         C   s   |  S(   N(    (   R  (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt	   __round__K  s    c         C   s   d |  j  S(   Ns   NonStandardInteger(%s)(   R  (   R  (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   __repr__N  s    N(-   t   __name__t
   __module__t   __doc__t   NoneR  R!  R$  R&  R(  R*  R,  R.  R0  R2  R4  R6  R8  R:  R<  R=  R>  R?  R@  RA  RB  RC  RE  RG  RH  RI  RK  RM  RO  RQ  RS  RT  RU  RV  RW  RX  RY  RZ  R[  R\  R]  (    (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyR  ¼  sT   																																							(   R`  t
   __author__R  R"  t   os.pathRÞ   t   syst   google.protobufR    R   R   R   Rn   Rp   RÀ   RÈ   RÒ   RÛ   Rå   Rè   Rø   R  R  R  R  (    (    (    sD   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/test_util.pyt   <module>#   s*   				Ž			Ñ					