yXXc@sdZddlZddlZejeZddlmZdddgZdefdYZ ddl m Z m Z e d Z e d Zd efd YZdd l mZdddgZdefdYZdS(s&passlib.tests -- tests for passlib.pwdiN(tTestCaset UtilsTestt GenerateTestt StrengthTestcBseZdZdZdZRS(stest internal utilitiess passlib.pwdcCsddlm}|j|dd|j|dd|j|dd|j|dd|j|d d |j|d dd |j|d d d ddS(s_self_info_rate()i(t_self_info_ratetitaitabitabcditabcdaaaag@?tplacesiNtaaaaaaaatabababababababab(t passlib.pwdRt assertEqualtassertAlmostEqual(tselfR((s:/usr/lib/python2.7/site-packages/passlib/tests/test_pwd.pyttest_self_info_rates(t__name__t __module__t__doc__tdescriptionPrefixR(((s:/usr/lib/python2.7/site-packages/passlib/tests/test_pwd.pyRs(tgenwordtdefault_charsetstascii_62thextWordGeneratorTestcBsDeZdZdZdZedZdZdZdZ RS(stest generation routinesspasslib.pwd.genword()cCsCtt|jddlm}|j|d|jddS(Ni(tSequenceGeneratortrngs pwd generator(tsuperRtsetUpR Rt patchAttrt getRandom(RR((s:/usr/lib/python2.7/site-packages/passlib/tests/test_pwd.pyRDs cCsy|jt|||rP|tkr1|}n|jtt||n|jtdj|t|dS(s2check result list matches expected count & charsetRN(RtlentTruetsettjoin(Rtresultstcounttcharstunique((s:/usr/lib/python2.7/site-packages/passlib/tests/test_pwd.pytassertResultContentsLs   cCs<t}|jt|d|jtdtdtdS(sgeneral behaviori s(?i)unexpected keyword.*badkwdtbadkwdN(RRR!tassertRaisesRegext TypeErrorR"(Rtresult((s:/usr/lib/python2.7/site-packages/passlib/tests/test_pwd.pyt test_generalUs cCstdd}|j|dttdt}gtdD]}t|^q>}|j|dt|jttdddS(s'returns' keywordtreturnsis invalid-typeN(RR)Rtitertrangetnextt assertRaisesR,(RR%tgent_((s:/usr/lib/python2.7/site-packages/passlib/tests/test_pwd.pyt test_returns_s %cCs|tdddd}|j|dttdddddd}|j|ddd d |jttddddd S( s'charset' & 'chars' optionstcharsetRR/itlengthiR'tabcR(iN(RR)RR3R,(RR%((s:/usr/lib/python2.7/site-packages/passlib/tests/test_pwd.pyt test_charsetms ( RRRRRR"R)R.R6R:(((s:/usr/lib/python2.7/site-packages/passlib/tests/test_pwd.pyR@s  (t genphrasetalphatbetatgammatPhraseGeneratorTestcBsGeZdZdZeddZdZdZdZdZ RS(stest generation routinesspasslib.pwd.genphrase()t cs|jt|||rP|tkr1|}n|jtt||nttjjfd|D}|j|t|dS(s2check result list matches expected count & charsetc3s|]}|jVqdS(N(tsplit(t.0telem(tsep(s:/usr/lib/python2.7/site-packages/passlib/tests/test_pwd.pys sN(RR!R"R#t itertoolstchaint from_iterable(RR%R&twordsR(RDtout((RDs:/usr/lib/python2.7/site-packages/passlib/tests/test_pwd.pyR)s  (cCsEt}|jt|jdd|jtdtdtdS(sgeneral behaviorR@is(?i)unexpected keyword.*badkwdR*N(R;RR!RAR+R,R"(RR-((s:/usr/lib/python2.7/site-packages/passlib/tests/test_pwd.pyR.s cCstdd}|jt|jddtdd}|jt|jddtdddd}|jt|jddtdddd }|jt|jddd S( s'length' & 'entropy' keywordstentropyiFR@iR8ii0ii N(R;RR!RA(RR-((s:/usr/lib/python2.7/site-packages/passlib/tests/test_pwd.pyt test_entropyscCstdddt}|j|dttdtdt}gtdD]}t|^qJ}|j|dt|jttdddS(s'returns' keywordR/iRHs invalid-typeN(R;t simple_wordsR)R0R1R2R3R,(RR%R4R5((s:/usr/lib/python2.7/site-packages/passlib/tests/test_pwd.pyR6s %cCs|tdtdd}|j|dttdddtdd}|j|dtdd |jttdtddd S( s'wordset' & 'words' optionsRHR/iR8iR(twordsettbip39Ni(R;RLR)R3R,(RR%((s:/usr/lib/python2.7/site-packages/passlib/tests/test_pwd.pyt test_wordsets ( RRRRR"R)R.RKR6RO(((s:/usr/lib/python2.7/site-packages/passlib/tests/test_pwd.pyR?s  (RREtloggingt getLoggerRtlogtpasslib.tests.utilsRt__all__RR RRRRRR;RLR?(((s:/usr/lib/python2.7/site-packages/passlib/tests/test_pwd.pyts   '  B