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/test_rand.pyc


ʐMc@sdZddlmZddlZddlZddlmZmZddlm	Z	defdYZ
edkrendS(	s!
Unit tests for L{OpenSSL.rand}.
i(tmainN(tTestCasetb(trandt	RandTestscBseZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZRS(cCsF|jttj|jttjd|jttjdddS(s
        L{OpenSSL.rand.bytes} raises L{TypeError} if called with the wrong
        number of arguments or with a non-C{int} argument.
        iN(tassertRaisest	TypeErrorRtbytestNone(tself((s:/usr/lib/python2.7/dist-packages/OpenSSL/test/test_rand.pyttest_bytes_wrong_argsscCstjd}|jt|dtjdd}|j||tjdd}|jt|d|jttjd}|jt|ddS(s
        Verify that we can obtain bytes from rand_bytes() and
        that they are different each time.  Test the parameter
        of rand_bytes() for bad values.
        i2t	num_bytesiisnum_bytes must not be negativeN(RRtassertEqualtlentassertNotEqualRt
ValueErrortstr(R	tb1tb2tb3texc((s:/usr/lib/python2.7/dist-packages/OpenSSL/test/test_rand.pyt
test_bytesscCsq|jttj|jttjtdd|jttjdd|jttjtddddS(s
        When called with the wrong number of arguments, or with arguments not of
        type C{str} and C{int}, L{OpenSSL.rand.add} raises L{TypeError}.
        tfooiN(RRRtaddRR(R	((s:/usr/lib/python2.7/dist-packages/OpenSSL/test/test_rand.pyttest_add_wrong_args,scCstjtdddS(s?
        L{OpenSSL.rand.add} adds entropy to the PRNG.
        t	hamburgeriN(RRR(R	((s:/usr/lib/python2.7/dist-packages/OpenSSL/test/test_rand.pyttest_add7scCsL|jttj|jttjd|jttjtdddS(s
        When called with the wrong number of arguments, or with a non-C{str}
        argument, L{OpenSSL.rand.seed} raises L{TypeError}.
        RN(RRRtseedRR(R	((s:/usr/lib/python2.7/dist-packages/OpenSSL/test/test_rand.pyttest_seed_wrong_args>scCstjtddS(s@
        L{OpenSSL.rand.seed} adds entropy to the PRNG.
        s
milk shakeN(RRR(R	((s:/usr/lib/python2.7/dist-packages/OpenSSL/test/test_rand.pyt	test_seedHscCs|jttjddS(sd
        L{OpenSSL.rand.status} raises L{TypeError} when called with any
        arguments.
        N(RRRtstatusR(R	((s:/usr/lib/python2.7/dist-packages/OpenSSL/test/test_rand.pyttest_status_wrong_argsOscCs|jtjdkdS(sx
        L{OpenSSL.rand.status} returns C{True} if the PRNG has sufficient
        entropy, C{False} otherwise.
        iiN(ii(t
assertTrueRR(R	((s:/usr/lib/python2.7/dist-packages/OpenSSL/test/test_rand.pyttest_statusWscCs{|jttj|jttjd|jttjdd|jttjdd|jttjddddS(s
        L{OpenSSL.rand.egd} raises L{TypeError} when called with the wrong
        number of arguments or with arguments not of type C{str} and C{int}.
        RiN(RRRtegdR(R	((s:/usr/lib/python2.7/dist-packages/OpenSSL/test/test_rand.pyttest_egd_wrong_argsbs
cCs?tj|j}d}|j||kd||fdS(sr
        L{OpenSSL.rand.egd} returns C{0} or C{-1} if the EGD socket passed
        to it does not exist.
        iis%r not in %rN(ii(RR"tmktempR (R	tresulttexpected((s:/usr/lib/python2.7/dist-packages/OpenSSL/test/test_rand.pyttest_egd_missingns
	cCs|jttjddS(se
        L{OpenSSL.rand.cleanup} raises L{TypeError} when called with any
        arguments.
        N(RRRtcleanupR(R	((s:/usr/lib/python2.7/dist-packages/OpenSSL/test/test_rand.pyttest_cleanup_wrong_argszscCs|jtjddS(sk
        L{OpenSSL.rand.cleanup} releases the memory used by the PRNG and returns
        C{None}.
        N(tassertIdenticalRR(R(R	((s:/usr/lib/python2.7/dist-packages/OpenSSL/test/test_rand.pyttest_cleanupscCse|jttj|jttjdd|jttjdd|jttjddddS(s
        L{OpenSSL.rand.load_file} raises L{TypeError} when called the wrong
        number of arguments or arguments not of type C{str} and C{int}.
        RiN(RRRt	load_fileR(R	((s:/usr/lib/python2.7/dist-packages/OpenSSL/test/test_rand.pyttest_load_file_wrong_argsscCsF|jttj|jttjd|jttjdddS(s
        L{OpenSSL.rand.write_file} raises L{TypeError} when called with the
        wrong number of arguments or a non-C{str} argument.
        RN(RRRt
write_fileR(R	((s:/usr/lib/python2.7/dist-packages/OpenSSL/test/test_rand.pyttest_write_file_wrong_argsscCs|j}t|d}|jzTtj|tj|tj}|j|dtj	|tj	|dWdtj
|XdS(sG
        Test reading and writing of files via rand functions.
        twiiN(R$topentcloseRR.toststattST_SIZEtassertEqualsR,tunlink(R	ttmpfiletfObjtsize((s:/usr/lib/python2.7/dist-packages/OpenSSL/test/test_rand.pyt
test_filess


(t__name__t
__module__R
RRRRRRR!R#R'R)R+R-R/R;(((s:/usr/lib/python2.7/dist-packages/OpenSSL/test/test_rand.pyRs					
									
t__main__(t__doc__tunittestRR3R4tOpenSSL.test.utilRRtOpenSSLRRR<(((s:/usr/lib/python2.7/dist-packages/OpenSSL/test/test_rand.pyt<module>s