
XXc           @   s  d  Z  d Z d d l Z d d l Z y d d l Z Wn e k
 rS d d l Z n Xd d l m Z d d l m	 Z	 d d l m
 Z
 d d l m Z d d l m Z d d	 l m Z d d
 l m Z d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z d e j f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ  d  e f d!     YZ! d" e f d#     YZ" d$ e j f d%     YZ# e j$ e j%   d& k d'  d( e j f d)     Y Z& e d* d+ i e i e d, d- f d. d/ f g  d0 6e i e d1 d2 f d3 d4 f g  d0 6e i e d5 d6 f d7 d8 f g  d0 6d9 e d- d0 d5  f d: e! d/ d;  f g  d< 6d9 e d- d0 d3  f d: e! d/ d=  f d> e  d? d<  f g  d@ 6d9 e d- d0 d.  f dA e  d/ d@  f g dB e' dC 6e i e dD d? f dE dF f g  d0 6e i e dG dH f dI dJ f g  d0 6e i e dK dL f dM dN f g  d0 6d9 e d- d0 dM  f d: e! d/ dO  f g  d< 6d9 e d- d0 dG  f d: e! d/ dP  f d> e  d? d<  f g  d@ 6d9 e d- d0 dD  f dA e  d/ d@  f g  dQ 6 Z( e dR d+ i e i e dS dT f dU dV f g  d0 6e i e dW dX f dY dZ f g  d0 6e i e d[ d\ f d] d^ f g  d0 6d9 e d- d0 d[  f d: e! d/ d_  f g  d< 6d9 e d- d0 dY  f d: e! d/ d`  f d> e  d? d<  f g  d@ 6d9 e d- d0 dU  f dA e  d/ d@  f g da db e" dc dC  f g dd 6de d* df g dg df g Z) e* dh k re j+   n  d S(i   s*   Tests for google.protobuf.descriptor_pool.s"   matthewtoia@google.com (Matt Toia)iN(   t   unittest_import_pb2(   t   unittest_import_public_pb2(   t   unittest_pb2(   t   descriptor_pb2(   t   api_implementation(   t   descriptor_pool_test1_pb2(   t   descriptor_pool_test2_pb2(   t   factory_test1_pb2(   t   factory_test2_pb2(   t   file_options_test_pb2(   t   more_messages_pb2(   t
   descriptor(   t   descriptor_database(   t   descriptor_pool(   t   message_factory(   t   symbol_databaset   DescriptorPoolTestc           B   s   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 RS(   c         C   so   t  j   |  _ t j j t j j  |  _	 t j j t
 j j  |  _ |  j j |  j	  |  j j |  j  d  S(   N(   R   t   DescriptorPoolt   poolR   t   FileDescriptorProtot
   FromStringR   t
   DESCRIPTORt   serialized_pbt   factory_test1_fdR   t   factory_test2_fdt   Add(   t   self(    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyt   setUpA   s    		c         C   s   d } |  j  j |  } |  j | t j  |  j | | j  |  j d | j  |  j d | j	  d } |  j  j |  } |  j | t j  |  j | | j  |  j d | j  |  j d | j	  d  S(   Ns,   google/protobuf/internal/factory_test1.protos   google.protobuf.python.internalt   Factory1Messages,   google/protobuf/internal/factory_test2.protot   Factory2Message(
   R   t   FindFileByNamet   assertIsInstanceR   t   FileDescriptort   assertEqualt   namet   packaget   assertInt   message_types_by_name(   R   t   name1t
   file_desc1t   name2t
   file_desc2(    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyt   testFindFileByNameJ   s    c         C   s*   |  j  t   |  j j d  Wd  QXd  S(   Ns   Does not exist(   t   assertRaisest   KeyErrorR   R   (   R   (    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyt   testFindFileByNameFailureY   s    c         C   s   |  j  j d  } |  j | t j  |  j d | j  |  j d | j  |  j d | j	  |  j  j d  } |  j | t j  |  j d | j  |  j d | j  |  j d | j	  d  S(   Ns/   google.protobuf.python.internal.Factory1Messages,   google/protobuf/internal/factory_test1.protos   google.protobuf.python.internalR   s/   google.protobuf.python.internal.Factory2Messages,   google/protobuf/internal/factory_test2.protoR   (
   R   t   FindFileContainingSymbolR   R   R    R!   R"   R#   R$   R%   (   R   R'   R)   (    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyt   testFindFileContainingSymbol]   s    			
			
c         C   s*   |  j  t   |  j j d  Wd  QXd  S(   Ns   Does not exist(   R+   R,   R   R.   (   R   (    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyt#   testFindFileContainingSymbolFailuren   s    c   	      C   s  |  j  j d  } |  j | t j  |  j d | j  |  j d | j  |  j d  | j	  |  j
 | j  | j d } |  j d | j  |  j | | j	  | j d } |  j d | j  |  j | | j	  |  j | | j d j  |  j | | j d j  |  j  j d  } |  j | t j  |  j d	 | j  |  j d | j  |  j | j	  | j d } |  j d
 | j  |  j | | j	  | j d } |  j d | j  |  j | | j	  |  j | | j d j  |  j | | j d j  |  j | j d j  |  j d | j d j  |  j | j d j  |  j d | j d j  |  j | j d j  |  j d | j d j  |  j | j d j  |  j
 | j d j  |  j | j d j  |  j d | j d j  |  j  j d  } |  j | |  |  j | j d j  |  j d | j d j  |  j d t | j   |  j d t | j   |  j d t | j d j   xV d d g D]H } |  j | j d | j | j  |  j | j | | j d j  qWd  S(   Ns/   google.protobuf.python.internal.Factory1MessageR   i    t   NestedFactory1Messaget   NestedFactory1Enumt   nested_factory_1_messaget   nested_factory_1_enums/   google.protobuf.python.internal.Factory2MessageR   t   NestedFactory2Messaget   NestedFactory2Enumt   nested_factory_2_messaget   nested_factory_2_enumt   int_with_defaulti  t   double_with_defaultg{G#@t   string_with_defaults   hello worldt   bool_with_defaultt   enum_with_defaulti   sE   google.protobuf.python.internal.Factory2Message.NestedFactory2Messaget   bytes_with_defaults   a ci   t	   oneof_intt   oneof_string(   R   t   FindMessageTypeByNameR   R   t
   DescriptorR!   R"   t	   full_namet   Nonet   containing_typet   assertFalset   has_optionst   nested_typest
   enum_typest   fields_by_namet   message_typet	   enum_typet   assertIsNonet
   assertTruet   has_default_valuet   default_valuet   lent   oneofst   oneofs_by_namet   fieldst   containing_oneofR$   (	   R   t   msg1t   nested_msg1t   nested_enum1t   msg2t   nested_msg2t   nested_enum2t   msg3R"   (    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyt   testFindMessageTypeByNamer   s    			
			
		 c         C   s*   |  j  t   |  j j d  Wd  QXd  S(   Ns   Does not exist(   R+   R,   R   RA   (   R   (    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyt    testFindMessageTypeByNameFailure   s    c         C   sx  |  j  j d  } |  j | t j  |  j d | j d j  |  j d | j d j  |  j | j	  |  j  j d  } |  j | t j  |  j d | j d j  |  j d | j d j  |  j  j d	  } |  j | t j  |  j d | j d
 j  |  j d | j d j  |  j  j d  } |  j | t j  |  j d | j d j  |  j d | j d j  d  S(   Ns,   google.protobuf.python.internal.Factory1Enumi    t   FACTORY_1_VALUE_0i   t   FACTORY_1_VALUE_1sB   google.protobuf.python.internal.Factory1Message.NestedFactory1Enumt   NESTED_FACTORY_1_VALUE_0t   NESTED_FACTORY_1_VALUE_1s,   google.protobuf.python.internal.Factory2Enumt   FACTORY_2_VALUE_0t   FACTORY_2_VALUE_1sB   google.protobuf.python.internal.Factory2Message.NestedFactory2Enumt   NESTED_FACTORY_2_VALUE_0t   NESTED_FACTORY_2_VALUE_1(
   R   t   FindEnumTypeByNameR   R   t   EnumDescriptorR!   t   values_by_namet   numberRF   RG   (   R   t   enum1RX   t   enum2R[   (    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyt   testFindEnumTypeByName   s2    								c         C   s*   |  j  t   |  j j d  Wd  QXd  S(   Ns   Does not exist(   R+   R,   R   Rg   (   R   (    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyt   testFindEnumTypeByNameFailure   s    c         C   su   |  j  j d  } |  j | j d  |  j | j | j  |  j | j  |  j t	   |  j  j d  Wd  QXd  S(   Ns:   google.protobuf.python.internal.Factory1Message.list_valuet
   list_values   Does not exist(
   R   t   FindFieldByNameR!   R"   t   labelt   LABEL_REPEATEDRF   RG   R+   R,   (   R   t   field(    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyt   testFindFieldByName   s    		c         C   s   |  j  j d  } |  j | j d  |  j  j d  } |  j | j d  |  j | j d  |  j t   |  j  j d  Wd  QXd  S(   Ns>   google.protobuf.python.internal.Factory2Message.one_more_fieldt   one_more_fields-   google.protobuf.python.internal.another_fieldt   another_fieldi  s   Does not exist(   R   t   FindExtensionByNameR!   R"   Rj   R+   R,   Rp   (   R   t	   extension(    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyt   testFindExtensionByName   s    				c         C   s   |  j  j d  } |  j  j d  } | j d } |  j  j |  |  j  j d  } | j d } |  j  j |  |  j  j |  } t | | g  } |  j | t |   | j d  |  j  j |  } |  j | t |   d  S(   Ns/   google.protobuf.python.internal.Factory1Messages/   google.protobuf.python.internal.Factory2MessageRu   s,   google/protobuf/internal/factory_test2.protoRv   t   unexpected_element(	   R   RA   t   extensions_by_namet   AddExtensionDescriptorR   t   FindAllExtensionst   setR!   t   append(   R   t   factory1_messaget   factory2_messageRu   t   factory_test2Rv   t
   extensionst   expected_extension_numbers(    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyt   testFindAllExtensions  s     						c         C   s   |  j  j d  } |  j  j d  } | j d } |  j  j |  |  j  j d  } | j d } |  j  j |  |  j  j | d  } |  j | j d  |  j  j | d  } |  j | j d  |  j t	   |  j  j | d  } Wd  QXd  S(	   Ns/   google.protobuf.python.internal.Factory1Messages/   google.protobuf.python.internal.Factory2MessageRu   s,   google/protobuf/internal/factory_test2.protoRv   i  i  i (
   R   RA   R{   R|   R   t   FindExtensionByNumberR!   R"   R+   R,   (   R   R   R   Ru   R   Rv   Rx   (    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyt   testFindExtensionByNumber  s     						c         C   sv   |  j  t   |  j j d  Wd  QX|  j  t   |  j j d  Wd  QX|  j  t   |  j j d  Wd  QXd  S(   Ns-   google.protobuf.python.internal.another_fields>   google.protobuf.python.internal.Factory2Message.one_more_fields:   google.protobuf.python.internal.Factory1Message.list_value(   R+   R,   R   Rp   Rw   (   R   (    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyt   testExtensionsAreNotFields0  s    		c         C   sL   t  j   } t j |  |  _ | j |  j  | j |  j  |  j   d  S(   N(	   R   t   DescriptorDatabaseR   R   R   R   R   R   R]   (   R   t   db(    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyt   testUserDefinedDB:  s
    c         C   sO   t  j   |  _ |  j j |  j j    |  j j |  j j    |  j   d  S(   N(   R   R   R   t   AddSerializedFileR   t   SerializeToStringR   R]   (   R   (    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyt   testAddSerializedFileA  s    c         C   s   t  j j t j j  } t  j j t j j  } t  j j t j j  } |  j j	 |  |  j j	 |  |  j j	 |  t
 j |  |  j  t j |  |  j  d  S(   N(   R   R   R   R
   R   R   R   R   R   R   t
   TEST1_FILEt	   CheckFilet
   TEST2_FILE(   R   t   more_messages_desct
   test1_desct
   test2_desc(    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyt   testComplexNestingG  s    			c            s     f d   } | t  j  t j   j j d  }   j | t  j  | |  t j j	 t  j j
  }   j j |    j j d  } | |  d S(   s:   Test the default value of enums which don't start at zero.c            s1   |  j  d j d j }   j | t j j  d  S(   Nt   DescriptorPoolTest1t   nested_enum(   R%   RJ   RP   R!   R   R   t   BETA(   t   file_descriptorRP   (   R   (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyt   _CheckDefaultValueW  s
    
	s4   google/protobuf/internal/descriptor_pool_test1.protoN(   R   R   R   t   DefaultR   R   t   assertIsR   R   R   R   R   (   R   R   R   t   descriptor_proto(    (   R   sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyt   testEnumDefaultValueU  s    	
			c            s    f d       f d   } | t  j    t j   } | j t j j t j	 j
   | j t j j t j	 j
   | j t j j t  j	 j
   t j |  j | j t  j j	 j   } | |    d S(   s0   Check the value returned by non-existent fields.c            s$     j  |  |    j |  |  d  S(   N(   R!   R   (   t   valuet   expected_valuet   expected_type(   R   (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyt   _CheckValueAndTypeq  s    c            s   y
 t  } Wn t k
 r# t } n Xy
 t } Wn t k
 rG t } n X  |  j d t    |  j d | t f    |  j d t t f    |  j	 d t t f    |  j
 t t    |  j d |    |  j d t    |  j |  j t  d  S(   Ni    u    t    (   t   longt	   NameErrort   intt   unicodet   strt   optional_int32t   optional_uint64t   optional_floatt   floatt   optional_doublet   optional_boolt   Falset   boolt   optional_stringt   optional_bytest   bytest   optional_nested_enumt   FOO(   t   msgt   int64t   unicode_type(   R   (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyt   _CheckDefaultValuesu  s     



N(   R   t   TestAllTypesR   R   R   R   R   R   R   R   R   R    R   t   MessageFactoryt   GetPrototypeRA   RC   (   R   R   R   t   message_class(    (   R   R   sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyt!   testDefaultValueForCustomMessageso  s    (   t   __name__t
   __module__R   R*   R-   R/   R0   R]   R^   Rm   Rn   Rt   Ry   R   R   R   R   R   R   R   R   (    (    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyR   ?   s&   							R				
				
				t	   ProtoFilec           B   s    e  Z d d d   Z d   Z RS(   c         C   s=   | |  _  | |  _ | |  _ | p$ g  |  _ | p3 g  |  _ d  S(   N(   R"   R#   t   messagest   dependenciest   public_dependencies(   R   R"   R#   R   R   R   (    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyt   __init__  s
    			c   	      C   s   | j  |  j  } | j |  j | j  | j |  j | j  g  | j D] } | j ^ qH } | j |  j |  g  | j D] } | j ^ qz } | j |  j |  x3 |  j j   D]" \ } } | j | d  | |  q Wd  S(   N(
   R   R"   R!   R#   R   R   R   t   itemst	   CheckTypeRD   (	   R   t   testR   t	   file_desct   ft   dependencies_namest   public_dependencies_namesR"   t   msg_type(    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyR     s    N(   R   R   RD   R   R   (    (    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyR     s   t   EnumTypec           B   s   e  Z d    Z d   Z RS(   c         C   s   | |  _  d  S(   N(   t   values(   R   R   (    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyR     s    c         C   s  | j  | } | j | | j  d j | j | g  } | j | | j  | j | | j  | j | | j  x t |  j  D]~ \ } \ } }	 | j	 | }
 | j | |
 j  | j | |
 j
  | j |	 |
 j  | j | |
 j  | j | | j  q Wd  S(   Nt   .(   t   enum_types_by_nameR!   R"   t   joinRC   RE   t   filet	   enumerateR   Ri   t   indexRj   t   typeR$   t   enum_values_by_name(   R   R   t   msg_descR"   R   t	   enum_desct   expected_enum_full_nameR   R   Rj   t
   value_desc(    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyR     s    "(   R   R   R   R   (    (    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyR     s   	t   MessageTypec           B   s    e  Z e d d   Z d   Z RS(   c         C   s.   | |  _  | |  _ | |  _ | p$ g  |  _ d  S(   N(   t	   type_dictt
   field_listt   is_extendableR   (   R   R   R   R   R   (    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyR     s    			c   
      C   sm  | d  k r4 | j | } d j | j | g  } n% | j | } d j | j | g  } | j | | j  | j | | j  | j | | j  | j | j	 |  | j |  j
 | j
  x3 |  j j   D]" \ } } | j | | | |  q Wx9 t |  j  D]( \ } \ } }	 |	 j | | | |  qWx9 t |  j  D]( \ } \ } }	 |	 j | | | |  q=Wd  S(   NR   (   RD   R%   R   R#   t   nested_types_by_nameRC   R!   R"   RE   R   R   R   R   R   R   R   t
   CheckFieldR   (
   R   R   t   containing_type_descR"   R   t   desct   expected_full_namet   subtypeR   Rs   (    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyR     s     ""N(   R   R   R   RD   R   R   (    (    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyR     s   t	   EnumFieldc           B   s   e  Z d    Z d   Z RS(   c         C   s   | |  _  | |  _ | |  _ d  S(   N(   Rj   t	   type_nameRP   (   R   Rj   R   RP   (    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyR     s    		c         C   s*  | j  | } | j |  j } | j | | j  d j | j | g  } | j | | j  | j | | j  | j |  j | j  | j t	 j
 j | j  | j t	 j
 j | j  | j | j  | j | j |  j j | j  | j | j |  j j  | j | | j  | j | | j  d  S(   NR   (   RJ   R   R   R!   R"   R   RC   R   Rj   R   t   FieldDescriptort	   TYPE_ENUMR   t   CPPTYPE_ENUMt   cpp_typeRN   RO   Ri   RP   RF   RG   RE   RL   (   R   R   R   R"   R   t
   field_descR   t   expected_field_full_name(    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyR     s     

(   R   R   R   R   (    (    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyR     s   	t   MessageFieldc           B   s   e  Z d    Z d   Z RS(   c         C   s   | |  _  | |  _ d  S(   N(   Rj   R   (   R   Rj   R   (    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyR     s    	c         C   s   | j  | } | j |  j } | j | | j  d j | j | g  } | j | | j  | j | | j  | j |  j | j  | j t	 j
 j | j  | j t	 j
 j | j  | j | j  | j | | j  | j | | j  d  S(   NR   (   RJ   R   R   R!   R"   R   RC   R   Rj   R   R   t   TYPE_MESSAGER   t   CPPTYPE_MESSAGER   RF   RO   RE   RK   (   R   R   R   R"   R   R   t   field_type_descR   (    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyR     s    
(   R   R   R   R   (    (    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyR     s   	t   StringFieldc           B   s   e  Z d    Z d   Z RS(   c         C   s   | |  _  | |  _ d  S(   N(   Rj   RP   (   R   Rj   RP   (    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyR     s    	c         C   s   | j  | } | j | | j  d j | j | g  } | j | | j  | j | | j  | j |  j | j  | j t j j	 | j
  | j t j j | j  | j | j  | j |  j | j  d  S(   NR   (   RJ   R!   R"   R   RC   R   Rj   R   R   t   TYPE_STRINGR   t   CPPTYPE_STRINGR   RN   RO   RP   (   R   R   R   R"   R   R   R   (    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyR     s    
(   R   R   R   R   (    (    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyR     s   	t   ExtensionFieldc           B   s   e  Z d    Z d   Z RS(   c         C   s   | |  _  | |  _ d  S(   N(   Rj   t   extended_type(   R   Rj   R   (    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyR   '  s    	c         C   s	  | j  | } | j | | j  d j | j | g  } | j | | j  | j |  j | j  | j | | j  | j t j j	 | j
  | j t j j | j  | j | j  | j | j  | j | | j  | j | | j  | j |  j | j j  d  S(   NR   (   R{   R!   R"   R   RC   Rj   R   R   R   R   R   R   R   RF   RO   RN   t   is_extensiont   extension_scopeRK   R   RE   (   R   R   R   R"   R   R   R   (    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyR   +  s    
(   R   R   R   R   (    (    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyR   %  s   	t   AddDescriptorTestc           B   s   e  Z d    Z e j e j   d k d  d    Z d   Z e j e j   d k d  d    Z	 e j e j   d k d  d    Z
 d   Z d   Z d	   Z RS(
   c         C   s   t  j   } | j t j j  |  j d | j | d  j  |  j	 t
   | j | d  Wd  QX| j t j j j  |  j d | j | d  j  |  j d | j d  j  |  j d | j | d  j  d  S(   Ns   protobuf_unittest.TestAllTypess,   protobuf_unittest.TestAllTypes.NestedMessages   google/protobuf/unittest.proto(   R   R   t   AddDescriptorR   R   R   R!   RA   RC   R+   R,   t   NestedMessageR   R"   R.   (   R   t   prefixR   (    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyt   _TestMessage>  s,    t   cpps7   With the cpp implementation, Add() must be called firstc         C   s   |  j  d  |  j  d  d  S(   NR   R   (   R   (   R   (    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyt   testMessage\  s    c         C   s   t  j   } | j t j j  |  j d | j | d  j  |  j	 t
   | j | d  Wd  QX| j t j j j  |  j d | j | d  j  |  j d | j d  j  |  j d | j | d  j  d  S(   Ns   protobuf_unittest.ForeignEnums(   protobuf_unittest.ForeignEnum.NestedEnums)   protobuf_unittest.TestAllTypes.NestedEnums   google/protobuf/unittest.proto(   R   R   t   AddEnumDescriptorR   t   ForeignEnumR   R!   Rg   RC   R+   R,   R   t
   NestedEnumR   R"   R.   (   R   R   R   (    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyt	   _TestEnumb  s,    c         C   s   |  j  d  |  j  d  d  S(   NR   R   (   R  (   R   (    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyt   testEnum  s    c         C   s_   t  j   } | j t j  |  j d | j d  j  |  j t	   | j
 d  Wd  QXd  S(   Ns   google/protobuf/unittest.protos   protobuf_unittest.TestAllTypes(   R   R   t   AddFileDescriptorR   R   R!   R   R"   R+   R,   R.   (   R   R   (    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyt   testFile  s    c         C   sq   t  j   } t j j } |  j t | j |  t j   } t j j	 |  | j
 |  |  j | j |   d  S(   N(   R   R   R   R   R"   R+   R,   R   R   t   CopyToProtoR   RN   (   R   R   t   proto_file_nameR   (    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyt   testEmptyDescriptorPool  s    c         C   s   t  j   } t j d d d d  } | j j d d  | j |  |  j | j d  j	 d  |  j | j
 d  j	 d  d  S(   NR"   s   some/file.protoR#   t   Messages   package.Message(   R   R   R   R   RK   t   addR   R!   R   R"   RA   (   R   R   R   (    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyt   testCustomDescriptorPool  s    	c         C   s   t  j   } d } t j d |  } t j } d | j j | _ | j	 |  | j
 |  } | j   } |  j d | j | j  |  j | | j    d  S(   Ns9   file_descriptor_options_with_custom_descriptor_pool.protoR"   t   foo(   R   R   R   R   R	   t   foo_optionst   optionst
   Extensionst   foo_nameR   R   t
   GetOptionsR!   R   (   R   R   t	   file_namet   file_descriptor_protot   extension_idR   R  (    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyt1   testFileDescriptorOptionsWithCustomDescriptorPool  s    	(   R   R   R   t   unittestt   skipIfR   t   TypeR   R  R  R  R	  R  R  (    (    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyR   <  s   				R   s8   default_pool is only supported by the C++ implementationt   DefaultPoolTestc           B   s   e  Z d    Z d   Z RS(   c         C   s   d d l  m } | j } |  j | j d  t j  |  j | j d  t j j  |  j | j	 d  t j j j
 d  |  j | j d  t j j d  |  j | j d	  t j j  |  j | j d
  t j j j d  d  S(   Ni(   t   _messages   google/protobuf/unittest.protos   protobuf_unittest.TestAllTypess-   protobuf_unittest.TestAllTypes.optional_int32R   s*   protobuf_unittest.optional_int32_extensiont   optional_int32_extensions   protobuf_unittest.ForeignEnums*   protobuf_unittest.TestAllTypes.oneof_fieldt   oneof_field(   t   google.protobuf.pyextR  t   default_poolR   R   R   R   RA   R   Rp   RJ   Rw   R{   Rg   R  t   FindOneofByNameRS   (   R   R  R   (    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyt   testFindMethods  s(    	
c         C   sO   d d l  m } | j } t j d d  } | j |  | j | j    d  S(   Ni(   R  R"   s   some/file.proto(   R  R  R  R   R   R   R   R   (   R   R  R   R   (    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyt   testAddFileDescriptor  s
    	(   R   R   R!  R"  (    (    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyR    s   	s4   google/protobuf/internal/descriptor_pool_test1.protos   google.protobuf.python.internalt   ALPHAi   R   i   R  t   EPSILONi   t   ZETAi   t   ETAi   t   THETAi   R   t   nested_fieldt   thetat   DeepNestedMessaget   betat   deep_nested_messagei   R   t   nested_messageR   R   t   GAMMAt   DELTAi   t   IOTAi	   t   KAPPAi
   t   LAMBDAi   t   MUi   t   lambdat   deltat   DescriptorPoolTest2s4   google/protobuf/internal/descriptor_pool_test2.protot   NUi   t   XIi   t   OMICRONi   t   PIi   t   RHOi   t   SIGMAi   t   sigmat   nuR   t   descriptor_pool_testi  t   DescriptorPoolTest3R   s,   google/protobuf/internal/more_messages.protoR   t   __main__(,   t   __doc__t
   __author__t   ost   syst	   unittest2R  t   ImportErrort   google.protobufR    R   R   R   t   google.protobuf.internalR   R   R   R   R   R	   R
   R   R   R   R   R   t   TestCaseR   t   objectR   R   R   R   R   R   R   R   R  R  R  t   TrueR   R   R   t   main(    (    (    sO   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_pool_test.pyt   <module>!   s    X 	"
"	