
XXc           @   s  d  Z  d Z d d l Z y d d l Z Wn e k
 rG 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 Z d e j f d     YZ d e f d     YZ d e j f d     YZ d e j f d     YZ d e j f d     YZ e d k re j   n  d S(   s1   Unittest for google.protobuf.internal.descriptor.s#   robinson@google.com (Will Robinson)iN(   t   unittest_custom_options_pb2(   t   unittest_import_pb2(   t   unittest_pb2(   t   descriptor_pb2(   t   api_implementation(   t	   test_util(   t
   descriptor(   t   descriptor_pool(   t   symbol_database(   t   text_formats   
name: 'TestEmptyMessage'
t   DescriptorTestc           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 e j e j   d k p e j   d k d  d    Z RS(   c      	   C   s  t  j d d d d  } | j j d d  } | j j d d d d d	 t  j j d
 t  j j  | j j d d  } | j	 j d d d d  | j	 j d d d d  | j	 j d d d d  | j j d d  | j
 j d d  } | j j d d d d d d  } |  j   |  _ |  j j |  |  j j | j  |  _ |  j j | j |  _ |  j j | j |  _ |  j j | j |  _ |  j j | j |  _ d  S(   Nt   names   some/filename/some.protot   packaget   protobuf_unittestt   NestedMessaget   bbt   numberi   t   typet   labelt   ForeignEnumt   FOREIGN_FOOi   t   FOREIGN_BARi   t   FOREIGN_BAZi   t   ResponseMessaget   Servicet
   CallMethodt
   input_types    .protobuf_unittest.NestedMessaget   output_types"   .protobuf_unittest.ResponseMessage(   R   t   FileDescriptorProtot   message_typet   addt   fieldt   FieldDescriptorProtot
   TYPE_INT32t   LABEL_OPTIONALt	   enum_typet   valuet   servicet   methodt   GetDescriptorPoolt   poolt   Addt   FindFileByNameR   t   my_filet   message_types_by_namet
   my_messaget   enum_types_by_namet   my_enumt   services_by_namet
   my_servicet   methods_by_namet	   my_method(   t   selft
   file_protot   message_protot
   enum_protot   service_protot   method_proto(    (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyt   setUp?   s:    						c         C   s   t  j   j S(   N(   R   t   DefaultR(   (   R4   (    (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyR'   c   s    c         C   sV   |  j  |  j j d d  d  |  j  |  j j d j d j |  j j d d   d  S(   NR   i   R   (   t   assertEqualR-   t   EnumValueNameR.   t   values_by_numberR   (   R4   (    (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyt   testEnumValueNamef   s    	c         C   s$   |  j  |  j |  j j d j  d  S(   Ni    (   R<   R/   t   valuesR   (   R4   (    (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyt   testEnumFixupso   s    c         C   s=   |  j  |  j |  j j d j  |  j  |  j |  j j  d  S(   Ni    (   R<   R-   t   fieldst   containing_typeR/   (   R4   (    (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyt   testContainingTypeFixupsr   s     c         C   s   |  j  |  j |  j j  d  S(   N(   R<   R1   R3   t   containing_service(   R4   (    (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyt   testContainingServiceFixupsv   s    c         C   s   |  j  |  j j   t j    |  j  |  j j d j   t j    |  j  |  j j   t j    |  j  |  j j	 d j   t j
    |  j  |  j j   t j    |  j  |  j j   t j    d  S(   Ni    (   R<   R/   t
   GetOptionsR   t   EnumOptionsR@   t   EnumValueOptionsR-   t   MessageOptionsRB   t   FieldOptionsR3   t   MethodOptionsR1   t   ServiceOptions(   R4   (    (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyt   testGetOptionsy   s    c         C   s  t  j } t  j j } | j d } | j d } | j d } | j d } t  j j } | j d  } | j	   }	 t  j
 }
 |  j d |	 j |
  | j	   } t  j } |  j d | j |  | j	   } t  j } |  j d | j |  t  j } |  j d	 | j |  | j	   } t  j } |  j d
 | j |  | j	   } t  j } |  j d | j |  | j	   } t  j } |  j d | j |  | j	   } t  j } |  j d | j |  | j	   } t  j } |  j t  j | j |  t  j j } |  j | j  |  j | j  d  S(   Nt   field1t   AnOneoft   AnEnumt   ANENUM_VAL2t   FooIL   iI-u
   i*   iii{   IO(   R    t
   DESCRIPTORt   TestMessageWithCustomOptionst   fields_by_namet   oneofs_by_nameR.   t   enum_values_by_namet   TestServiceWithCustomOptionst   FindMethodByNameRG   t	   file_opt1R<   t
   Extensionst   message_opt1t
   field_opt1t
   field_opt2t
   oneof_opt1t	   enum_opt1t   enum_value_opt1t   service_opt1t   method_opt1t   METHODOPT1_VAL2t   DummyMessageContainingEnumt
   assertTruet   has_optionst   assertFalse(   R4   t   file_descriptort   message_descriptort   field_descriptort   oneof_descriptort   enum_descriptort   enum_value_descriptort   service_descriptort   method_descriptort   file_optionsR[   t   message_optionsR]   t   field_optionsR^   R_   t   oneof_optionsR`   t   enum_optionsRa   t   enum_value_optionsRb   t   service_optionsRc   t   method_optionsRd   (    (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyt   testSimpleCustomOptions   sL    										c   
      C   s  d } d } d } d } d } d } t  j j } | j   } |  j t | j t  j  |  j | | j t  j  |  j | | j t  j	  |  j d | j t  j
  |  j d | j t  j  |  j | | j t  j  |  j | | j t  j  |  j d | j t  j  |  j d | j t  j  |  j | | j t  j  |  j | | j t  j  t  j j } | j   } |  j t | j t  j  |  j | | j t  j  |  j | | j t  j	  |  j | | j t  j
  |  j | | j t  j  |  j | | j t  j  |  j | | j t  j  |  j | | j t  j  |  j | | j t  j  |  j | | j t  j  |  j | | j t  j  t  j j } | j   } |  j d | j t  j  |  j d	 | j t  j d
  |  j d | j t  j  |  j d | j t  j  |  j d | j t  j  t  j }	 |  j |	 j | j t  j  t  j j } | j   } |  j d | j t  j d
  |  j d | j t  j  t  j j } | j   } |  j d | j t  j d
  |  j d | j t  j  d  S(   Ni   i   i?   i   i    i@   i    ig$(@i   gYB?s   Hello, "World"t   Hello Worldi   i   iifI       i   l            l         I       il            l    I       I    l            l    (   R    t   CustomOptionMinIntegerValuesRT   RG   R<   t   FalseR\   t   bool_optt	   int32_optt	   int64_optt
   uint32_optt
   uint64_optt
   sint32_optt
   sint64_optt   fixed32_optt   fixed64_optt   sfixed32_optt   sfixed64_optt   CustomOptionMaxIntegerValuest   Truet   CustomOptionOtherValuest   assertAlmostEqualt	   float_optt
   double_optt
   string_optt	   bytes_optRf   t   TEST_OPTION_ENUM_TYPE2t   enum_optt   SettingRealsFromPositiveIntst   SettingRealsFromNegativeInts(
   R4   t	   kint32mint	   kint64mint	   kint32maxt	   kint64maxt
   kuint32maxt
   kuint64maxRk   Rs   t
   dummy_enum(    (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyt   testDifferentCustomOptionTypes   s    	c         C   sY  t  j j } | j   } |  j d | j t  j j  |  j d | j t  j j t  j  |  j d | j t  j j t  j	 j
  |  j d | j t  j j  |  j d | j t  j j t  j  |  j d | j t  j j j  |  j d | j t  j j j t  j  |  j d | j t  j j j t  j	 j
  |  j d	 | j t  j j t  j j  |  j d
 | j t  j j t  j j t  j  |  j d | j t  j j t  j j t  j	 j
  |  j d | j t  j j j j  |  j d | j t  j j j  |  j d | j t  j j
  |  j d | j t  j j j  |  j d | j t  j j  d  S(   Ni*   iD  il  i  i  i  i  i  i  i  iI  i  iA  i	   i   i   (   R    t   VariousComplexOptionsRT   RG   R<   R\   t   complex_opt1t   foot   quuxt   corget   quxt   complex_opt2t   bazt   graultt   bart   garplyt   ComplexOptionType2t   ComplexOptionType4t   complex_opt4t   waldot   fredt   complex_opt3t   complexoptiontype5t   plught   complexopt6t   xyzzy(   R4   R   t   options(    (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyt   testComplexExtensionOptions  sX    







c   	      C   s  t  j } t  j j } | j d } t  j j } | j d } t  j j } | j d  } | j   j	 t  j
 } |  j d | j  |  j d | j  |  j d | j j  |  j d | j j	 t  j
 j  |  j d | j j	 t  j j j  |  j d	 | j   j	 t  j j  |  j d
 | j   j	 t  j j  |  j d | j   j	 t  j j  |  j d | j   j	 t  j j  |  j d | j   j	 t  j j  |  j d | j   j	 t  j j  d  S(   Nt	   fieldnamet   VALUEt   Methodid   t   FileAnnotationt   NestedFileAnnotationt   FileExtensionAnnotationt   EmbeddedMessageSetElementt   MessageAnnotationt   FieldAnnotationt   EnumAnnotationt   EnumValueAnnotationt   ServiceAnnotationt   MethodAnnotation(   R    RT   t   AggregateMessageRV   t   AggregateEnumt   values_by_namet   AggregateServiceRZ   RG   R\   t   fileoptR<   t   it   st   subt   filet   msett   AggregateMessageSetElementt   message_set_extensiont   msgoptt   fieldoptt   enumoptt
   enumvaloptt
   serviceoptt	   methodopt(	   R4   Rj   Rk   Rl   Rn   Ro   Rp   Rq   Rr   (    (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyt   testAggregateOptionsF  sP    	
c         C   s   t  j j j } |  j d | j   j t  j  | j d } |  j d | j   j t  j	  t  j j } | j
 d } |  j d | j   j t  j  | j d } |  j d | j   j t  j  | j d } |  j d	 | j   j t  j  d  S(
   Ni  t   nested_fieldi  t
   NestedEnumi  t   NESTED_ENUM_VALUEi  t   nested_extensioni  (   R    t   NestedOptionTypeR   RT   R<   RG   R\   R]   RV   R^   R.   Ra   RX   Rb   t   extensions_by_nameR_   (   R4   t   nested_messageR   t   outer_messaget   nested_enumt   nested_enum_valueR   (    (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyt   testNestedOptionsw  s     c         C   s6   |  j  |  j j |  j  |  j  |  j j |  j  d  S(   N(   R<   R/   R   R+   R-   (   R4   (    (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyt   testFileDescriptorReferences  s    c         C   se   |  j  |  j j d  |  j  |  j j d  |  j  |  j j |  j  |  j  t j j t j    d  S(   Ns   some/filename/some.protoR   (	   R<   R+   R   R   R(   R   RT   R   R;   (   R4   (    (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyt   testFileDescriptor  s    t   cppi   sA   Immutability of descriptors is only enforced in v2 implementationc         C   sx   t  j j } |  j t   d  | _ Wd  QX|  j t   d  | j d <Wd  QX|  j t   | j j	 d   Wd  QXd  S(   Nt   Another(
   R   t   TestAllTypesRT   t   assertRaisest   AttributeErrort   NoneRV   t	   TypeErrorRB   t   append(   R4   Rk   (    (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyt   testImmutableCppDescriptor  s    (   t   __name__t
   __module__R:   R'   R?   RA   RD   RF   RN   Rz   R   R   R   R   R   R   t   unittestt   skipIfR   t   Typet   VersionR   (    (    (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyR
   =   s"   	$								/	^	2	1			!t   NewDescriptorTestc           B   s   e  Z d  Z d   Z RS(   sA   Redo the same tests as above, but with a separate DescriptorPool.c         C   s
   t  j   S(   N(   R   t   DescriptorPool(   R4   (    (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyR'     s    (   R   R   t   __doc__R'   (    (    (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyR     s   t   GeneratedDescriptorTestc           B   sM   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 RS(   s:   Tests for the properties of descriptors in generated code.c         C   s   |  j  | j d  |  j  | j d  |  j  | |  |  j  | j d j |  |  j | | g  |  j | i d  | 6 |  j | j  |  j | j	  |  j | j
  |  j | j  d  S(   NR   s   protobuf_unittest.TestAllTypesi    (   R<   R   t	   full_nameRB   RC   t   assertInR   t   CheckDescriptorSequencet   CheckDescriptorMappingRV   t   fields_by_numbert   fields_by_camelcase_name(   R4   Rk   (    (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyt   CheckMessageDescriptor  s    c         C   s   |  j  | j d  |  j  | j d  |  j  | j d  |  j  | j j d  |  j  | |  |  j  | j j d |  |  j  | j j d |  |  j | | g  |  j | i d  | 6 d  S(   Nt   optional_int32t   optionalInt32s-   protobuf_unittest.TestAllTypes.optional_int32R   (	   R<   R   t   camelcase_nameR   RC   RV   R   R   R   (   R4   Rl   (    (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyt   CheckFieldDescriptor  s    	c         C   s   |  j  t |  d  |  j t |  t t |    | d } |  j | | d  |  j | |  |  j | j |  d  |  j | j |  d  t |  } |  j t |  t |  d  d  d   |  j t	 t
 |  d  S(   Ni    i   i(   t   assertGreatert   lenR<   t   listR   t   indext   countt   reversedR   t   StopIterationt   next(   R4   t   sequencet   itemt   reversed_iterator(    (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyR     s    "
)c            si    j  t |  d    j t |  t t |    t j d k rh t t | j     \ } } n | j   d \ } }   j	 | |    j | j
 |  |  t t | j     t t | j     f }   j | t t | j      t j d k  re  f d   } | | j   | j    | | j   | j    | | j   | j    n  d  S(   Ni    i   c            s8     j  t |  |  d    j  t |  |  d  d  S(   Ni    i   (   R<   R  R  (   t   seqt   iterator(   R4   (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyt
   CheckItems  s    (   i   (   i   (   R   R   R<   R  t   syst   version_infoR  t   itert   itemsR   t   gett   keysR@   t   iterkeyst
   itervaluest	   iteritems(   R4   t   mappingt   keyR  R  (    (   R4   sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyR     s    "!0"c         C   sQ   t  j j } |  j |  | j d } |  j |  | j d } |  j |  d  S(   NR   R   (   R   R   RT   R   RV   R   R   (   R4   Rk   Rl   (    (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyt   testDescriptor  s    c         C   s:   t  j j j d } | j } ~ |  j d | d j  d  S(   NR   t   FOOi    (   R   R   RT   R.   R@   R<   R   (   R4   t   enumR@   (    (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyt   testCppDescriptorContainer  s    	c         C   sB   t  j j j d } t | j  } ~ |  j d t |  j  d  S(   NR   R  (	   R   R   RT   R.   R  R@   R<   R  R   (   R4   R  t   values_iter(    (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyt#   testCppDescriptorContainer_Iterator  s    (
   R   R   R   R   R   R   R   R  R  R  (    (    (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyR     s   							t   DescriptorCopyToProtoTestc           B   sh   e  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)   Tests for CopyTo functions of Descriptor.c         C   sF   |   } t  j | |  |  j | | d t |  t |  f  d  S(   Ns#   Not equal,
Actual:
%s
Expected:
%s
(   R	   t   MergeR<   t   str(   R4   t   actual_protot   expected_classt   expected_asciit   expected_proto(    (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyt   _AssertProtoEqual  s    	c         C   s-   |   } | j  |  |  j | | |  d  S(   N(   t   CopyToProtoR%  (   R4   t   desct   expected_proto_classt   expected_proto_asciit   actual(    (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyt   _InternalTestCopyToProto  s    	c         C   s    |  j  t j j t j t  d  S(   N(   R+  R   t   TestEmptyMessageRT   R   t   DescriptorProtot#   TEST_EMPTY_MESSAGE_DESCRIPTOR_ASCII(   R4   (    (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyt   testCopyToProto_EmptyMessage   s    	c         C   s)   d } |  j  t j j j t j |  d  S(   Ns   
      name: 'NestedMessage'
      field: <
        name: 'bb'
        number: 1
        label: 1  # Optional
        type: 5  # TYPE_INT32
      >
      (   R+  R   R   R   RT   R   R-  (   R4   t   TEST_NESTED_MESSAGE_ASCII(    (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyt   testCopyToProto_NestedMessage&  s
    	c         C   s&   d } |  j  t j j t j |  d  S(   Ns   
      name: 'TestForeignNested'
      field: <
        name: 'foreign_nested'
        number: 1
        label: 1  # Optional
        type: 11  # TYPE_MESSAGE
        type_name: '.protobuf_unittest.TestAllTypes.NestedMessage'
      >
      (   R+  R   t   TestForeignNestedRT   R   R-  (   R4   t   TEST_FOREIGN_NESTED_ASCII(    (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyt$   testCopyToProto_ForeignNestedMessage6  s
    
	c         C   s&   d } |  j  t j j t j |  d  S(   Ns   
      name: 'ForeignEnum'
      value: <
        name: 'FOREIGN_FOO'
        number: 4
      >
      value: <
        name: 'FOREIGN_BAR'
        number: 5
      >
      value: <
        name: 'FOREIGN_BAZ'
        number: 6
      >
      (   R+  R   R   RT   R   t   EnumDescriptorProto(   R4   t   TEST_FOREIGN_ENUM_ASCII(    (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyt   testCopyToProto_ForeignEnumG  s
    	c         C   s&   d } |  j  t j j t j |  d  S(   Ns   
      name: 'TestDeprecatedFields'
      field: <
        name: 'deprecated_int32'
        number: 1
        label: 1  # Optional
        type: 5  # TYPE_INT32
        options: <
          deprecated: true
        >
      >
      (   R+  R   t   TestDeprecatedFieldsRT   R   R-  (   R4   t   TEST_DEPRECATED_FIELDS_ASCII(    (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyt   testCopyToProto_Options]  s
    	c         C   s&   d } |  j  t j j t j |  d  S(   Ns}   
      name: 'TestEmptyMessageWithExtensions'
      extension_range: <
        start: 1
        end: 536870912
      >
      (   R+  R   t   TestEmptyMessageWithExtensionsRT   R   R-  (   R4   t(   TEST_EMPTY_MESSAGE_WITH_EXTENSIONS_ASCII(    (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyt   testCopyToProto_AllExtensionsp  s
    	c         C   s&   d } |  j  t j j t j |  d  S(   Ns  
      name: 'TestMultipleExtensionRanges'
      extension_range: <
        start: 42
        end: 43
      >
      extension_range: <
        start: 4143
        end: 4244
      >
      extension_range: <
        start: 65536
        end: 536870912
      >
      (   R+  R   t   TestMultipleExtensionRangesRT   R   R-  (   R4   t*   TEST_MESSAGE_WITH_SEVERAL_EXTENSIONS_ASCII(    (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyt!   testCopyToProto_SeveralExtensions~  s
    	c         C   s
   d } d  S(   NsM  
      name: 'TestService'
      method: <
        name: 'Foo'
        input_type: '.protobuf_unittest.FooRequest'
        output_type: '.protobuf_unittest.FooResponse'
      >
      method: <
        name: 'Bar'
        input_type: '.protobuf_unittest.BarRequest'
        output_type: '.protobuf_unittest.BarResponse'
      >
      (    (   R4   t   TEST_SERVICE_ASCII(    (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyt!   testCopyToProto_ServiceDescriptor  s    (   R   R   R   R%  R+  R/  R1  R4  R7  R:  R=  R@  RB  (    (    (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyR    s   										Bt   MakeDescriptorTestc           B   s5   e  Z d    Z d   Z d   Z d   Z d   Z RS(   c   	      C   s7  t  j   } d | _ | j j   } | j | _ | j j   } d | _ | j j   } d | _ | j j   } d | _ d | _ | j	 j   } d | _ d | _ t
 j j | _ t
 j j | _ | j	 j   } d | _ d	 | _ t
 j j | _ t
 j j | _ d | _ | j	 j   } d | _ d
 | _ t
 j j | _ t
 j j | _ d | _ t
 j |  } |  j | j d j t
 j j  |  j | j d j t
 j j  |  j | j d j j |  |  j | j d j d j d  |  j | j d j d j | j d j d  |  j | j  |  j | j d j  d  S(   Nt   Foo2t   SubR  t   BARi   i   t   uint64_fieldi   t   nested_message_fieldt	   bar_fields   Foo2.Sub.FOOi    s   Foo2.Sub.bar_field(   R   R   R   R   R   t   nested_typeR#   R$   R   R   R   t   FieldDescriptort   LABEL_REQUIREDR   t   TYPE_UINT64R   t   TYPE_MESSAGEt	   type_namet	   TYPE_ENUMt   MakeDescriptorR<   RB   t   cpp_typet   CPPTYPE_UINT64t   CPPTYPE_MESSAGERC   t   nested_typesR   t
   enum_typesRi   Rh   (	   R4   t   file_descriptor_protoR   RJ  R#   t   enum_type_valR   t
   enum_fieldt   result(    (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyt"   testMakeDescriptorWithNestedFields  sR    													c         C   s#  t  j   } d | _ | j j   } | j | _ | j j   } d | _ | j j   } d | _ d | _ | j j   } d | _ d | _ t	 j
 j | _ t	 j
 j | _ | j j   } d | _ d | _ t	 j
 j | _ t	 j
 j | _ d	 | _ t	 j |  } |  j | j d
 j t	 j
 j  d  S(   NRS   R  RF  i   i   RG  i   RI  s   Foo.FOOi    (   R   R   R   R   R   R#   R$   R   R   R   RK  RL  R   RM  R   RP  RO  RQ  R<   RB   RR  RS  (   R4   RW  R   R#   RX  R   RY  RZ  (    (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyt&   testMakeDescriptorWithUnsignedIntField  s.    									c         C   sa   t  j   } t j } | j j |  t j |  } | j   } |  j	 d | j
 t j j  d  S(   Nie   (   R   R-  R    R   RT   R&  R   RQ  RG   R<   R\   R   R   (   R4   t   descriptor_protot   aggregate_messaget   reformed_descriptorR   (    (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyt   testMakeDescriptorWithOptions  s    		c         C   s   t  j   } d | _ d d d d d g } d d d d d g } xC t t |   D]/ } | j j   } | d | _ | | | _ qR Wt j	 |  } x8 t t |   D]$ } |  j
 | j | j | |  q Wd  S(	   Nt   Bart   foo_foot   FooBart   fooBazt   fooFoot   foobart   fooBari   (   R   R-  R   t   rangeR   R   R   R   R   RQ  R<   RB   R   (   R4   R]  t   namest   camelcase_namesR  R   RZ  (    (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyt   testCamelcaseName)  s    	c         C   s   t  j   } d | _ d d d d d d g } d d d d d d	 g } xC t t |   D]/ } | j j   } | d
 | _ | | | _ qX Wd	 | _ t	 j
 |  } x8 t t |   D]$ } |  j | j | j | |  q Wd  S(   Nt   TestJsonNamet
   field_namet	   fieldNamet	   FieldNamet   _field_namet
   FIELD_NAMEt	   json_namet	   FIELDNAMEs   @typei   (   R   R-  R   Rh  R   R   R   R   Rr  R   RQ  R<   RB   (   R4   R]  Ri  t
   json_namesR  R   RZ  (    (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyt   testJsonName7  s    				(   R   R   R[  R\  R`  Rk  Ru  (    (    (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyRC    s
   	,		
	t   __main__(   R   t
   __author__R  t	   unittest2R   t   ImportErrort   google.protobufR    R   R   R   t   google.protobuf.internalR   R   R   R   R   R	   R.  t   TestCaseR
   R   R   R  RC  R   t   main(    (    (    sJ   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/descriptor_test.pyt   <module>!   s2    gcs