3 SLj@sdZyddlmZWn ek r4ddlmZYnXy ddlZWnek r^ddlZYnXddlmZddlm Z ddlm Z ddlm Z Gdd d ej Z ed krejdS) z(Tests for google.protobuf.proto_builder.) OrderedDictN)descriptor_pb2)descriptor_pool) proto_builder) text_formatc@s,eZdZddZddZddZddZd S) ProtoBuilderTestcCs.tdtjjfdtjjfg|_t|j|_dS)Nfoobar)rrZFieldDescriptorProtoZ TYPE_INT64Z TYPE_STRINGordered_fieldsdict_fields)selfr(/usr/lib/python3.6/proto_builder_test.pysetUp3s zProtoBuilderTest.setUpcCs8tj|jdd}|}d|_d|_|jdtj|dS)z&Test that we can create a proto class.z0net.proto2.python.public.proto_builder_test.Test) full_namei90asdfzbar: "asdf" foo: 12345 N)rMakeSimpleProtoClassr rr assertMultiLineEqualrMessageToString)r proto_clsprotorrrtestMakeSimpleProtoClass:sz)ProtoBuilderTest.testMakeSimpleProtoClasscCs8tj|jdd}|}d|_d|_|jdtj|dS)zBTest that the field order is maintained when given an OrderedDict.z7net.proto2.python.public.proto_builder_test.OrderedTest)ri90rzfoo: 12345 bar: "asdf" N)rrr rr rrr)r rrrrrtestOrderedFieldsEsz"ProtoBuilderTest.testOrderedFieldscCs@tj}tj|jd|d}tj|jd|d}|j|j|jdS)z%Test that the DescriptorPool is used.z0net.proto2.python.public.proto_builder_test.Test)rpoolN)rZDescriptorPoolrrr ZassertIsZ DESCRIPTOR)r rZ proto_cls1Z proto_cls2rrrtestMakeSameProtoClassTwicePsz,ProtoBuilderTest.testMakeSameProtoClassTwiceN)__name__ __module__ __qualname__rrrrrrrrr1s  r__main__)__doc__ collectionsr ImportErrorZ ordereddictZ unittest2ZunittestZgoogle.protobufrrrrZTestCaserrmainrrrr s     -