eaiovnaovbqoebvqoeavibavo  Duac@sdZdZddlZddlZddlZddlmZddlmZye Wne k rqe Z nXdZ dZ dZd Zd Zd Zd Zd ZdZdZdZdZdejfdYZdS(spUtilities for Python proto2 tests. This is intentionally modeled on C++ code in //google/protobuf/test_util.*. s#robinson@google.com (Will Robinson)iN(tunittest_import_pb2(t unittest_pb2cCs|jjdkS(Ntproto2(t DESCRIPTORtsyntax(tmessage((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pytIsProto27scCsrd|_d|_d|_d|_d|_d|_d|_d|_d |_d |_ d |_ d |_ t |_ d |_d|_t|rd|j_nd|j_d|j_d|j_d|j_tjj|_tj|_ t|rt!j"|_#nd|_$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|j0j'd|j1j'd |j2j'd!|j3j't |j4j'd"|j5j'd#t|r+d$|j6j7_nd%|j8j7_d&|j9j7_d'|j:j7_d(|j;j7_|j<j'tjj=|j>j'tj?t|r|j@j't!jAn|jBj'd)|jCj'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+|j0j'd+|j1j'd+|j2j'd+|j3j't |j4j'd,|j5j'd-d.|j&d/|j8j7_d?|j9j7_d@|j:j7_dA|j;j7_|j<j'tjj=tjj|j<d/<|j>j'tjt|rX|j@j't!j"n|jBj'dB|jCj'dCt|rGdD|_EdE|_FdF|_GdG|_HdH|_IdI|_JdJ|_KdK|_LdL|_MdM|_NdN|_OdO|_PtD|_QdP|_RdQ|_StjjT|_UtjV|_Wt!jX|_YdR|_ZdS|_[ndT|_\dU|j]_dV|_^dW|__dXS(YsmSets every non-lazy field in the message to a unique value. Args: message: A TestAllTypes instance. ieifigihiiijikiliminioipu115t116iuiviwixi~u124u125iiiiiiiiiiiiu215t216iiiiiu224u225iu0t0i-ii.i/i0i1i2i3i4i5i6i7i8u315t316i=i>i?i@iGu324u325iiiiiiiiiiiit415t416t424t425iYiZt603t604N(`toptional_int32toptional_int64toptional_uint32toptional_uint64toptional_sint32toptional_sint64toptional_fixed32toptional_fixed64toptional_sfixed32toptional_sfixed64toptional_floattoptional_doubletTruet optional_booltoptional_stringtoptional_bytesRt optionalgrouptatoptional_nested_messagetbbtoptional_foreign_messagetctoptional_import_messagetdtoptional_public_import_messageteRt TestAllTypestBAZtoptional_nested_enumt FOREIGN_BAZtoptional_foreign_enumRt IMPORT_BAZtoptional_import_enumtoptional_string_piecet optional_cordtrepeated_int32tappendtrepeated_int64trepeated_uint32trepeated_uint64trepeated_sint32trepeated_sint64trepeated_fixed32trepeated_fixed64trepeated_sfixed32trepeated_sfixed64trepeated_floattrepeated_doublet repeated_booltrepeated_stringtrepeated_bytest repeatedgrouptaddtrepeated_nested_messagetrepeated_foreign_messagetrepeated_import_messagetrepeated_lazy_messagetrepeated_nested_enumtBARtrepeated_foreign_enumt FOREIGN_BARtrepeated_import_enumt IMPORT_BARtrepeated_string_piecet repeated_cordtFalset default_int32t default_int64tdefault_uint32tdefault_uint64tdefault_sint32tdefault_sint64tdefault_fixed32tdefault_fixed64tdefault_sfixed32tdefault_sfixed64t default_floattdefault_doublet default_booltdefault_stringt default_bytestFOOtdefault_nested_enumt FOREIGN_FOOtdefault_foreign_enumt IMPORT_FOOtdefault_import_enumtdefault_string_piecet default_cordt oneof_uint32toneof_nested_messaget oneof_stringt oneof_bytes(R((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pytSetAllNonLazyFields;s                                                                  cCst|d|j_dS(Ni(Rntoptional_lazy_messageR$(R((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt SetAllFieldss cCs|j}t}t}d||j||j?j(|j@||jAj(|jB||jCj(d*||jDj(d+||j'j(d,||j)j(d-||j*j(d.||j+j(d/||j,j(d0||j-j(d1||j.j(d2||j/j(d3||j0j(d4||j1j(d5||j2j(d6||j3j(d7||j4j(tE||j5j(d8||j6j(d9d:||j7j8_d;||j9j8_d<||j:j8_d=||j;j8_d>||j<j8_||j=j(|jj||j?j(|j!||jAj(|j#||jCj(d?||jDj(d@dA||jFi?i@iGu324u325iiiiiiiiiiiiu415R u424RiYiZu603RN(at ExtensionsRRtoptional_int32_extensiontoptional_int64_extensiontoptional_uint32_extensiontoptional_uint64_extensiontoptional_sint32_extensiontoptional_sint64_extensiontoptional_fixed32_extensiontoptional_fixed64_extensiontoptional_sfixed32_extensiontoptional_sfixed64_extensiontoptional_float_extensiontoptional_double_extensionRtoptional_bool_extensiontoptional_string_extensiontoptional_bytes_extensiontoptionalgroup_extensionR"t!optional_nested_message_extensionR$t"optional_foreign_message_extensionR&t!optional_import_message_extensionR(t(optional_public_import_message_extensionR*toptional_lazy_message_extensionR+R,toptional_nested_enum_extensionR.toptional_foreign_enum_extensionR0toptional_import_enum_extensiontoptional_string_piece_extensiontoptional_cord_extensiontrepeated_int32_extensionR5trepeated_int64_extensiontrepeated_uint32_extensiontrepeated_uint64_extensiontrepeated_sint32_extensiontrepeated_sint64_extensiontrepeated_fixed32_extensiontrepeated_fixed64_extensiontrepeated_sfixed32_extensiontrepeated_sfixed64_extensiontrepeated_float_extensiontrepeated_double_extensiontrepeated_bool_extensiontrepeated_string_extensiontrepeated_bytes_extensiontrepeatedgroup_extensionREt!repeated_nested_message_extensiont"repeated_foreign_message_extensiont!repeated_import_message_extensiontrepeated_lazy_message_extensiontrepeated_nested_enum_extensionRKtrepeated_foreign_enum_extensionRMtrepeated_import_enum_extensionROtrepeated_string_piece_extensiontrepeated_cord_extensionRRtdefault_int32_extensiontdefault_int64_extensiontdefault_uint32_extensiontdefault_uint64_extensiontdefault_sint32_extensiontdefault_sint64_extensiontdefault_fixed32_extensiontdefault_fixed64_extensiontdefault_sfixed32_extensiontdefault_sfixed64_extensiontdefault_float_extensiontdefault_double_extensiontdefault_bool_extensiontdefault_string_extensiontdefault_bytes_extensionRbtdefault_nested_enum_extensionRdtdefault_foreign_enum_extensionRftdefault_import_enum_extensiontdefault_string_piece_extensiontdefault_cord_extensiontoneof_uint32_extensiontoneof_nested_message_extensiontoneof_string_extensiontoneof_bytes_extension(Rt extensionstpb2t import_pb2((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pytSetAllExtensionss                                     cCs?d|_d|_d|_d|jtjn|jd1t(|j?|jd1t(|j@|jd2|j)d3|jd4|j*d3|jd5|j+d3|jd6|j,d3|jd7|j-d3|jd8|j.d3|jd9|j/d3|jd:|j0d3|jd;|j1d3|jd<|j2d3|jd=|j3d3|jd>|j4d3|jt|j5d3|jd?|j6d3|jd@|j7d3t|r|jdA|j8d3jn|jdB|j9d3j|jdC|j:d3j|jdD|j;d3j|jdE|jAd3j|jtj jB|j<d3|jtjC|j=d3t|rV |jt%jD|j>d3n|jdF|j)dG|jdH|j*dG|jdI|j+dG|jdJ|j,dG|jdK|j-dG|jdL|j.dG|jdM|j/dG|jdN|j0dG|jdO|j1dG|jdP|j2dG|jdQ|j3dG|jdR|j4dG|jtE|j5dG|jdS|j6dG|jdT|j7dGt|r |jdU|j8dGjn|jdV|j9dGj|jdW|j:dGj|jdX|j;dGj|jdY|jAdGj|jtj j!|j<dG|jtj#|j=dGt|r |jt%j&|j>dGnt|r|j|jdZ|j|jd[|j|jd\|j|jd]|j|jd^|j|jd_|j|jd`|j|jda|j|jdb|j|jdc|j|jdd|j|jde|j|jdf|j|jdg|j|jdh|j|jdi|j|jdj|j|jdk|jdl|jF|jdm|jG|jdn|jH|jdo|jI|jdp|jJ|jdq|jK|jdr|jL|jds|jM|jdt|jN|jdu|jO|jdv|jP|jdw|jQ|jtE|jR|jdx|jS|jdy|jT|jtj jU|jV|jtjW|jX|jt%jY|jZndzS({sFCheck all fields for correct values have after Set*Fields() is called.RRRRRRRRRRRRRRR R!R#R%R'R"R$R&R(R-R/R1R2R3ieifigihiiijikiliminioipt115Riuiviwixi~iiiiiiiiiiiiiiit215Riiiiii-ii.i/i0i1i2i3i4i5i6i7i8t315R i=i>i?i@iGRSRTRURVRWRXRYRZR[R\R]R^R_R`RaRcReRgiiiiiiiiiiiiR R N([t assertTruetHasFieldRR!R#R%R't assertEqualRRRRRRRRRRRRRRRR R"R$R&R(R)R*RoRR+R,R-R.R/RR0R1tlenR4R6R7R8R9R:R;R<R=R>R?R@RARBRCRDRFRGRHRJRLRNRPRQRIRKRMRORRRSRTRURVRWRXRYRZR[R\R]R^R_R`RaRbRcRdReRfRg(t test_caseR((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pytExpectAllFieldsSetsj                        cCsd}xqtjj|rytjjtjj|dratjj|d|}t|dStjj|d}q Wd}tjj|d|}tjj|rt|dStddS( sFFinds the given golden file and returns a file object representing it.t.ssrc/google/protobufssrc/google/protobuf/testdatatrbs..s'third_party/py/google/protobuf/testdatasCould not find golden files. This test must be run from within the protobuf source package so that it can read test data files from the C++ source tree.N(tostpathtexistsRtopent RuntimeError(tfilenameRt full_path((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt GoldenFileis!   cCs#t|}|jSWdQXdS(s5Finds the given golden file and returns its contents.N(Rtread(Rtf((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pytGoldenFileDatascCs>|jjddg|jjddg|jjddg|jjddg|jjd d g|jjd d g|jjd dg|jjddg|j jddg|j jddg|j jddg|j jddg|j jttg|jjtjtjgdS(sgSets every field in the message to a unique value. Args: message: A TestPackedTypes instance. iYiiZii[ii\ii]ii^ii_ii`iiaiibig@g8@g @g@@N(t packed_int32textendt packed_int64t packed_uint32t packed_uint64t packed_sint32t packed_sint64tpacked_fixed32tpacked_fixed64tpacked_sfixed32tpacked_sfixed64t packed_floatt packed_doublet packed_boolRRRt packed_enumRRMR.(R((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pytSetAllPackedFieldsscCs|j}t}||jjddg||jjddg||jjddg||jjddg||jjd d g||jjd d g||j jd dg||j jddg||j jddg||j jddg||j jddg||jjddg||jjttg||jjtjtjgdS(s}Sets every extension in the message to a unique value. Args: message: A unittest_pb2.TestPackedExtensions instance. iYiiZii[ii\ii]ii^ii_ii`iiaiibig@g8@g @g@@N(RqRtpacked_int32_extensionRtpacked_int64_extensiontpacked_uint32_extensiontpacked_uint64_extensiontpacked_sint32_extensiontpacked_sint64_extensiontpacked_fixed32_extensiontpacked_fixed64_extensiontpacked_sfixed32_extensiontpacked_sfixed64_extensiontpacked_float_extensiontpacked_double_extensiontpacked_bool_extensionRRRtpacked_enum_extensionRMR.(RRR((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pytSetAllPackedExtensionss" cCs>|jjddg|jjddg|jjddg|jjddg|jjd d g|jjd d g|jjd dg|jjddg|j jddg|j jddg|j jddg|j jddg|j jttg|jjtjtjgdS(svSets every field in the message to a unique value. Args: message: A unittest_pb2.TestUnpackedTypes instance. iYiiZii[ii\ii]ii^ii_ii`iiaiibig@g8@g @g@@N(tunpacked_int32Rtunpacked_int64tunpacked_uint32tunpacked_uint64tunpacked_sint32tunpacked_sint64tunpacked_fixed32tunpacked_fixed64tunpacked_sfixed32tunpacked_sfixed64tunpacked_floattunpacked_doublet unpacked_boolRRRt unpacked_enumRRMR.(R((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pytSetAllUnpackedFieldsstNonStandardIntegercBseZdZd*dZdZdZdZdZdZ dZ dZ d Z d Z d Zd Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"d Z#d!Z$d"Z%d#Z&d$Z'd%Z(d&Z)d'Z*d(Z+d)Z,RS(+sAn integer object that does not subclass int. This is used to verify that both C++ and regular proto systems can handle integer others than int and long and that they handle them in predictable ways. NonStandardInteger is the minimal legal specification for a custom Integral. As such, it does not support 0 < x < 5 and it is not hashable. Note: This is added here instead of relying on numpy or a similar library with custom integers to limit dependencies. cCsIt|tjstt|tr3|j}n||_||_dS(N(t isinstancetnumberstIntegraltAssertionErrorRtvalterror_string_on_conversion(tselfRR((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt__init__s   cCs(|jrt|jnt|jS(N(RRtlongR(R((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt__long__s cCsttj|jS(N(RtoperatortabsR(R((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt__abs__scCsttj|j|S(N(RR"RER(Rty((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt__add__scCsttj|j|S(N(RR"tdivR(RR%((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt__div__scCstj|j|S(N(R"teqR(RR%((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt__eq__scCsttj|j|S(N(RR"tfloordivR(RR%((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt __floordiv__scCsttj|j|S(N(RR"ttruedivR(RR%((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt __truediv__scCsttj|jS(N(RR"tinvertR(R((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt __invert__scCsttj|j|S(N(RR"tmodR(RR%((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt__mod__scCsttj|j|S(N(RR"tmulR(RR%((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt__mul__scCsttj|jS(N(RR"tnegR(R((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt__neg__scCsttj|jS(N(RR"tposR(R((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt__pos__ scCsttj|j|S(N(RR"tpowR(RR%((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt__pow__ scCs t|jS(N(tintR(R((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt __trunc__scCsttj||jS(N(RR"RER(RR%((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt__radd__scCsttj||jS(N(RR"R'R(RR%((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt__rdiv__scCsttj||jS(N(RR"R1R(RR%((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt__rmod__scCsttj||jS(N(RR"R3R(RR%((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt__rmul__scCsttj||jS(N(RR"R9R(RR%((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt__rpow__scCsttj||jS(N(RR"R+R(RR%((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt __rfloordiv__!scCsttj||jS(N(RR"R-R(RR%((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt __rtruediv__$scCsttj|j|S(N(RR"tlshiftR(RR%((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt __lshift__'scCsttj|j|S(N(RR"trshiftR(RR%((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt __rshift__*scCsttj||jS(N(RR"RDR(RR%((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt __rlshift__-scCsttj||jS(N(RR"RFR(RR%((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt __rrshift__0scCs.t|tr|j}ntj|j|S(N(RRRR"tle(RR%((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt__le__3s cCs.t|tr|j}ntj|j|S(N(RRRR"tlt(RR%((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt__lt__8s cCsttj|j|S(N(RR"tand_R(RR%((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt__and__=scCsttj|j|S(N(RR"tor_R(RR%((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt__or__@scCsttj|j|S(N(RR"txorR(RR%((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt__xor__CscCsttj||jS(N(RR"RNR(RR%((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt__rand__FscCsttj||jS(N(RR"RPR(RR%((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt__ror__IscCsttj||jS(N(RR"RRR(RR%((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt__rxor__LscCs|jS(N(R(R((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt__bool__OscCs|jS(N(R(R((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt __nonzero__RscCs|S(N((R((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt__ceil__UscCs|S(N((R((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt __floor__XscCs(|jrt|jnt|jS(N(RRR;R(R((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt__int__[s cCs|S(N((R((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt __round__`scCs d|jS(NsNonStandardInteger(%s)(R(R((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt__repr__csN(-t__name__t __module__t__doc__tNoneRR!R$R&R(R*R,R.R0R2R4R6R8R:R<R=R>R?R@RARBRCRERGRHRIRKRMRORQRSRTRURVRWRXRYRZR[R\R](((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyRsT                                         (R`t __author__RR"tos.pathRtgoogle.protobufRRR t NameErrorR;RRnRpRRRRRRRRRRR(((sF/usr/lib/python2.7/site-packages/google/protobuf/internal/test_util.pyt#s.