
XXc           @   s  d  Z  d Z d d l Z d d l Z d d l Z y d d l Z Wn e k
 r_ 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 e j f d     YZ d e j f d     YZ e	 j e e  d e f d     Y Z d e f d     YZ d e f d     YZ d e j f d     YZ d e j f d     YZ e d k re j    n  d S(   s%   Test for google.protobuf.text_format.s    kenton@google.com (Kenton Varda)iN(   t   _parameterized(   t   any_test_pb2(   t   map_unittest_pb2(   t   unittest_mset_pb2(   t   unittest_pb2(   t   unittest_proto3_arena_pb2(   t   api_implementation(   t	   test_util(   t   message_set_extensions_pb2(   t   descriptor_pool(   t   text_formatt   SimpleTextFormatTestsc           B   s   e  Z d    Z RS(   c         C   s.   x' t  j D] } |  j d t |   q
 Wd  S(   Ni   (   R
   t   _QUOTESt   assertEqualt   len(   t   selft   quote(    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testQuoteMarksAreSingleCharsE   s    (   t   __name__t
   __module__R   (    (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyR   ?   s   t   TextFormatBasec           B   s,   e  Z d    Z d   Z d   Z d   Z RS(   c         C   sR   t  j |  = } t t k r( | j   Sg  | D] } | j d  ^ q/ SWd  QXd  S(   Ns   utf-8(   R   t
   GoldenFilet   strt   bytest	   readlinest   decode(   R   t   golden_filenamet   ft   golden_line(    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt
   ReadGoldenM   s    c         C   s,   |  j  |  } |  j | d j |   d  S(   Nt    (   R   t   assertMultiLineEqualt   join(   R   t   textR   t   golden_lines(    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   CompareToGoldenFileR   s    c         C   s   |  j  | |  d  S(   N(   R   (   R   R!   t   golden_text(    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   CompareToGoldenTextV   s    c         C   s[   | j  d d  j  d d  j  d d  j  d d  } t j d t j  j d |  } | S(   Ns   e+0s   e+s   e-0s   e-s   \.0$R   (   t   replacet   ret   compilet	   MULTILINEt   sub(   R   R!   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   RemoveRedundantZerosY   s    !(   R   R   R   R#   R%   R+   (    (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyR   K   s   			t   TextFormatTestc           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 d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   c         C   s   | j    } | 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	 |   d  d  S(	   NI       l    gw/^@gtQFքDg6<t    
	\'"u   üꜟs   repeated_int64: -9223372036854775808
repeated_uint64: 18446744073709551615
repeated_double: 123.456
repeated_double: 1.23e+22
repeated_double: 1.23e-18
repeated_string: "\000\001\007\010\014\n\r\t\013\\\'\""
repeated_string: "\303\274\352\234\237"
(
   t   TestAllTypest   repeated_int64t   appendt   repeated_uint64t   repeated_doublet   repeated_stringR%   R+   R
   t   MessageToString(   R   t   message_modulet   message(    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testPrintExoticg   s    c         C   sX   d t  j f d     Y} | j   } | j j | d   |  j t j |  d  d  S(   Nt
   UnicodeSubc           B   s   e  Z RS(    (   R   R   (    (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyR8   }   s   u   üꜟs(   repeated_string: "\303\274\352\234\237"
(   t   sixt	   text_typeR.   R3   R0   R%   R
   R4   (   R   R5   R8   R6   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testPrintExoticUnicodeSubclass{   s    c         C   sG   | j    } | j j   } d | _ |  j t j | d t d  d  S(   Ni*   t   as_one_lines"   repeated_nested_message { bb: 42 }(   R.   t   repeated_nested_messaget   addt   bbR%   R
   R4   t   True(   R   R5   R6   t   msg(    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testPrintNestedMessageAsOneLine   s    	c         C   s   | j    } | j j d  | j j d  | j j d  | j j d  | j j d  |  j t j | d t d  d  S(   Ni   i   t   Googlet   ZurichR<   si   repeated_int32: 1 repeated_int32: 1 repeated_int32: 3 repeated_string: "Google" repeated_string: "Zurich"(   R.   t   repeated_int32R0   R3   R%   R
   R4   R@   (   R   R5   R6   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt    testPrintRepeatedFieldsAsOneLine   s    c         C   s8   | j    } d | _ |  j t j | d t d  d  S(   Ns
   a
new
lineR<   s   optional_string: "a\nnew\nline"(   R.   t   optional_stringR%   R
   R4   R@   (   R   R5   R6   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt'   testPrintNestedNewLineInStringAsOneLine   s
    	c         C   s   | j    } | 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	 | d t
  d	  d  S(
   NI       l    gw/^@gtQFքDg6<R-   u   üꜟR<   s   repeated_int64: -9223372036854775808 repeated_uint64: 18446744073709551615 repeated_double: 123.456 repeated_double: 1.23e+22 repeated_double: 1.23e-18 repeated_string: "\000\001\007\010\014\n\r\t\013\\\'\"" repeated_string: "\303\274\352\234\237"(   R.   R/   R0   R1   R2   R3   R%   R+   R
   R4   R@   (   R   R5   R6   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testPrintExoticAsOneLine   s    c         C   s?  | j    } | j j d  | j j d  | j j d  | j j d  | j j d  | j j d  | j j d  t j | d t d	 t	 } | j    } t j
 | |  } |  j | |  |  j | |  t j | d t d	 t } | j    } t j
 | |  } |  j | |  |  j | | d
 | | f  d  S(   NI       l    gw/^@gtQFքDg6<R-   u   üꜟR<   t   as_utf8s	   
%s != %s(   R.   R/   R0   R1   R2   R3   R
   R4   R@   t   Falset   Parset   assertIsR   (   R   R5   R6   t	   wire_textt   parsed_messaget   r(    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testRoundTripExoticAsOneLine   s.    		c         C   s~   | j    } | j j d  t j | d t } |  j | d  | j    } t j | |  |  j | | d | | f  d  S(   Nu   üꜟRJ   s   repeated_string: "üꜟ"
s	   
%s != %s(	   R.   R3   R0   R
   R4   R@   R%   RL   R   (   R   R5   R6   R!   RO   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testPrintRawUtf8String   s    c         C   s   | j    } d | j _ d | j _ | j j j d  | j j j d  d d d d g } t j | d	 d
 } |  j	 |  j
 |  d j |    t j | d t d	 d
 } |  j	 |  j
 |  d j |    d  S(   Ng      ?g/_e̾ig⹭?s   optional_float: 1.25s%   optional_double: -3.45678901234568e-6s   repeated_float: -5642s   repeated_double: 7.89e-5t   float_formats   .15gs&   payload {{
  {0}
  {1}
  {2}
  {3}
}}
R<   s   payload {{ {0} {1} {2} {3} }}(   t   NestedTestAllTypest   payloadt   optional_floatt   optional_doublet   repeated_floatR0   R2   R
   R4   R%   R+   t   formatR@   (   R   R5   R6   t   formatted_fieldst   text_message(    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testPrintFloatFormat   s&    
	c         C   s/   | j    } d | _ |  j d t |   d  S(   Ni{   s   c: 123
(   t   ForeignMessaget   cR   R   (   R   R5   R6   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testMessageToString   s    	c         C   s   | j    } | j j d } | j } t j t  } t j | | |  |  j d | j	    | j
   t j t  } t j |  } | j | |  |  j d | j	    | j
   d  S(   NRV   s   optional_float: 0.0
(   R.   t
   DESCRIPTORt   fields_by_nameRV   R
   t
   TextWriterRK   t
   PrintFieldR   t   getvaluet   closet   _Printer(   R   R5   R6   t   fieldt   valuet   outt   printer(    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testPrintField  s    	
c         C   s   | j    } | j j d } | j } t j t  } t j | | |  |  j d | j	    | j
   t j t  } t j |  } | j | |  |  j d | j	    | j
   d  S(   NRV   s   0.0(   R.   R`   Ra   RV   R
   Rb   RK   t   PrintFieldValueR   Rd   Re   Rf   (   R   R5   R6   Rg   Rh   Ri   Rj   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testPrintFieldValue  s    	
c         C   sw   | j    } t j |  t j |  } | j    } t j | |  |  j | |  | t k rs t j |  |  n  d  S(   N(	   R.   R   t   SetAllFieldsR
   R4   RL   R   R   t   ExpectAllFieldsSet(   R   R5   R6   t
   ascii_textRO   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testParseAllFields!  s    c         C   s   | j    } d } t j | |  |  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  d  S(   NsS  repeated_int64: -9223372036854775808
repeated_uint64: 18446744073709551615
repeated_double: 123.456
repeated_double: 1.23e+22
repeated_double: 1.23e-18
repeated_string: 
"\000\001\007\010\014\n\r\t\013\\\'\""
repeated_string: "foo" 'corge' "grault"
repeated_string: "\303\274\352\234\237"
repeated_string: "\xc3\xbc"
repeated_string: "ü"
I       i    l    gw/^@gtQFքDi   g6<i   R-   t   foocorgegraultu   üꜟu   üi   (   R.   R
   RL   R   R/   R1   R2   R3   (   R   R5   R6   R!   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testParseExotic,  s    c         C   s   | j    } d } t j | |  |  j d | j d  |  j d | j d  |  j d | j d  |  j d | j d  |  j d	 | j d  d  S(
   Nso   repeated_int64: 100;
repeated_int64: 200;
repeated_int64: 300,
repeated_string: "one",
repeated_string: "two";
id   i    i   i   i,  i   u   oneu   two(   R.   R
   RL   R   R/   R3   (   R   R5   R6   R!   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testParseTrailingCommasE  s    c         C   s   | j    } d } t j | |  |  j d | j d  |  j d | j d  |  j d | j d  |  j d | j d  |  j d	 | j d  d  S(
   NsR   repeated_int64: [100, 200];
repeated_int64: 300,
repeated_string: ["one", "two"];
id   i    i   i   i,  i   u   oneu   two(   R.   R
   RL   R   R/   R3   (   R   R5   R6   R!   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt"   testParseRepeatedScalarShortFormatT  s    c         C   s   | j    } d } t j | |  |  j d | j d j  |  j d | j d j  |  j d | j d j  |  j d | j d	 j  d  S(
   Nsy   repeated_nested_message: [{bb: 100}, {bb: 200}],
repeated_nested_message: {bb: 300}
repeated_nested_message [{bb: 400}];
id   i    i   i   i,  i   i  i   (   R.   R
   RL   R   R=   R?   (   R   R5   R6   R!   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt#   testParseRepeatedMessageShortFormata  s    c         C   s<   | j    } d } t j | |  |  j | j    |  d  S(   NR   (   R.   R
   RL   R   (   R   R5   R6   R!   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testParseEmptyTextm  s    c         C   s2   | j    } d } |  j t j t j | |  d  S(   Ns   repeated_string: "\xc3\xc3"(   R.   t   assertRaisesR
   t
   ParseErrorRL   (   R   R5   R6   R!   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testParseInvalidUtf8s  s    c         C   s8   | j    } d } t j |  t j d t j | |  d  S(   Nt   foos?   1:1 : Message type "\w+.TestAllTypes" has no field named "foo".(   R.   R9   t   assertRaisesRegexR
   Ry   RL   (   R   R5   R6   R!   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testParseSingleWordx  s
    c         C   s8   | j    } d } t j |  t j d t j | |  d  S(   Ns   unknown_field: 8
sI   1:1 : Message type "\w+.TestAllTypes" has no field named "unknown_field".(   R.   R9   R|   R
   Ry   RL   (   R   R5   R6   R!   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testParseUnknownField  s
    c         C   sl   | j    } d } t j |  t j d t j | |  | j    } d } t j |  t j d t j | |  d  S(   Ns   optional_nested_enum: BARRsG   1:23 : Enum type "\w+.TestAllTypes.NestedEnum" has no value named BARR.s   optional_nested_enum: 100sL   1:23 : Enum type "\w+.TestAllTypes.NestedEnum" has no value with number 100.(   R.   R9   R|   R
   Ry   RL   (   R   R5   R6   R!   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testParseBadEnumValue  s    
c         C   s8   | j    } d } t j |  t j d t j | |  d  S(   Ns   optional_int32: borks#   1:17 : Couldn't parse integer: bork(   R.   R9   R|   R
   Ry   RL   (   R   R5   R6   R!   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testParseBadIntValue  s
    c         C   s   | j    } d } t j | |  d } |  j d | j d  |  j | d | d | j d  |  j | d | d	 | j d
  |  j | | d | | d | j d  |  j | | d | | d	 | j d  |  j | d | j d  d  S(   Ns   repeated_string: "\xf\x62"
               repeated_string: "\\xf\\x62"
               repeated_string: "\\\xf\\\x62"
               repeated_string: "\\\\xf\\\\x62"
               repeated_string: "\\\\\xf\\\\\x62"
               repeated_string: "\x5cx20"s   \s   bi    t   xft   x62i   s   t   bi   i   i   t   x20i   (   R.   R
   RL   R   R3   (   R   R5   R6   R!   t   SLASH(    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testParseStringFieldUnescape  s    ##c         C   sK   | j    } d } t j | |  } |  j | |  |  j d | j  d  S(   Ns%   optional_int32: 42 optional_int32: 67iC   (   R.   R
   t   MergeRM   R   t   optional_int32(   R   R5   R6   R!   RP   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testMergeDuplicateScalars  s
    c         C   sQ   | j    } d } t j | |  } |  j | | k  |  j d | j j  d  S(   NsC   optional_nested_message { bb: 1 } optional_nested_message { bb: 2 }i   (   R.   R
   R   t
   assertTrueR   t   optional_nested_messageR?   (   R   R5   R6   R!   RP   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt&   testMergeDuplicateNestedMessageScalars  s
    c         C   sW   | j    } d | _ | j    } t j t j |  |  |  j d | j d   d  S(   Ni   t   oneof_uint32t   oneof_field(   R.   R   R
   RL   R4   R   t
   WhichOneof(   R   R5   t   mt   m2(    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testParseOneof  s
    	c         C   s   d j  d d g  } | j   } | t k r\ |  j t j d   t j | |  Wd  QXn) t j | |  |  j d | j d   d  S(   Ns   
s   oneof_uint32: 11s   oneof_string: "foo"s    is specified along with field t   oneof_stringR   (	   R    R.   R   t   assertRaisesRegexpR
   Ry   RL   R   R   (   R   R5   t   m_stringR   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testParseMultipleOneof  s    
(   R   R   R7   R;   RB   RF   RH   RI   RQ   RR   R\   R_   Rk   Rm   Rq   Rs   Rt   Ru   Rv   Rw   Rz   R}   R~   R   R   R   R   R   R   R   (    (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyR,   d   s8   								
	!																		t    OnlyWorksWithProto2RightNowTestsc           B   sP   e  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 RS(   c         C   sE   t  j   } t j |  |  j |  j t j | d t  d  d  S(   Nt   pointy_bracketss*   text_format_unittest_data_pointy_oneof.txt(	   R   R.   R   Rn   R#   R+   R
   R4   R@   (   R   R6   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testPrintAllFieldsPointy  s    c         C   ss   d j  |  j d   } t j   } t j | |  } |  j | |  t j   } t j |  |  j	 | |  d  S(   Ns   
s/   text_format_unittest_data_oneof_implemented.txt(
   R    R   R   R.   R
   RL   RM   R   Rn   R   (   R   R$   RO   RP   R6   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testParseGolden  s    c         C   s?   t  j   } t j |  |  j |  j t j |   d  d  S(   Ns/   text_format_unittest_data_oneof_implemented.txt(   R   R.   R   Rn   R#   R+   R
   R4   (   R   R6   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testPrintAllFields  s
    c         C   s   t  j   } d | _ d | _ d | _ d | j _ d | j _ |  j |  j	 t
 j | d t  d  |  j |  j	 t
 j |   d  d  S(	   Nt   115ie   io   i    i   t   use_index_ordersW   my_string: "115"
my_int: 101
my_float: 111
optional_nested_message {
  oo: 0
  bb: 1
}
sW   my_int: 101
my_string: "115"
my_float: 111
optional_nested_message {
  bb: 1
  oo: 0
}
(   R   t   TestFieldOrderingst	   my_stringt   my_intt   my_floatR   t   ooR?   R%   R+   R
   R4   R@   (   R   R6   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testPrintInIndexOrder  s    			c         C   sj   |  j  d  } t j   } t j | |  } |  j | |  t j   } t j |  |  j | |  d  S(   Ns/   text_format_unittest_data_oneof_implemented.txt(	   R   R   R.   R
   t
   MergeLinesRM   R   Rn   R   (   R   t   openedRO   RP   R6   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testMergeLinesGolden  s    c         C   sj   |  j  d  } t j   } t j | |  } |  j | |  t j   } t j |  |  j | |  d  S(   Ns/   text_format_unittest_data_oneof_implemented.txt(	   R   R   R.   R
   t
   ParseLinesRM   R   Rn   R   (   R   R   RO   RP   R6   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testParseLinesGolden  s    c         C   sz   t  j   } d | j d <d | j d <d | j d <d | j d <d | j d	 <d
 | j d _ |  j	 t
 j |  d  d  S(   Ni8ii   i"   i!   i  i{   t   123t   abci   io   sH  map_int32_int32 {
  key: -123
  value: -456
}
map_int64_int64 {
  key: -8589934592
  value: -17179869184
}
map_uint32_uint32 {
  key: 123
  value: 456
}
map_uint64_uint64 {
  key: 8589934592
  value: 17179869184
}
map_string_string {
  key: "abc"
  value: "123"
}
map_int32_foreign_message {
  key: 111
  value {
    c: 5
  }
}
I       I    I       I    I       I       (   R   t   TestMapt   map_int32_int32t   map_int64_int64t   map_uint32_uint32t   map_uint64_uint64t   map_string_stringt   map_int32_foreign_messageR^   R%   R
   R4   (   R   R6   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testPrintMap  s    c         C   s   t  j   } x% t j d d !D] } d | j | <q Wx+ t t j d d ! D] } d | j | <qK Wd j d   t j D  } |  j t j	 |  |  d  S(   Ni   i   t   dummyi    R   c         s   s   |  ] } d  | f Vq d S(   s3   map_string_string {
  key: "%c"
  value: "dummy"
}
N(    (   t   .0t   letter(    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pys	   <genexpr>E  s   (
   R   R   t   stringt   ascii_uppercaseR   t   reversedR    R%   R
   R4   (   R   R6   R   t   golden(    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testMapOrderEnforcement?  s    (
   R   R   R   R   R   R   R   R   R   R   (    (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyR     s   					
	
	(t   Proto2Testsc           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   s   t  j   } t  j j } t  j j } d | j j | _ d | j j | _ |  j	 t
 j |  d  t j   } t j } d | j | _ |  j	 t
 j |  d  d  S(   Ni   R{   s   message_set {
  [protobuf_unittest.TestMessageSetExtension1] {
    i: 23
  }
  [protobuf_unittest.TestMessageSetExtension2] {
    str: "foo"
  }
}
t   barsF   [google.protobuf.internal.TestMessageSetExtension3] {
  text: "bar"
}
(   R   t   TestMessageSetContainert   TestMessageSetExtension1t   message_set_extensiont   TestMessageSetExtension2t   message_sett
   Extensionst   iR   R%   R
   R4   R   t   TestMessageSett   message_set_extension3R!   (   R   R6   t   ext1t   ext2t   ext(    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testPrintMessageSet\  s    		c         C   s   t  j t  } t j   } t j j } t j j } d | j j	 | _
 d | j j	 | _ t  j | | d t |  j | j   d  | j   d  S(   Ni   R{   t   use_field_numbers?   1 {
  1545008 {
    15: 23
  }
  1547769 {
    25: "foo"
  }
}
(   R
   Rb   RK   R   R   R   R   R   R   R   R   R   t   PrintMessageR@   R%   Rd   Re   (   R   Ri   R6   R   R   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt    testPrintMessageSetByFieldNumberu  s    c         C   sm   t  j   } t  j j } t  j j } d | j j | _ d | j j | _ |  j	 t
 j | d t d  d  S(   Ni   R{   R<   s   message_set { [protobuf_unittest.TestMessageSetExtension1] { i: 23 } [protobuf_unittest.TestMessageSetExtension2] { str: "foo" } }(   R   R   R   R   R   R   R   R   R   R%   R
   R4   R@   (   R   R6   R   R   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testPrintMessageSetAsOneLine  s    c         C   s   t  j   } d } t j | |  |  j d | j d  |  j d | j d  t j   } d } t j | |  t j j	 } t j
 j	 } |  j d | j j | j  |  j d | j j | j  d  S(   Ns&   repeated_uint64: 1
repeated_uint64: 2
i   i    i   s   message_set {
  [protobuf_unittest.TestMessageSetExtension1] {
    i: 23
  }
  [protobuf_unittest.TestMessageSetExtension2] {
    str: "foo"
  }
}
i   R{   (   R   R.   R
   RL   R   R1   R   R   R   R   R   R   R   R   R   (   R   R6   R!   R   R   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testParseMessageSet  s    c         C   sW   t  j   } d } t j | | d t j   |  j t j | d t j   |  d  S(   Ns   value {
  [type.googleapis.com/google.protobuf.internal.TestAny] {
    [google.protobuf.internal.TestAnyExtension1.extension1] {
      i: 10
    }
  }
}
R	   (   t   test_extend_anyt   TestAnyR
   R   R	   t   DefaultR%   R4   (   R   R6   R!   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testExtensionInsideAnyMessage  s    c      	   C   s6  t  j   } d } t j | | d t |  j d | j d  |  j d | j d  t j   } d } t j | | d t t j	 j
 } t j j
 } |  j d | j j | j  |  j d | j j | j  t  j   } d	 } t j |  t j d
 t j | |  d } t j |  t j d t j | | d t d  S(   Ns   34: 1
repeated_uint64: 2
t   allow_field_numberi   i    i   s?   1 {
  1545008 {
    15: 23
  }
  1547769 {
    25: "foo"
  }
}
i   R{   s   34:1
s>   1:1 : Message type "\w+.TestAllTypes" has no field named "34".s   1234:1
s@   1:1 : Message type "\w+.TestAllTypes" has no field named "1234".(   R   R.   R
   RL   R@   R   R1   R   R   R   R   R   R   R   R   R   R9   R|   Ry   (   R   R6   R!   R   R   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testParseMessageByFieldNumber  s4    c         C   s?   t  j   } t j |  |  j |  j t j |   d  d  S(   Ns(   text_format_unittest_extensions_data.txt(   R   t   TestAllExtensionsR   t   SetAllExtensionsR#   R+   R
   R4   (   R   R6   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testPrintAllExtensions  s
    c         C   sE   t  j   } t j |  |  j |  j t j | d t  d  d  S(   NR   s/   text_format_unittest_extensions_data_pointy.txt(	   R   R   R   R   R#   R+   R
   R4   R@   (   R   R6   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testPrintAllExtensionsPointy  s    c         C   sa   d j  |  j d   } t j   } t j | |  t j   } t j |  |  j | |  d  S(   Ns   
s(   text_format_unittest_extensions_data.txt(	   R    R   R   R   R
   RL   R   R   R   (   R   R$   RO   R6   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testParseGoldenExtensions  s    c         C   sX   t  j   } t j |  t j |  } t  j   } t j | |  |  j | |  d  S(   N(   R   R   R   R   R
   R4   RL   R   (   R   R6   Rp   RO   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testParseAllExtensions  s    c      	   C   s  t  j   } d } t j | | d t d } |  j t j |  |  t  j   } d } t j |  t j	 d t j | | d t t  j   } d } t j |  t j	 d t j | | d t t  j   } d } t j |  t j	 d t j | | d t t  j   } d	 } t j |  t j	 d
 t j | | d t t  j   } d } t j |  t j	 d t j | | d t t  j   } d } t j | | d t t  j
 j } t  j j } |  j d | j j | j  |  j d | j j | j  d  S(   Ns  message_set {
  [unknown_extension] {
    i: 23
    bin: ""    [nested_unknown_ext]: {
      i: 23
      test: "test_string"
      floaty_float: -0.315
      num: -inf
      multiline_str: "abc"
          "def"
          "xyz."
      [nested_unknown_ext]: <
        i: 23
        i: 24
        pointfloat: .3
        test: "test_string"
        floaty_float: -0.315
        num: -inf
        long_string: "test" "test2" 
      >
    }
  }
  [unknown_extension]: 5
}
t   allow_unknown_extensions   message_set {
}
s3   message_set {
  [unknown_extension] {
    i:
  }
}
s   Invalid field value: }sG   message_set {
  [unknown_extension] {
    str: "malformed string
  }
}
s   Invalid field value: "sS   message_set {
  [unknown_extension] {
    str: "malformed
 multiline
 string
  }
}
s7   message_set {
  [malformed_extension] <
    i: -5
  
}
s   5:1 : Expected ">".s)   message_set {
  unknown_field: true
  
}
sb   2:3 : Message type "proto2_wireformat_unittest.TestMessageSet" has no field named "unknown_field".s   message_set {
  [protobuf_unittest.TestMessageSetExtension1] {
    i: 23
  }
  [protobuf_unittest.TestMessageSetExtension2] {
    str: "foo"
  }
}
i   R{   (   R   R   R
   RL   R@   R%   R4   R9   R|   Ry   R   R   R   R   R   R   R   R   (   R   R6   R!   R   t	   malformedR   R   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt    testParseAllowedUnknownExtension  sr    					c         C   sf   t  j   } d } t j |  t j d t j | |  t  j   } t j |  t j d t j | |  d  S(   Ns   [unknown_extension]: 8
s3   1:2 : Extension "unknown_extension" not registered.sM   1:2 : Message type "protobuf_unittest.TestAllTypes" does not have extensions.(   R   R   R9   R|   R
   Ry   RL   R.   (   R   R6   R!   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testParseBadExtension  s    c         C   s@   t  j   } d } t j | |  |  j d | j t  j  d  S(   Nsa   [protobuf_unittest.optional_int32_extension]: 42 [protobuf_unittest.optional_int32_extension]: 67iC   (   R   R   R
   R   R   R   t   optional_int32_extension(   R   R6   R!   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt"   testMergeDuplicateExtensionScalars  s
    	c         C   s8   t  j   } d } t j |  t j d t j | |  d  S(   Nsa   [protobuf_unittest.optional_int32_extension]: 42 [protobuf_unittest.optional_int32_extension]: 67s   1:96 : Message type "protobuf_unittest.TestAllExtensions" should not have multiple "protobuf_unittest.optional_int32_extension" extensions.(   R   R   R9   R|   R
   Ry   RL   (   R   R6   R!   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt"   testParseDuplicateExtensionScalars  s
    c         C   s8   t  j   } d } t j |  t j d t j | |  d  S(   NsC   optional_nested_message { bb: 1 } optional_nested_message { bb: 2 }sh   1:65 : Message type "protobuf_unittest.TestAllTypes.NestedMessage" should not have multiple "bb" fields.(   R   R.   R9   R|   R
   Ry   RL   (   R   R6   R!   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt&   testParseDuplicateNestedMessageScalars  s    	c         C   s8   t  j   } d } t j |  t j d t j | |  d  S(   Ns%   optional_int32: 42 optional_int32: 67sf   1:36 : Message type "protobuf_unittest.TestAllTypes" should not have multiple "optional_int32" fields.(   R   R.   R9   R|   R
   Ry   RL   (   R   R6   R!   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testParseDuplicateScalars  s    	c         C   s`   t  j   } d } t j |  t j d t j | |  d } t j |  t j d t j | |  d  S(   Ns   RepeatedGroup: <s   1:16 : Expected ">".s   RepeatedGroup: {s   1:16 : Expected "}".(   R   R.   R9   R|   R
   Ry   RL   (   R   R6   R!   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testParseGroupNotClosed  s    c         C   s~   t  j   } d } t j | |  |  j | j d   | j   t  j   } d } t j | |  |  j | j d   d  S(   Ns   OptionalGroup: {}t   optionalgroups   OptionalGroup: <>(   R   R.   R
   RL   R   t   HasFieldt   Clear(   R   R6   R!   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testParseEmptyGroup  s    
c         C   s   d } t  j   } t j | |  |  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  S(   NsH  map_int32_int32 {
  key: -123
  value: -456
}
map_int64_int64 {
  key: -8589934592
  value: -17179869184
}
map_uint32_uint32 {
  key: 123
  value: 456
}
map_uint64_uint64 {
  key: 8589934592
  value: 17179869184
}
map_string_string {
  key: "abc"
  value: "123"
}
map_int32_foreign_message {
  key: 111
  value {
    c: 5
  }
}
i8ii   i"   i!   i  i{   R   R   i   io   I       I    I       I    I       I       (   R   R   R
   RL   R   R   R   R   R   R   R   R^   (   R   R!   R6   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testParseMap  s    (   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   (    (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyR   Z  s&   						)			
			y			
						t   Proto3Testsc           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 RS(   c         C   sZ   t  j   } d | _ t j   } | j j |  |  j t j	 | d t
 j   d  d  S(   NR   R	   s[   any_value {
  [type.googleapis.com/protobuf_unittest.OneString] {
    data: "string"
  }
}
(   R   t	   OneStringt   dataR   R   t	   any_valuet   PackR   R
   R4   R	   R   (   R   t   packed_messageR6   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testPrintMessageExpandAny  s    	c         C   s   t  j   } t j   } d | _ | j j   j |  d | _ | j j   j |  |  j t	 j
 | d t j   d  d  S(   Nt   string0t   string1R	   s   repeated_any_value {
  [type.googleapis.com/protobuf_unittest.OneString] {
    data: "string0"
  }
}
repeated_any_value {
  [type.googleapis.com/protobuf_unittest.OneString] {
    data: "string1"
  }
}
(   R   R   R   R   R   t   repeated_any_valueR>   R   R   R
   R4   R	   R   (   R   R   R6   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt!   testPrintMessageExpandAnyRepeated  s    		c         C   sT   t  j   } d | _ t j   } | j j |  |  j t j	 | d d  d  d  S(   NR   R	   sd   any_value {
  type_url: "type.googleapis.com/protobuf_unittest.OneString"
  value: "\n\006string"
}
(   R   R   R   R   R   R   R   R   R
   R4   t   None(   R   R   R6   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt)   testPrintMessageExpandAnyNoDescriptorPool  s    	c         C   s`   t  j   } d | _ t j   } | j j |  t j   } |  j	 t
 j | d | d  d  S(   NR   R	   sd   any_value {
  type_url: "type.googleapis.com/protobuf_unittest.OneString"
  value: "\n\006string"
}
(   R   R   R   R   R   R   R   R	   t   DescriptorPoolR   R
   R4   (   R   R   R6   t
   empty_pool(    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt2   testPrintMessageExpandAnyDescriptorPoolMissingType  s    	c         C   s`   t  j   } d | _ t j   } | j j |  |  j t j	 | d t
 d t j   d  d  S(   NR   R   R	   s[   any_value <
  [type.googleapis.com/protobuf_unittest.OneString] <
    data: "string"
  >
>
(   R   R   R   R   R   R   R   R   R
   R4   R@   R	   R   (   R   R   R6   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt'   testPrintMessageExpandAnyPointyBrackets+  s    	c         C   s`   t  j   } d | _ t j   } | j j |  |  j t j	 | d t
 d t j   d  d  S(   NR   R<   R	   sR   any_value { [type.googleapis.com/protobuf_unittest.OneString] { data: "string" } }(   R   R   R   R   R   R   R   R   R
   R4   R@   R	   R   (   R   R   R6   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt"   testPrintMessageExpandAnyAsOneLine:  s    	c      	   C   sf   t  j   } d | _ t j   } | j j |  |  j t j	 | d t
 d t
 d t j   d  d  S(   NR   R<   R   R	   sR   any_value < [type.googleapis.com/protobuf_unittest.OneString] < data: "string" > >(   R   R   R   R   R   R   R   R   R
   R4   R@   R	   R   (   R   R   R6   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt0   testPrintMessageExpandAnyAsOneLinePointyBracketsH  s    	c         C   sa   t  j   } d } t j | | d t j   t j   } | j j	 |  |  j
 d | j  d  S(   Ns[   any_value {
  [type.googleapis.com/protobuf_unittest.OneString] {
    data: "string"
  }
}
R	   R   (   R   R   R
   R   R	   R   R   R   R   t   UnpackR   R   (   R   R6   R!   R   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testMergeExpandedAnyW  s    c         C   s   t  j   } d } t j | | d t j   t j   } | j d j	 |  |  j
 d | j  | j d j	 |  |  j
 d | j  d  S(   Ns   repeated_any_value {
  [type.googleapis.com/protobuf_unittest.OneString] {
    data: "string0"
  }
}
repeated_any_value {
  [type.googleapis.com/protobuf_unittest.OneString] {
    data: "string1"
  }
}
R	   i    R   i   R   (   R   R   R
   R   R	   R   R   R   R   R   R   R   (   R   R6   R!   R   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testMergeExpandedAnyRepeatedc  s    
c         C   sa   t  j   } d } t j | | d t j   t j   } | j j	 |  |  j
 d | j  d  S(   Ns[   any_value {
  [type.googleapis.com/protobuf_unittest.OneString] <
    data: "string"
  >
}
R	   R   (   R   R   R
   R   R	   R   R   R   R   R   R   R   (   R   R6   R!   R   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt"   testMergeExpandedAnyPointyBracketsv  s    c      	   C   s`   t  j   } d } |  j t j   } t j | | d d  Wd  QX|  j t | j	  d  d  S(   Ns[   any_value {
  [type.googleapis.com/protobuf_unittest.OneString] {
    data: "string"
  }
}
R	   s4   Descriptor pool required to parse expanded Any field(
   R   R   Rx   R
   Ry   R   R   R   R   t	   exception(   R   R6   R!   t   e(    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt$   testMergeExpandedAnyNoDescriptorPool  s    c      	   C   sl   t  j   } d } |  j t j  ) } t j   } t j | | d | Wd  QX|  j t	 | j
  d  d  S(   Ns[   any_value {
  [type.googleapis.com/protobuf_unittest.OneString] {
    data: "string"
  }
}
R	   s=   Type protobuf_unittest.OneString not found in descriptor pool(   R   R   Rx   R
   Ry   R	   R   R   R   R   R  (   R   R6   R!   R  R   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt-   testMergeExpandedAnyDescriptorPoolMissingType  s    c         C   sU   d } t  j   } t j | |  t j   } | j j |  |  j d | j	  d  S(   Nsd   any_value {
  type_url: "type.googleapis.com/protobuf_unittest.OneString"
  value: "\n\006string"
}
R   (
   R   R   R
   R   R   R   R   R   R   R   (   R   R!   R6   R   (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testMergeUnexpandedAny  s    (   R   R   R   R   R   R   R   R   R   R   R   R   R  R  R  (    (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyR     s   												t   TokenizerTestc           B   sY   e  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 RS(	   c      J   C   s1  d } t  j | j    } | j d f d | j d f | j d f d | j d f | j d f d | j d f | j d	 f d | j d
 f | j d f d | j d f | j d f d | j d f | j d f d | j d f | j d f d d | j d f d | j t d  f | j d f d | j t d  f | j d f d | j t	 f | j d f d | j t
 f d | j d f d | j d f | j d f d | j d f | j d f d | j d f | j d f d | j d  f | j d! f d | j d" f | j d# f d | j d$ f | j d% f d | j t
 f | j d& f d | j t	 f | j d' f d | j t	 f | j d( f d | j t
 f | j d) f d | j t
 f | j d* f d | j t	 f gI } d+ } xt | j   s,| | } t | t  r| j } |  j | |  | j   n |  j | d, | d+    | d, 7} qWd  S(-   Nsq  identifier1:"string1"
     

identifier2 : 
 
123  
  identifier3 :'string'
identifiER_4 : 1.1e+2 ID5:-0.23 ID6:'aaaa\'bbbb'
ID7 : "aa\"bb"



 ID8: {A:inf B:-inf C:true D:false}
ID9: 22 ID10: -111111111111111111 ID11: -22
ID12: 2222222222222222222 ID13: 1.23456f ID14: 1.2e+2f false_bool:  0 true_BOOL:t 
 true_bool1:  1 false_BOOL1:f False_bool: False True_bool: Truet   identifier1t   :R   t   identifier2i{   t   identifier3R   t   identifiER_4g     [@t   ID5gq=
ףpͿt   ID6s	   aaaa'bbbbt   ID7s   aa"bbt   ID8t   {t   At   inft   Bt   Ct   Dt   }t   ID9i   t   ID10I9{Aut   ID11it   ID12IWVt   ID13g82?t   ID14g      ^@t
   false_boolt	   true_BOOLt
   true_bool1t   false_BOOL1t
   False_boolt	   True_booli    i   (   R
   t	   Tokenizert
   splitlinest   ConsumeIdentifiert   ConsumeStringt   ConsumeIntegert   ConsumeFloatt   floatt   ConsumeBoolR@   RK   t   AtEndt
   isinstanceR   t   tokenR   t	   NextToken(   R   R!   t	   tokenizert   methodsR   R   R-  (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testSimpleTokenCases  st    
	c         C   s   d	 } d } d | d | d f } t  j | j    } |  j d | j    |  j | d | j    |  j | d | j    |  j | j    d } t  j | j    } |  j d | j    |  j d | j    |  j | j    d  S(   Ni   i?   i    s   -1 %d %dis   -0 0i    l            l    I       I    (   R
   R#  R$  R   R'  R   R+  (   R   t	   int64_maxt
   uint32_maxR!   R/  (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testConsumeAbstractIntegers  s    c         C   s  d	 } d } d | d | d f } t  j | j    } |  j t  j t  j |  |  j t  j t  j |  |  j d t  j |   |  j t  j t  j |  |  j t  j t  j |  |  j | d t  j	 |   |  j t  j t  j	 |  |  j | d t  j |   |  j
 | j    d } t  j | j    } |  j d t  j |   |  j d t  j |   |  j d t  j |   |  j d t  j |   |  j
 | j    d  S(   Ni   i?   i    s   -1 %d %dis	   -0 -0 0 0i    l            l    I       I    (   R
   R#  R$  Rx   Ry   t   _ConsumeUint32t   _ConsumeUint64R   t   _ConsumeInt32t   _ConsumeInt64R   R+  (   R   R2  R3  R!   R/  (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testConsumeIntegers  s2    c         C   s   d } t  j | j    } |  j t  j | j  d } t  j | j    } |  j t  j | j  d } t  j | j    } |  j t  j | j  d } t  j | j    } |  j t  j | j  d } t  j | j    } |  j t  j | j  d  S(   Ns	   "string1's   string1"s   
"\xt"s   
"\"s   
"\x"(   R
   R#  R$  Rx   Ry   t   ConsumeByteString(   R   R!   R/  (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testConsumeByteString#  s    c         C   s5   d } t  j | j    } |  j t  j | j  d  S(   Ns
   not-a-bool(   R
   R#  R$  Rx   Ry   R*  (   R   R!   R/  (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testConsumeBool8  s    c         C   sB   t  j d j    } |  j | j    |  j t  j | j  d  S(   Ns   # some comment(   R
   R#  R$  R   R+  Rx   Ry   t   ConsumeComment(   R   R/  (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testSkipComment=  s    c         C   s[   t  j d j   d t } |  j | j    |  j d | j    |  j | j    d  S(   Ns   # some commentt   skip_comments(	   R
   R#  R$  RK   t   assertFalseR+  R   R=  R   (   R   R/  (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testConsumeCommentB  s
    	c         C   sw   d } t  j | j   d t } |  j d | j    |  j | j    |  j d | j    |  j | j    d  S(   Ns    # some comment
# another commentR?  s   # some comments   # another comment(	   R
   R#  R$  RK   R   R=  R@  R+  R   (   R   R!   R/  (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testConsumeTwoCommentsI  s    c         C   s   d } t  j | j   d t } |  j t  j | j  |  j d | j    |  j | j	 d  | j
   |  j t  j | j  |  j d | j    |  j | j    |  j d | j    |  j | j    d  S(   Ns   some_number: 4
# some commentR?  t   some_numberR  i   s   # some comment(   R
   R#  R$  RK   Rx   Ry   R=  R   R%  R-  R.  R'  R@  R+  R   (   R   R!   R/  (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   testConsumeTrailingCommentQ  s    
(   R   R   R1  R4  R9  R;  R<  R>  RA  RB  RD  (    (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyR    s   	E		 					t   __main__(!   t   __doc__t
   __author__R'   R9   R   t	   unittest2t   unittestt   ImportErrort   google.protobuf.internalR    t   google.protobufR   R   R   R   R   R   R   R   R   R	   R
   t   TestCaseR   R   t
   ParametersR,   R   R   R   R  R   t   main(    (    (    sK   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/text_format_test.pyt   <module>!   s@    r 