ó ð|ýJc@s~dZddlmZddlZddlZddlmZddlmZdefd„ƒYZ e dkrzeƒndS( s! Unit tests for L{OpenSSL.rand}. iĸĸĸĸ(tmainN(tTestCase(trandt RandTestscBs5eZd„Zd„Zd„Zd„Zd„ZRS(cCsĄtjdƒ}|jt|ƒdƒtjddƒ}|j||ƒtjddƒ}|jt|ƒdƒ|jttjdƒ}|jt|ƒdƒdS(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_bytesiiĸĸĸĸsnum_bytes must not be negativeN(Rtbytest assertEqualtlentassertNotEqualt assertRaisest ValueErrortstr(tselftb1tb2tb3texc((sI/opt/alt/python27/lib64/python2.7/site-packages/OpenSSL/test/test_rand.pyt test_bytesscCstjddƒdS(s? L{OpenSSL.rand.add} adds entropy to the PRNG. t hamburgeriN(Rtadd(R ((sI/opt/alt/python27/lib64/python2.7/site-packages/OpenSSL/test/test_rand.pyttest_add scCstjdƒdS(s@ L{OpenSSL.rand.seed} adds entropy to the PRNG. s milk shakeN(Rtseed(R ((sI/opt/alt/python27/lib64/python2.7/site-packages/OpenSSL/test/test_rand.pyt test_seed'scCs|jtjƒdkƒdS(sx L{OpenSSL.rand.status} returns C{True} if the PRNG has sufficient entropy, C{False} otherwise. iiN(ii(t assertTrueRtstatus(R ((sI/opt/alt/python27/lib64/python2.7/site-packages/OpenSSL/test/test_rand.pyt test_status.scCsŽ|jƒ}t|dƒ}|jƒzTtj|ƒtj|ƒtj}|j|dƒtj |ƒtj |dƒWdtj |ƒXdS(sG Test reading and writing of files via rand functions. twiiN( tmktemptfiletcloseRt write_filetoststattST_SIZEt assertEqualst load_filetunlink(R ttmpfiletfObjtsize((sI/opt/alt/python27/lib64/python2.7/site-packages/OpenSSL/test/test_rand.pyt test_files9s    (t__name__t __module__RRRRR((((sI/opt/alt/python27/lib64/python2.7/site-packages/OpenSSL/test/test_rand.pyRs     t__main__( t__doc__tunittestRRR tOpenSSL.test.utilRtOpenSSLRRR)(((sI/opt/alt/python27/lib64/python2.7/site-packages/OpenSSL/test/test_rand.pyts  @