3
SLj @ s d Z yddlmZ W n ek
r4 ddlmZ Y nX yddlZW n ek
r^ ddlZY nX ddlmZ ddlm Z ddlm
Z
ddlmZ G dd d ejZ
ed
krej dS )z(Tests for google.protobuf.proto_builder. )OrderedDictN)descriptor_pb2)descriptor_pool)
proto_builder)text_formatc @ s, e Zd Zdd Zdd Zdd Zdd Zd S )
ProtoBuilderTestc C s. t dtjjfdtjjfg| _t| j| _d S )Nfoobar)r r ZFieldDescriptorProtoZ
TYPE_INT64ZTYPE_STRINGordered_fieldsdict_fields)self r (/usr/lib/python3.6/proto_builder_test.pysetUp3 s
zProtoBuilderTest.setUpc C s8 t j| jdd}| }d|_d|_| jdtj| dS )z&Test that we can create a proto class.z0net.proto2.python.public.proto_builder_test.Test) full_namei90 asdfzbar: "asdf"
foo: 12345
N)r MakeSimpleProtoClassr r r assertMultiLineEqualr MessageToString)r
proto_clsprotor r r testMakeSimpleProtoClass: s z)ProtoBuilderTest.testMakeSimpleProtoClassc C s8 t j| jdd}| }d|_d|_| jdtj| dS )zBTest that the field order is maintained when given an OrderedDict.z7net.proto2.python.public.proto_builder_test.OrderedTest)r i90 r zfoo: 12345
bar: "asdf"
N)r r r
r r r r r )r
r r r r r testOrderedFieldsE s z"ProtoBuilderTest.testOrderedFieldsc C s@ t j }tj| jd|d}tj| jd|d}| j|j|j dS )z%Test that the DescriptorPool is used.z0net.proto2.python.public.proto_builder_test.Test)r poolN)r ZDescriptorPoolr r r ZassertIsZ
DESCRIPTOR)r
r Z
proto_cls1Z
proto_cls2r r r testMakeSameProtoClassTwiceP s z,ProtoBuilderTest.testMakeSameProtoClassTwiceN)__name__
__module____qualname__r r r r r r r r r 1 s r __main__)__doc__collectionsr ImportErrorZordereddictZ unittest2ZunittestZgoogle.protobufr r r r ZTestCaser r mainr r r r