�
��[c@s�dZddlZddlZddlZddlmZddlmZddlZddl m
Z
mZejdkr�d�Z
eZnd �Z
eZd
efd��YZdS(
s`
Helpers for the OpenSSL test suite, largely copied from
U{Twisted<http://twistedmatrix.com/>}.
i����N(tmktemp(tTestCase(tErrort_exception_from_error_queueiicCs|S(N((ts((s7/usr/lib64/python2.7/site-packages/OpenSSL/test/util.pytbscCs
|jd�S(Ntcharmap(tencode(R((s7/usr/lib64/python2.7/site-packages/OpenSSL/test/util.pyRsRcBs�eZdZd�Zd
d�ZeZd
d�ZeZd
d�Z e Z
d�ZeZd
Z
d�Zd�Zd�Zd �ZRS(s�
L{TestCase} adds useful testing functionality beyond what is available
from the standard library L{unittest.TestCase}.
cCs�trp|jdk rpxX|jD]J}tjj|�rGtj|�qtjj|�rtj |�qqWnyt
�WnMtk
r�tj
�d}|jgfkr�|jdt|��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.
is)Left over errors in OpenSSL error queue: N(tFalset_temporaryFilestNonetostpathtisdirtshutiltrmtreetexiststunlinkRRtsystexc_infotargstfailtrepr(tselfttempte((s7/usr/lib64/python2.7/site-packages/OpenSSL/test/util.pyttearDown!s
cCs2||kr.|j|p%d||f��n|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((s7/usr/lib64/python2.7/site-packages/OpenSSL/test/util.pytfailUnlessIn5s
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(R(RtfirsttsecondR((s7/usr/lib64/python2.7/site-packages/OpenSSL/test/util.pytfailUnlessIdenticalEs "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(RR R!R((s7/usr/lib64/python2.7/site-packages/OpenSSL/test/util.pytfailIfIdenticalTs "cOs�y|||�}WnN|k
r7tj�d}|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.
is%s raised instead of %sis%s not raised (%r returned)N(RRRt__name__(Rt exceptiontfRtkwargstresulttinst((s7/usr/lib64/python2.7/site-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((s7/usr/lib64/python2.7/site-packages/OpenSSL/test/util.pyR�s
cOs|j||�S(N(t
failUnless(Rtatkw((s7/usr/lib64/python2.7/site-packages/OpenSSL/test/util.pyt
assertTrue�scOs|j||�S(N(tfailIf(RR/R0((s7/usr/lib64/python2.7/site-packages/OpenSSL/test/util.pytassertFalse�scGsO|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((s7/usr/lib64/python2.7/site-packages/OpenSSL/test/util.pytassertConsistentType�sN(R$t
__module__t__doc__RR
RtassertInR"R7R#tassertNotIdenticalR*tassertRaisesR RR1R3R<(((s7/usr/lib64/python2.7/site-packages/OpenSSL/test/util.pyRs (ii(R>RRtos.pathttempfileRtunittestRRtOpenSSL.cryptoRRtversion_infoRtstrtbytes(((s7/usr/lib64/python2.7/site-packages/OpenSSL/test/util.pyt<module>s |