Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/OpenSSL/test/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/OpenSSL/test/util.pyc


T@Rc@sdZddlZddlZddlZddlmZddlmZddlZddl	m
Z
mZejdkrdZ
eZnd	Z
eZd
efdYZdS(
s`
Helpers for the OpenSSL test suite, largely copied from
U{Twisted<http://twistedmatrix.com/>}.
iN(tmktemp(tTestCase(tErrort_exception_from_error_queueiicCs|S(N((ts((s5/usr/lib/python2.7/dist-packages/OpenSSL/test/util.pytbscCs
|jdS(Ntcharmap(tencode(R((s5/usr/lib/python2.7/dist-packages/OpenSSL/test/util.pyRsRcBseZdZdZd
dZeZd
dZeZd
dZ	e	Z
dZeZd
Z
dZdZdZd	ZRS(s
    L{TestCase} adds useful testing functionality beyond what is available
    from the standard library L{unittest.TestCase}.
    cCstrp|jdk	rpxX|jD]J}tjj|rGtj|qtjj|rtj	|qqWnyt
WnMtk
rtj
d}|jgfkr|jdt|qnXdS(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.
        is)Left over errors in OpenSSL error queue: N(tFalset_temporaryFilestNonetostpathtisdirtshutiltrmtreetexiststunlinkRRtsystexc_infotargstfailtrepr(tselfttempte((s5/usr/lib/python2.7/dist-packages/OpenSSL/test/util.pyttearDown!s
cCs2||kr.|j|p%d||fn|S(s
        Fail the test if C{containee} is not found in C{container}.

        @param containee: the value that should be in C{container}
        @param container: a sequence type, or in the case of a mapping type,
                          will follow semantics of 'if key in dict.keys()'
        @param msg: if msg is None, then the failure message will be
                    '%r not in %r' % (first, second)
        s%r not in %r(tfailureException(Rt	containeet	containertmsg((s5/usr/lib/python2.7/dist-packages/OpenSSL/test/util.pytfailUnlessIn5s
cCs2||k	r.|j|p%d||fn|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(R(RtfirsttsecondR((s5/usr/lib/python2.7/dist-packages/OpenSSL/test/util.pytfailUnlessIdenticalEs	"cCs2||kr.|j|p%d||fn|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(RR R!R((s5/usr/lib/python2.7/dist-packages/OpenSSL/test/util.pytfailIfIdenticalTs	"cOsy|||}WnN|k
r7tjd}|S|jdtjd|jfnX|jd|j|fdS(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.
        is%s raised instead of %sis%s not raised (%r returned)N(RRRt__name__(Rt	exceptiontfRtkwargstresulttinst((s5/usr/lib/python2.7/dist-packages/OpenSSL/test/util.pytfailUnlessRaisescs
	
	cCs>|jdkrg|_ntdd}|jj||S(sQ
        Pathetic substitute for twisted.trial.unittest.TestCase.mktemp.
        tdirt.N(R	R
Rtappend(RR((s5/usr/lib/python2.7/dist-packages/OpenSSL/test/util.pyRs
cOs|j||S(N(t
failUnless(Rtatkw((s5/usr/lib/python2.7/dist-packages/OpenSSL/test/util.pyt
assertTruescOs|j||S(N(tfailIf(RR/R0((s5/usr/lib/python2.7/dist-packages/OpenSSL/test/util.pytassertFalsescGsO|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(tassertEqualR$R1t
isinstancettypetassertIdentical(RttheTypetnametconstructionArgstinstance((s5/usr/lib/python2.7/dist-packages/OpenSSL/test/util.pytassertConsistentTypesN(R$t
__module__t__doc__RR
RtassertInR"R7R#tassertNotIdenticalR*tassertRaisesR	RR1R3R<(((s5/usr/lib/python2.7/dist-packages/OpenSSL/test/util.pyRs					(ii(R>RRtos.pathttempfileRtunittestRRtOpenSSL.cryptoRRtversion_infoRtstrtbytes(((s5/usr/lib/python2.7/dist-packages/OpenSSL/test/util.pyt<module>s