ó ð|ýJc@s†dZddlZddlZddlZddlmZddlmZddlZddl m Z m Z defd„ƒYZdS(s` Helpers for the OpenSSL test suite, largely copied from U{Twisted}. iĸĸĸĸN(tmktemp(tTestCase(tErrort_exception_from_error_queueRcBsteZdZd„Zd d„ZeZd d„ZeZd„Z e Z d Z d„Z d„Z d„Zd„ZRS( s„ L{TestCase} adds useful testing functionality beyond what is available from the standard library L{unittest.TestCase}. cCsŧ|jdk rjxX|jD]J}tjj|ƒrAtj|ƒqtjj|ƒrtj|ƒqqWny t ƒWn?t k rķ}|j gfkr·|j dt |ƒƒq·nXdS(sŧ Clean up any files or directories created using L{TestCase.mktemp}. Subclasses must invoke this method if they override it or the cleanup will not occur. s)Left over errors in OpenSSL error queue: N(t_temporaryFilestNonetostpathtisdirtshutiltrmtreetexiststunlinkRRtargstfailtrepr(tselfttempte((sD/opt/alt/python27/lib64/python2.7/site-packages/OpenSSL/test/util.pyttearDowns cCs2||k r.|j|p%d||fƒ‚n|S(s Fail the test if C{first} is not C{second}. This is an obect-identity-equality test, not an object equality (i.e. C{__eq__}) test. @param msg: if msg is None, then the failure message will be '%r is not %r' % (first, second) s %r is not %r(tfailureException(Rtfirsttsecondtmsg((sD/opt/alt/python27/lib64/python2.7/site-packages/OpenSSL/test/util.pytfailUnlessIdentical+s "cCs2||kr.|j|p%d||fƒ‚n|S(s  Fail the test if C{first} is C{second}. This is an obect-identity-equality test, not an object equality (i.e. C{__eq__}) test. @param msg: if msg is None, then the failure message will be '%r is %r' % (first, second) s%r is %r(R(RRRR((sD/opt/alt/python27/lib64/python2.7/site-packages/OpenSSL/test/util.pytfailIfIdentical:s "cOsvy|||Ž}Wn@|k r)}|S|jdtjƒd|jfƒ‚nX|jd|j|fƒ‚dS(s9 Fail the test unless calling the function C{f} with the given C{args} and C{kwargs} raises C{exception}. The failure will report the traceback and call stack of the unexpected exception. @param exception: exception type that is to be expected @param f: the function to call @return: The raised exception instance, if it is of the given type. @raise self.failureException: Raised if the function call does not raise an exception or if it raises an exception of a different type. s%s raised instead of %sis%s not raised (%r returned)N(Rtsystexc_infot__name__(Rt exceptiontfR tkwargstresulttinst((sD/opt/alt/python27/lib64/python2.7/site-packages/OpenSSL/test/util.pytfailUnlessRaisesIs   cCs>|jdkrg|_ntddƒ}|jj|ƒ|S(sQ Pathetic substitute for twisted.trial.unittest.TestCase.mktemp. tdirt.N(RRRtappend(RR((sD/opt/alt/python27/lib64/python2.7/site-packages/OpenSSL/test/util.pyRgs  cOs|j||ŽS(N(t failUnless(Rtatkw((sD/opt/alt/python27/lib64/python2.7/site-packages/OpenSSL/test/util.pyt assertTruesscOs|j||ŽS(N(tfailIf(RR'R(((sD/opt/alt/python27/lib64/python2.7/site-packages/OpenSSL/test/util.pyt assertFalsewscGsO|j|j|ƒ|jt|tƒƒ||Œ}|jt|ƒ|ƒdS(s Perform various assertions about C{theType} to ensure that it is a well-defined type. This is useful for extension types, where it's pretty easy to do something wacky. If something about the type is unusual, an exception will be raised. @param theType: The type object about which to make assertions. @param name: A string giving the name of the type. @param constructionArgs: Positional arguments to use with C{theType} to create an instance of it. N(t assertEqualRR)t isinstancettypetassertIdentical(RttheTypetnametconstructionArgstinstance((sD/opt/alt/python27/lib64/python2.7/site-packages/OpenSSL/test/util.pytassertConsistentType|s  N(Rt __module__t__doc__RRRR/RtassertNotIdenticalR"t assertRaisesRRR)R+R4(((sD/opt/alt/python27/lib64/python2.7/site-packages/OpenSSL/test/util.pyRs      ( R6R Rtos.pathttempfileRtunittestRRtOpenSSL.cryptoRR(((sD/opt/alt/python27/lib64/python2.7/site-packages/OpenSSL/test/util.pyts