<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>

hc           @   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 e j f d     YZ d e f d     YZ e d k rXe j   n  d S(   s%   Test for google.protobuf.json_format.s   jieluo@google.com (Jie Luo)iN(   t   any_pb2(   t   duration_pb2(   t   field_mask_pb2(   t
   struct_pb2(   t   timestamp_pb2(   t   wrappers_pb2(   t   unittest_mset_pb2(   t   unittest_pb2(   t   well_known_types(   t   json_format(   t   json_format_proto3_pb2t   JsonFormatBasec           B   s#   e  Z d    Z d   Z d   Z RS(   c         C   s  d | _  d | _ d | _ d | _ t d  | _ d | _ t | _ d | _	 d | _
 d	 | j _ t j | _ | j j d
  | j j d  | j j d  | j j d  | j j d  | j j d  | j j d  | j j d  | j j d  | j j d  | j j t d   | j j t  | j j t  | j j d  | j j d  | j j d  | j j d  d	 | j j   _ d | j j   _ | j j t j  | j j t j  | |  _ d  S(   Ni   il   ~t l   4? s   -infgo!	@t   foot   bari
   ii   l          l       iil    i    gV瞯<t   infs   Few symbols!#$,;i   (    t   int32_valuet   int64_valuet   uint32_valuet   uint64_valuet   floatt   float_valuet   double_valuet   Truet
   bool_valuet   string_valuet   bytes_valuet   message_valuet   valueR
   t   BARt
   enum_valuet   repeated_int32_valuet   appendt   repeated_int64_valuet   repeated_uint32_valuet   repeated_uint64_valuet   repeated_float_valuet   repeated_double_valuet   repeated_bool_valuet   Falset   repeated_string_valuet   repeated_bytes_valuet   repeated_message_valuet   addt   repeated_enum_valuet   FOOt   message(   t   selfR-   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   FillAllFields<   sB    								c         C   s-   t  j t  j |  |  |  j | |  d  S(   N(   R	   t   Parset   MessageToJsont   assertEqual(   R.   R-   t   parsed_message(    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   CheckParseBacka   s    c         C   s/   t  j   } |  j t j | t j | |  d  S(   N(   R
   t   TestMessaget   assertRaisesRegexpR	   t
   ParseErrorR0   (   R.   t   textt   error_messageR-   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt
   CheckErrorf   s
    (   t   __name__t
   __module__R/   R4   R:   (    (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyR   :   s   	%	t   JsonFormatTestc           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 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.   Z0 d/   Z1 RS(0   c         C   sE   t  j   } |  j t j |  d  t  j   } |  j | |  d  S(   Ns   {}(   R
   R5   R2   R	   R1   R4   (   R.   R-   R3   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testEmptyMessageToJsonp   s
    c         C   si   t  j d d d d d g  } |  j t j t j |   t j d   t  j   } |  j | |  d  S(   NR   t   testR   iY   i   s6   {"stringValue": "test", "repeatedInt32Value": [89, 4]}(   R
   R5   R2   t   jsont   loadsR	   R1   R4   (   R.   R-   R3   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testPartialMessageToJsonw   s    	c         C   sz   t  j   } d } |  j |  |  j t j t j |   t j |   t  j   } t j | |  |  j | |  d  S(   Ns  {"int32Value": 20, "int64Value": "-20", "uint32Value": 3120987654,"uint64Value": "12345678900","floatValue": "-Infinity","doubleValue": 3.1415,"boolValue": true,"stringValue": "foo","bytesValue": "YmFy","messageValue": {"value": 10},"enumValue": "BAR","repeatedInt32Value": [2147483647, -2147483648],"repeatedInt64Value": ["9007199254740992", "-9007199254740992"],"repeatedUint32Value": [268435455, 134217727],"repeatedUint64Value": ["9007199254740992", "9007199254740991"],"repeatedFloatValue": [0],"repeatedDoubleValue": [1e-15, "Infinity"],"repeatedBoolValue": [true, false],"repeatedStringValue": ["Few symbols!#$,;", "bar"],"repeatedBytesValue": ["Zm9v", "YmFy"],"repeatedMessageValue": [{"value": 10}, {"value": 11}],"repeatedEnumValue": ["FOO", "BAR"]}(	   R
   R5   R/   R2   R@   RA   R	   R1   R0   (   R.   R-   R8   R3   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testAllFieldsToJson   s    c         C   sd   d } t  j   } d | _ |  j t j |  |  t  j   } t j | |  |  j | |  d  S(   Ns   {
  "enumValue": 999
}i  (   R
   R5   R   R2   R	   R1   R0   (   R.   R8   R-   R3   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testUnknownEnumToJsonAndBack   s    	c         C   s   t  j   } t  j j } t  j j } d | j j | _ d | j j | _ t	 j
 |  } t  j   } t	 j | |  |  j | |  d  S(   Ni   R   (   R   t   TestMessageSetContainert   TestMessageSetExtension1t   message_set_extensiont   TestMessageSetExtension2t   message_sett
   Extensionst   it   strR	   R1   R0   R2   (   R.   R-   t   ext1t   ext2t   message_textR3   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testExtensionToJsonAndBack   s    	c         C   s   |  j  d d  d  S(   Ns   {"[extensionField]": {}}s8   Message type proto3.TestMessage does not have extensions(   R:   (   R.   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testExtensionErrors   s    	c         C   s   t  j   } t  j j } t  j j } d | j j | _ d | j j | _ t	 j
 |  } t  j   } t	 j | |  |  j | |  d  S(   Ni   R   (   R   RE   RF   RG   RH   RI   RJ   RK   RL   R	   t   MessageToDictt	   ParseDictR2   (   R.   R-   RM   RN   t   message_dictR3   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testExtensionToDictAndBack   s    	c         C   s   t  j   } t  j j } t  j j } d | j j | _ d | j j | _ t	 j
 |  } i i i d d 6d 6i d d 6d 6d 6} |  j | |  d	 S(
   s&   See go/proto3-json-spec for spec.
    i   R   RK   s@   [protobuf_unittest.TestMessageSetExtension1.messageSetExtension]u   fooRL   s@   [protobuf_unittest.TestMessageSetExtension2.messageSetExtension]t
   messageSetN(   R   RE   RF   RG   RH   RI   RJ   RK   RL   R	   RR   R2   (   R.   R-   RM   RN   RT   t   golden_dict(    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt/   testExtensionSerializationDictMatchesProto3Spec   s    	c         C   s   t  j   } t  j j } t  j j } d | j j | _ d | j j | _ t	 j
 |  } d } d } d | | f } |  j t j |  t j |   d S(   s&   See go/proto3-json-spec for spec.
    i   R   s>   protobuf_unittest.TestMessageSetExtension1.messageSetExtensions>   protobuf_unittest.TestMessageSetExtension2.messageSetExtensionsZ   {"messageSet": {    "[%s]": {        "i": 23    },    "[%s]": {        "str": "foo"    }}}N(   R   RE   RF   RG   RH   RI   RJ   RK   RL   R	   R1   R2   R@   RA   (   R.   R-   RM   RN   RO   t	   ext1_textt	   ext2_textt   golden_text(    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt/   testExtensionSerializationJsonMatchesProto3Spec   s    	c         C   s   t  j   } t j d d k  r+ d | _ n! d | _ | j d j d  7_ |  j t j |  d  t  j   } |  j	 | |  d } t j
 | |  |  j | j d	  d  S(
   Ni    i   s   &
<">	\/  s   &
<">	\/s     s   utf-8s;   {
  "stringValue": "&\n<\"\r>\b\t\f\\\u0001/\u2028\u2029"
}u   {"int32Value": "1"}i   (   R
   R5   t   syst   version_infoR   t   decodeR2   R	   R1   R4   R0   R   (   R.   R-   R3   R8   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testJsonEscapeString   s    	c         C   s`   t  j d d  } |  j t j t j | t   t j d   t  j   } |  j | |  d  S(   NR   R   s  {"repeatedStringValue": [],"stringValue": "foo","repeatedBoolValue": [],"repeatedUint32Value": [],"repeatedInt32Value": [],"enumValue": "FOO","int32Value": 0,"floatValue": 0,"int64Value": "0","uint32Value": 0,"repeatedBytesValue": [],"repeatedUint64Value": [],"repeatedDoubleValue": [],"bytesValue": "","boolValue": false,"repeatedEnumValue": [],"uint64Value": "0","doubleValue": 0,"repeatedFloatValue": [],"repeatedInt64Value": [],"repeatedMessageValue": []}(	   R
   R5   R2   R@   RA   R	   R1   R   R4   (   R.   R-   R3   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testAlwaysSeriliaze  s    		c         C   sy   t  j   } t j d |  |  j | j d  t j d |  |  j | j d  t j d |  |  j | j d  d  S(   Ns   {"int32Value": -2.147483648e9}i   s   {"int32Value": 1e5}i s   {"int32Value": 1.0}i   (   R
   R5   R	   R0   R2   R   (   R.   R-   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testIntegersRepresentedAsFloat-  s    c         C   s8  t  j   } |  j t j t j | t   t j d   d | j t <d | j t	 <d | j
 d <d | j
 d <d | j d <d | j d <d | j d <d | j d <d | j d <d | j d <d | j d <d | j d <d | j d j t <|  j t j t j | t	   t j d   t  j   } |  j | |  d  S(   Nsj   {"boolMap": {},"int32Map": {},"int64Map": {},"uint32Map": {},"uint64Map": {},"stringMap": {},"mapMap": {}}i   i   i   t   1t   nulls   {"boolMap": {"false": 2, "true": 1},"int32Map": {"1": 2, "2": 3},"int64Map": {"1": 2, "2": 3},"uint32Map": {"1": 2, "2": 3},"uint64Map": {"1": 2, "2": 3},"stringMap": {"1": 2, "null": 3},"mapMap": {"1": {"boolMap": {"true": 3}}}}(   R
   t   TestNestedMapR2   R@   RA   R	   R1   R   t   bool_mapR&   t	   int32_mapt	   int64_mapt
   uint32_mapt
   uint64_mapt
   string_mapt   map_mapR4   (   R.   R-   R3   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testMapFields6  s,    		c         C   sm   t  j   } |  j t j | t  d  d | _ |  j t j | t  d  t  j   } |  j | |  d  S(   Ns   {}i    s   {
  "oneofInt32Value": 0
}(   R
   t	   TestOneofR2   R	   R1   R   t   oneof_int32_valueR4   (   R.   R-   R3   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testOneofFields^  s    	c         C   s_   t  j   } t j d |  |  j | j d j d d   |  j d d  |  j d d  d  S(   Ns   {"stringValue": "\uD83D\uDE01"}s   😁s   utf-8t   stricts   {"stringValue": "\uD83D"}s*   Invalid \\uXXXX escape|Unpaired.*surrogates   {"stringValue": "\uDE01"}(   R
   R5   R	   R0   R2   R   R_   R:   (   R.   R-   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testSurrogatesm  s    c         C   s  t  j   } d | j _ d | j _ d | j j   _ d | j d _ d | j j   _ d | j d _ d | j j   _ d | j d _ d | j j   _ d | j d	 _ d
 | j j   _ d | j d _ |  j t j	 t
 j | t   t j	 d   t  j   } |  j | |  d } t
 j | |  |  j | j j d  |  j | j j d  |  j | j d j d  |  j | j d j d d  d  S(   Ni    i   i   i'  i i   l   A iɚ;i   l w#o9 i   s   {"value": "1970-01-01T00:00:00Z","repeatedValue": [  "1970-01-01T00:00:20.000000001Z",  "1970-01-01T00:00:00.000010Z",  "1973-03-03T09:46:40Z",  "9999-12-31T23:59:59.999999999Z",  "0001-01-01T00:00:00Z"]}s}   {"value": "1970-01-01T00:00:00.01+08:00","repeatedValue":[  "1970-01-01T00:00:00.01+08:30",  "1970-01-01T00:00:00.01-01:23"]}ii  i g      !i   i<   ig     id  (   R
   t   TestTimestampR   t   secondst   nanost   repeated_valueR*   R2   R@   RA   R	   R1   R   R4   R0   (   R.   R-   R3   R8   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testTimestampMessage~  s0    
c         C   s   t  j   } d | j _ d | j j   _ d | j d _ d | j j   _ d | j d _ d | j j   _ d | j d _ d | j j   _ d	 | j j   _ |  j t j	 t
 j | t   t j	 d
   t  j   } |  j | |  d  S(   Ni   i    i
   iiiا i   l s%l    s%ss   {"value": "1s","repeatedValue": [  "0.000000010s",  "-1.000001s",  "10.011s",  "-315576000000s",  "315576000000s"]}(   R
   t   TestDurationR   Rt   Rv   R*   Ru   R2   R@   RA   R	   R1   R   R4   (   R.   R-   R3   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testDurationMessage  s    
c         C   sn   t  j   } | j j j d  | j j j d  |  j t j | t  d  t  j   } |  j	 | |  d  S(   Ns   foo.barR   s   {
  "value": "foo.bar,bar"
}(
   R
   t   TestFieldMaskR   t   pathsR   R2   R	   R1   R   R4   (   R.   R-   R3   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testFieldMaskMessage  s    c         C   s   t  j   } t | j _ d | j _ d | j _ d | j _ t | j	 j
   _ t | j	 j
   _ | j j
   |  j t j t j | t   t j d   t  j   } |  j | |  d  S(   Ni    t    sR  {
  "int32Value": 0,  "boolValue": false,  "stringValue": "",  "bytesValue": "",  "repeatedBoolValue": [true, false],  "repeatedInt32Value": [0],  "repeatedUint32Value": [],  "repeatedFloatValue": [],  "repeatedDoubleValue": [],  "repeatedBytesValue": [],  "repeatedInt64Value": [],  "repeatedUint64Value": [],  "repeatedStringValue": []}(   R
   t   TestWrapperR&   R   R   R   R   R   R   R%   R*   R   R2   R@   RA   R	   R1   R4   (   R.   R-   R3   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testWrapperMessage  s    c         C   s  t  j   } d | j d <d | j d <t | j d <d  | j d <d | j j d  d	 <d
 | j d d <| j j d  } | j d d t t d  g  d | j	   d <d | j
 j   d <| j
 j   |  j t j t j | t   t j d   t  j   } |  j | |  d  S(   Nt   Jimt   namei
   t   aget   attendt   emailt   SFOt   addresst   cityi   t   house_numbert   listi   t   seveni	   t   subkey2i   s   {  "value": {    "address": {      "city": "SFO",       "house_number": 1024    },     "age": 10,     "name": "Jim",     "attend": true,     "email": null,     "list": [6, "seven", true, false, null, {"subkey2": 9}]  },  "repeatedValue": [{"age": 11}, {}]}(   R
   t
   TestStructR   R   t   Nonet   get_or_create_structt   get_or_create_listt   extendR&   t
   add_structRv   R*   R2   R@   RA   R	   R1   R4   (   R.   R-   t   struct_listR3   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testStructMessage  s$    
c         C   s  t  j   } d | j _ d | j j   _ t | j j   _ d | j j   _	 |  j
 t j t j | t   t j d   t  j   } |  j | |  | j j   |  j
 t j t j | t   t j d   | j   t j d |  |  j
 | j j d  d  d  S(	   Nt   hellog333333&@i    s;   {  "value": "hello",  "repeatedValue": [11.1, false, null]}sA   {  "value": "hello",  "repeatedValue": [11.1, false, null, null]}s   {"value": null}t   kindt
   null_value(   R
   t	   TestValueR   R   Rv   R*   t   number_valueR&   R   R   R2   R@   RA   R	   R1   R4   t   ClearR0   t
   WhichOneof(   R.   R-   R3   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testValueMessage
  s&    


c         C   s   t  j   } d | j j j   _ d | j j j   _ t | j j j   _ d | j j j   _	 d | j j j   j
 d <d | j j   j j   _ | j j   |  j t j t j | t   t j d   t  j   } |  j | |  d  S(   Ng333333&@i    R   R   R   i   sS   {"value": [11.1, null, true, "hello", {"name": "Jim"}]
,"repeatedValue": [[1], []]}(   R
   t   TestListValueR   t   valuesR*   R   R   R   R   R   t   struct_valueRv   R2   R@   RA   R	   R1   R&   R4   (   R.   R-   R3   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testListValueMessage&  s    
c         C   s@  t  j   } t  j   } t  j   } d | _ d | _ | j j |  | j j   j |  | j j   j |  | j j   |  j t j	 t
 j | t   t j	 d   t  j   } |  j | |  t  j d t d d d d d	 d d
 d d d d d  } | j   | j j |  |  j t
 j | t  d d !d  d  S(   Ni  i.  s  {
  "repeatedValue": [ {
    "@type": "type.googleapis.com/proto3.MessageType",
    "value": 1234
  }, {
    "@type": "type.googleapis.com/proto3.MessageType",
    "value": 5678
  },
  {}],
  "value": {
    "@type": "type.googleapis.com/proto3.MessageType",
    "value": 1234
  }
}
R   R   i   R   iR   R   R   gQ	@R   R   i    iD   sD   {
  "value": {
    "@type": "type.googleapis.com/proto3.TestMessage"(   R
   t   TestAnyt   MessageTypeR   t   PackRv   R*   R2   R@   RA   R	   R1   R   R4   R5   R   R&   (   R.   R-   t   value1t   value2R3   t   test_message(    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testAnyMessage7  s8    		
		
c   	      C   sx  t  j   } t j   } d | _ | j |  |  j t j t	 j
 | t   t j d   t  j   } |  j | |  t j   } | j |  |  j t j t	 j
 | t   t j d   |  j | |  t j   } d | _ | j |  |  j t j t	 j
 | t   t j d   |  j | |  t j   } | j j d  | j j d  | j |  |  j t j t	 j
 | t   t j d   |  j | |  t j   } d	 | d
 <| j |  |  j t j t	 j
 | t   t j d   |  j | |  t  j   } d | _ | j |  | j |  |  j t j t	 j
 | t   t j d   |  j | |  d  S(   Ni  sQ   {
  "@type": "type.googleapis.com/google.protobuf.Int32Value",
  "value": 1234
}
sb   {
  "@type": "type.googleapis.com/google.protobuf.Timestamp",
  "value": "1970-01-01T00:00:00Z"
}
i   sO   {
  "@type": "type.googleapis.com/google.protobuf.Duration",
  "value": "1s"
}
s   foo.barR   sY   {
  "@type": "type.googleapis.com/google.protobuf.FieldMask",
  "value": "foo.bar,bar"
}
R   R   sX   {
  "@type": "type.googleapis.com/google.protobuf.Struct",
  "value": {"name": "Jim"}
}
i.  s   {
  "@type": "type.googleapis.com/google.protobuf.Any",
  "value": {
    "@type": "type.googleapis.com/google.protobuf.Int32Value",
    "value": 5678
  }
}
(   R    t   AnyR   t
   Int32ValueR   R   R2   R@   RA   R	   R1   R   R4   R   t	   TimestampR   t   DurationRt   R   t	   FieldMaskR{   R   R   t   Struct(	   R.   R-   R   R3   t	   timestampt   durationt
   field_maskt   struct_messaget
   nested_any(    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testWellKnownInAnyMessagee  sf    	

	



	
c         C   s   t  j   } t  j   } |  j |  t j d |  |  j | |  |  j | j d   t j d |  |  j | j d   |  j	 t j
 d t j d |  |  j d d  d  S(   Ns  {"int32Value": null, "int64Value": null, "uint32Value": null,"uint64Value": null,"floatValue": null,"doubleValue": null,"boolValue": null,"stringValue": null,"bytesValue": null,"messageValue": null,"enumValue": null,"repeatedInt32Value": null,"repeatedInt64Value": null,"repeatedUint32Value": null,"repeatedUint64Value": null,"repeatedFloatValue": null,"repeatedDoubleValue": null,"repeatedBoolValue": null,"repeatedStringValue": null,"repeatedBytesValue": null,"repeatedMessageValue": null,"repeatedEnumValue": null}R   s   {"messageValue": {}}sk   Failed to parse repeatedInt32Value field: null is not allowed to be used as an element in a repeated field.s    {"repeatedInt32Value":[1, null]}s   {"repeatedMessageValue":[null]}sm   Failed to parse repeatedMessageValue field: null is not allowed to be used as an element in a repeated field.(   R
   R5   R/   R	   R0   R2   t   assertFalset   HasFieldt
   assertTrueR6   R7   R:   (   R.   R-   R3   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testParseNull  s"    		c         C   ss   t  j   } t d  | _ d } |  j t j |  |  t  j   } t j | |  |  j t	 j
 | j   d  S(   Nt   nans   {
  "floatValue": "NaN"
}(   R
   R5   R   R   R2   R	   R1   R0   R   t   matht   isnan(   R.   R-   R8   R3   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testNanFloat  s    c         C   s   |  j  d d  d  S(   NR}   s1   Failed to load JSON: (Expecting value)|(No JSON).(   R:   (   R.   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testParseEmptyText  s    	c         C   s   t  j   } d } t j | |  d } t j | |  |  j d d  d } t j | |  t j   } |  j t j d t j d |  d  S(   Ns   {"enumValue": 0}s   {"enumValue": 1}s   {"enumValue": "baz"}sV   Failed to parse enumValue field: Invalid enum value baz for enum type proto3.EnumType.s   {"enumValue": 12345}s{   Failed to parse optionalNestedEnum field: Invalid enum value 12345 for enum type protobuf_unittest.TestAllTypes.NestedEnum.s   {"optionalNestedEnum": 12345}(	   R
   R5   R	   R0   R:   R   t   TestAllTypesR6   R7   (   R.   R-   R8   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testParseEnumValue  s    c         C   s$   |  j  d d  |  j  d d  d  S(   Ns   {int32Value: 1}sQ   Failed to load JSON: Expecting property name( enclosed in double quotes)?: line 1s   {"unknownName": 1}sC   Message type "proto3.TestMessage" has no field named "unknownName".(   R:   (   R.   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testParseBadIdentifer  s    		c         C   sT   d } t  j   } t j | | d t d } t  j   } t j | | d t d  S(   Ns   {"unknownName": 1}t   ignore_unknown_fieldssl   {
  "repeatedValue": [ {
    "@type": "type.googleapis.com/proto3.MessageType",
    "unknownName": 1
  }]
}
(   R
   R5   R	   R0   R   R   (   R.   R8   R3   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testIgnoreUnknownField  s    c         C   s'   t  j d k  r d  S|  j d d  d  S(   Ni   i   s!   {"int32Value": 1,
"int32Value":2}s.   Failed to load JSON: duplicate key int32Value.(   i   i   (   R]   R^   R:   (   R.   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testDuplicateField  s    	c         C   s$   |  j  d d  |  j  d d  d  S(   Ns   {"boolValue": 1}sG   Failed to parse boolValue field: Expected true or false without quotes.s   {"boolValue": "true"}(   R:   (   R.   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testInvalidBoolValue  s    		c         C   s   t  j   } d } |  j t j t j | |  |  j d d  |  j d d  |  j d d  |  j d d	  |  j d
 d  |  j d d  d  S(   Ns   {"int32Value": 0x12345}s   {"int32Value": 1.5}s>   Failed to parse int32Value field: Couldn't parse integer: 1.5.s   {"int32Value": 012345}s9   Failed to load JSON: Expecting \'?,\'? delimiter: line 1.s   {"int32Value": " 1 "}s@   Failed to parse int32Value field: Couldn't parse integer: " 1 ".s   {"int32Value": "1 "}s?   Failed to parse int32Value field: Couldn't parse integer: "1 ".s$   {"int32Value": 12345678901234567890}sK   Failed to parse int32Value field: Value out of range: 12345678901234567890.s   {"uint32Value": -1}s:   Failed to parse uint32Value field: Value out of range: -1.(   R
   R5   t   assertRaisesR	   R7   R0   R:   (   R.   R-   R8   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testInvalidIntegerValue'  s     						c         C   s   |  j  d d  d  S(   Ns   {"floatValue": "nan"}sP   Failed to parse floatValue field: Couldn't parse float "nan", use "NaN" instead.(   R:   (   R.   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testInvalidFloatValue?  s    	c         C   s$   |  j  d d  |  j  d d  d  S(   Ns   {"bytesValue": "AQI"}s4   Failed to parse bytesValue field: Incorrect padding.s   {"bytesValue": "AQI*"}(   R:   (   R.   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testInvalidBytesValueD  s    		c         C   s   |  j  d d  d  S(   Ns   {"repeatedInt32Value": 12345}sk   Failed to parse repeatedInt32Value field: repeated field repeatedInt32Value must be in \[\] which is 12345.(   R:   (   R.   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testInvalidRepeatedJ  s    	c         C   s   t  j   } d } |  j t j d t j | |  d } |  j t j d t j | |  d } |  j t j d t j | |  t j d k  r d  Sd	 } |  j t j d
 t j | |  d } |  j t j d t j | |  d  S(   Ns!   {"int32Map": {"null": 2, "2": 3}}s/   Failed to parse int32Map field: invalid literals   {"int32Map": {1: 2, "2": 3}}sQ   Failed to load JSON: Expecting property name( enclosed in double quotes)?: line 1s   {"boolMap": {"null": 1}}sD   Failed to parse boolMap field: Expected "true" or "false", not null.i   i   s$   {"stringMap": {"a": 3, "\u0061": 2}}s$   Failed to load JSON: duplicate key as   {"stringMap": 0}sS   Failed to parse stringMap field: Map field string_map must be in a dict which is 0.(   i   i   (   R
   t   TestMapR6   R	   R7   R0   R]   R^   (   R.   R-   R8   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testInvalidMapO  s8    c         C   s   t  j   } d } |  j t j d t j | |  d } |  j t j d t j | |  d } |  j t j d t j | |  d } |  j t j d t j | |  d	 | j _ |  j t	 d
 t j
 |  d  S(   Ns%   {"value": "10000-01-01T00:00:00.00Z"}sK   time data '10000-01-01T00:00:00' does not match format '%Y-%m-%dT%H:%M:%S'.s/   {"value": "1970-01-01T00:00:00.0123456789012Z"}s2   nanos 0123456789012 more than 9 fractional digits.s&   {"value": "1972-01-01T01:00:00.01+08"}s$   Invalid timezone offset value: \+08.s!   {"value": "0000-01-01T00:00:00Z"}s7   Failed to parse value field: year (0 )?is out of range.l   A s   date value out of range(   R
   Rs   R6   R	   R7   R0   R   R   Rt   t   OverflowErrorR1   (   R.   R-   R8   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testInvalidTimestampo  s4    c         C   s5   t  j   } d } |  j t j d t j | |  d  S(   Ns/   {"oneofInt32Value": 1, "oneofStringValue": "2"}sT   Message type "proto3.TestOneof" should not have multiple "oneof_value" oneof fields.(   R
   Rn   R6   R	   R7   R0   (   R.   R-   R8   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testInvalidOneof  s    c         C   s5   t  j   } d } |  j t j d t j | |  d  S(   Ns   {"value": 1234}sD   Failed to parse value field: ListValue must be in \[\] which is 1234(   R
   R   R6   R	   R7   R0   (   R.   R-   R8   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testInvalidListValue  s    c         C   s5   t  j   } d } |  j t j d t j | |  d  S(   Ns   {"value": 1234}sC   Failed to parse value field: Struct must be in a dict which is 1234(   R
   R   R6   R	   R7   R0   (   R.   R-   R8   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testInvalidStruct  s    c         C   s   t  j   } d } |  j t d t j | |  d } |  j t j d t j | |  d } |  j t d t j | |  d } t j | |  d  S(   Ns;   {"@type": "type.googleapis.com/google.protobuf.Int32Value"}R   s   {"value": 1234}s*   @type is missing when parsing any message.s?   {"@type": "type.googleapis.com/MessageNotExist", "value": 1234}sQ   Can not find message descriptor by type_url: type.googleapis.com/MessageNotExist.sN   {"@type": "incorrect.googleapis.com/google.protobuf.Int32Value","value": 1234}(   R    R   R6   t   KeyErrorR	   R0   R7   t	   TypeError(   R.   R-   R8   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testInvalidAny  s$    c         C   s   t  j   } d | _ |  j d t j |   |  j d t j | t t   t  j   } |  j d t j | t t   |  j d t j | t t   t  j   } t j	 d |  |  j d | j  t j	 d |  |  j d | j  d  S(	   Ni90  s   {
  "int32Value": 12345
}s   {
  "int32_value": 12345
}s   {
  "repeatedValue": []
}s   {
  "repeated_value": []
}s   {"int32Value": 54321}i1  s   {"int32_value": 12345}(
   R
   R5   R   R2   R	   R1   R&   R   Rs   R0   (   R.   R-   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testPreservingProtoFieldNames  s     					c         C   s8   t  j   } d | _ |  j d t j | d d  d  S(   Ni90  s   {
"int32Value": 12345
}t   indenti    (   R
   R5   R   R2   R	   R1   (   R.   R-   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt
   testIndent  s    		c         C   sF   d } i | d 6} t  j   } t j | |  |  j | | j  d  S(   Ni90  t
   int32Value(   R
   R5   R	   RS   R2   R   (   R.   t   expectedt   js_dictR-   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testParseDict  s
    c         C   s?   t  j   } d | _ i d d 6} |  j | t j |   d  S(   Ni90  R   (   R
   R5   R   R2   R	   RR   (   R.   R-   R   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testMessageToDict  s
    		c         C   sN   t  j   } d | _ |  j d t j |   t  j   } |  j | |  d  S(   Ni90  s   {
  "@value": 12345
}(   R
   t   TestCustomJsonNameR   R2   R	   R1   R4   (   R.   R-   R3   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testJsonName  s    		c         C   s   t  j d t d d d d d d d d	  } |  j t j | d
 t t j i t d 6d d 6d d 6d d 6d	 d 6d d d
 t  d  S(   NR   R   i   R   i   R   i   R   t   blat	   sort_keyst	   boolValueR   t   3t
   int64Valuet   uint32Valuet   stringValueR   i   (   R
   R5   R   R2   R	   R1   R@   t   dumps(   R.   R-   (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   testSortKeys  s    	(2   R;   R<   R>   RB   RC   RD   RP   RQ   RU   RX   R\   R`   Ra   Rb   Rm   Rp   Rr   Rw   Ry   R|   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   (    (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyR=   n   s`   		
	!	
										(			(				!			.	O	-													 											t   __main__(   t   __doc__t
   __author__R@   R   R]   t	   unittest2t   unittestt   ImportErrort   google.protobufR    R   R   R   R   R   R   R   t   google.protobuf.internalR   R	   t   google.protobuf.utilR
   t   TestCaseR   R=   R;   t   main(    (    (    sM   /usr/lib/python2.7/site-packages/google/protobuf/internal/json_format_test.pyt   <module>    s4   4   