ó {G_Tc@sddlZddlZddlZddlZddlmZmZddlZddlZddl m Z dgZ ej r™e jdddgƒnge D]Zeef^q Zd„Zd ejfd „ƒYZd ejfd „ƒYZd „ZedkreƒndS(iÿÿÿÿN(t run_unittesttcheck_warnings(tsystems)BaseException.message has been deprecateds)exceptions must derive from BaseExceptionsEcatching classes that don't inherit from BaseException is not alloweds7__get(item|slice)__ not supported for exception classescs‡fd†}|S(s%Ignore the known DeprecationWarnings.cs*tdttŒˆ||ŽSWdQXdS(Ntquiet(RtTruet _deprecations(targstkw(tfunc(s,/usr/local/lib/python2.7/test/test_pep352.pytwrappers((RR ((Rs,/usr/local/lib/python2.7/test/test_pep352.pytignore_deprecation_warningsstExceptionClassTestscBsteZdZd„Zed„ƒZd„ZdZd „Zed „ƒZ ed „ƒZ ed„ƒZ d„Z RS(s]Tests for anything relating to exception objects themselves (e.g., inheritance hierarchy)cCs|jtttƒƒdS(N(t assertTruet issubclasst Exceptiontobject(tself((s,/usr/local/lib/python2.7/test/test_pep352.pyttest_builtins_new_style!scCs>x7dD]/}|jt||ƒd|jj|fƒqWdS(NRtmessaget__str__t__repr__t __getitem__s%s missing %s attribute(sargssmessages__str__s__repr__s __getitem__(R thasattrt __class__t__name__(Rtinstattr((s,/usr/local/lib/python2.7/test/test_pep352.pytverify_instance_interface$s cCsÊtd„ttƒDƒƒ}ttjjtjjtƒddƒƒ}zT|j ƒj ƒ}yt t |ƒ}Wn"t k r“|jd|ƒnX|j||ƒ|j|ƒg}d}xÚ|D]Ò}|j ƒ}|jdƒ}||d} d| krR| jdƒ} | | dd !} | | d } tƒ| krR|j| ƒqÄqRnd | kr~| jd ƒ} | | d } nyt t | ƒ} Wn"t k rµ|jd | ƒnX||krØ|j||fƒn4||kr x%|d d|kr|jƒqçWn|jt| |d dƒd | j|d djfƒy|j| ƒƒWntk rlnX|j| |ƒ|j| ƒ| }|}qÄWWd|jƒX|jt|ƒdd |ƒdS(Ncss$|]}|jdƒs|VqdS(t_N(t startswith(t.0tx((s,/usr/local/lib/python2.7/test/test_pep352.pys -sisexception_hierarchy.txtsbase class %s not a built-int-it(iiÿÿÿÿt[s%s not a built-in exceptions%s is not a subclass of %ss%s not accounted for(tsettdirt exceptionstopentostpathtjointsplitt__file__treadlinetrstriptgetattrt __builtin__tAttributeErrortfailtassertIntdiscardtrindextindextplatform_systemtappendtpopR R RRt TypeErrortcloset assertEqualtlen(Rtexc_settinheritance_treetsuperclass_nametlast_exct superclassest last_depthtexc_linetdepthtexc_namet paren_indext platform_namet left_brackettexc((s,/usr/local/lib/python2.7/test/test_pep352.pyttest_inheritance+sb                tlengthRRtstrtunicodetreprtindexingcCsMxFt|j|ƒD]2\}\}}|j||d|||fƒqWdS(Ns %s: %s != %s(tziptinterface_testsR;(Rtresultst test_nametgiventexpected((s,/usr/local/lib/python2.7/test/test_pep352.pytinterface_test_drivercs%c Cs°d}t|ƒ}t|jƒdg|jd|g|j|gt|ƒt|ƒgt|ƒt|ƒgt|ƒ|jjt|jƒg|d|gf}|j |ƒdS(Ntspamii( RR<RRRLRMRNRRRV(RtargRIRR((s,/usr/local/lib/python2.7/test/test_pep352.pyttest_interface_single_arghs .*"c CsÂd}tt|ƒƒ}t|Œ}t|jƒ|g|j|g|jdgt|ƒt|ƒgt|ƒt|ƒgt|ƒ|j j t|jƒg|d|dgf}|j |ƒdS(Nitiÿÿÿÿ( ttupletrangeRR<RRRLRMRNRRRV(Rt arg_countRRIRR((s,/usr/local/lib/python2.7/test/test_pep352.pyttest_interface_multi_argss !"cCstƒ}t|jƒdg|jtƒg|jdgt|ƒdgt|ƒdgt|ƒ|jj dgt t gf}|j |ƒdS(NiRZus()( RR<RR[RRLRMRNRRRRV(RRIRR((s,/usr/local/lib/python2.7/test/test_pep352.pyttest_interface_no_arg€s  ! (cCs'tdtfƒtƒjWdQXdS(NRZ(RtDeprecationWarningt BaseExceptionR(R((s,/usr/local/lib/python2.7/test/test_pep352.pyttest_message_deprecation‹s(RKsargssmessagesstrsunicodesreprRO( Rt __module__t__doc__RR RRJRQRVRYR^R_Rb(((s,/usr/local/lib/python2.7/test/test_pep352.pyR s  5    t UsageTestscBsJeZdZd„Zd„Zed„ƒZd„Zd„Zd„Z RS(sTest usage of exceptionscCs:y |‚Wntk rdSX|jdt|ƒƒdS(s6Make sure that raising 'object_' triggers a TypeError.Ns!TypeError expected for raising %s(R9R1ttype(Rtobject_((s,/usr/local/lib/python2.7/test/test_pep352.pyt raise_fails•s   cCsÂy"y t‚Wn|k r nXWn8tk r5n(tk r\|jdt|ƒƒnXy%y t‚Wn|fk r€nXWn9tk r–dStk r½|jdt|ƒƒnXdS(s,Catching 'object_' should raise a TypeError.s#TypeError expected when catching %sNs;TypeError expected when catching %s as specified in a tuple(t StandardErrorR9R1Rf(RRg((s,/usr/local/lib/python2.7/test/test_pep352.pyt catch_failss&        cCs|ddd„ƒY}y |‚Wn$|k r0n|jdƒnXy |ƒ‚Wn$|k rdn|jdƒnXdS(Nt ClassicClasscBseZRS((RRc(((s,/usr/local/lib/python2.7/test/test_pep352.pyRk·ssunable to raise classic classs&unable to raise classic class instance((R1(RRk((s,/usr/local/lib/python2.7/test/test_pep352.pyttest_raise_classic´s    cCs7dtfd„ƒY}|j|ƒ|j|ƒƒdS(Nt NewStyleClasscBseZRS((RRc(((s,/usr/local/lib/python2.7/test/test_pep352.pyRmËs(RRh(RRm((s,/usr/local/lib/python2.7/test/test_pep352.pyt"test_raise_new_style_non_exceptionÆs cCs|jdƒdS(NRW(Rh(R((s,/usr/local/lib/python2.7/test/test_pep352.pyttest_raise_stringÐscCs¢tjƒtjƒtjdƒd}|jtƒ#y t‚Wn|k rWnXWdQX|jtƒ)y t‚Wnt|fk r‘nXWdQXWdQXdS(NterrorRW(twarningstcatch_warningst resetwarningstfilterwarningst assertRaisesR`RitAssertionError(Rtstr_exc((s,/usr/local/lib/python2.7/test/test_pep352.pyttest_catch_stringÔs       ( RRcRdRhRjR RlRnRoRx(((s,/usr/local/lib/python2.7/test/test_pep352.pyRe‘s   cCstttƒdS(N(RR Re(((s,/usr/local/lib/python2.7/test/test_pep352.pyt test_mainést__main__(tunittestR/R%Rqttest.test_supportRRR'tsystplatformRR6tDEPRECATION_WARNINGSt py3kwarningtextendtmsgR`RR tTestCaseR ReRyR(((s,/usr/local/lib/python2.7/test/test_pep352.pyts(          uX