3 SÉLj£ã@s¶dZyddlmZWn ek r4ddlmZYnXy ddlZWnek r^ddlZYnXddlmZddlm Z ddlm Z ddlm Z Gdd „d ej ƒZ ed kr²ejƒdS) z(Tests for google.protobuf.proto_builder.é)Ú OrderedDictN)Údescriptor_pb2)Údescriptor_pool)Ú proto_builder)Ú text_formatc@s,eZdZdd„Zdd„Zdd„Zdd„Zd S) ÚProtoBuilderTestcCs.tdtjjfdtjjfgƒ|_t|jƒ|_dS)NÚfooÚbar)rrZFieldDescriptorProtoZ TYPE_INT64Z TYPE_STRINGÚordered_fieldsÚdictÚ_fields)Úself©rú(/usr/lib/python3.6/proto_builder_test.pyÚsetUp3s 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_namei90Úasdfzbar: "asdf" foo: 12345 N)rÚMakeSimpleProtoClassr rr ÚassertMultiLineEqualrÚMessageToString)r Ú proto_clsÚprotorrrÚtestMakeSimpleProtoClass: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 rrrrrÚtestOrderedFieldsEsz"ProtoBuilderTest.testOrderedFieldscCs@tjƒ}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)rZDescriptorPoolrrr ZassertIsZ DESCRIPTOR)r rZ proto_cls1Z proto_cls2rrrÚtestMakeSameProtoClassTwicePsz,ProtoBuilderTest.testMakeSameProtoClassTwiceN)Ú__name__Ú __module__Ú __qualname__rrrrrrrrr1s  rÚ__main__)Ú__doc__Ú collectionsrÚ ImportErrorZ ordereddictZ unittest2ZunittestZgoogle.protobufrrrrZTestCaserrÚmainrrrrÚ s     -