g&dZdZddlZddlZddlmZddlmZmZ ddl m Z m Z ejeZGddeZy#e $r ddl m Z m Z Y-wxYw) a This plugin adds a test id (like #1) to each test name output. After you've run once to generate test ids, you can re-run individual tests by activating the plugin and passing the ids (with or without the # prefix) instead of test names. For example, if your normal test run looks like:: % nosetests -v tests.test_a ... ok tests.test_b ... ok tests.test_c ... ok When adding ``--with-id`` you'll see:: % nosetests -v --with-id #1 tests.test_a ... ok #2 tests.test_b ... ok #3 tests.test_c ... ok Then you can re-run individual tests by supplying just an id number:: % nosetests -v --with-id 2 #2 tests.test_b ... ok You can also pass multiple id numbers:: % nosetests -v --with-id 2 3 #2 tests.test_b ... ok #3 tests.test_c ... ok Since most shells consider '#' a special character, you can leave it out when specifying a test id. Note that when run without the -v switch, no special output is displayed, but the ids file is still written. Looping over failed tests ------------------------- This plugin also adds a mode that will direct the test runner to record failed tests. Subsequent test runs will then run only the tests that failed last time. Activate this mode with the ``--failed`` switch:: % nosetests -v --failed #1 test.test_a ... ok #2 test.test_b ... ERROR #3 test.test_c ... FAILED #4 test.test_d ... ok On the second run, only tests #2 and #3 will run:: % nosetests -v --failed #2 test.test_b ... ERROR #3 test.test_c ... FAILED As you correct errors and tests pass, they'll drop out of subsequent runs. First:: % nosetests -v --failed #2 test.test_b ... ok #3 test.test_c ... FAILED Second:: % nosetests -v --failed #3 test.test_c ... FAILED When all tests pass, the full set will run on the next invocation. First:: % nosetests -v --failed #3 test.test_c ... ok Second:: % nosetests -v --failed #1 test.test_a ... ok #2 test.test_b ... ok #3 test.test_c ... ok #4 test.test_d ... ok .. note :: If you expect to use ``--failed`` regularly, it's a good idea to always run using the ``--with-id`` option. This will ensure that an id file is always created, allowing you to add ``--failed`` to the command line as soon as you have failing tests. Otherwise, your first run using ``--failed`` will (perhaps surprisingly) run *all* tests, because there won't be an id file containing the record of failed tests from your previous run. FN)Plugin)srcset)dumploadc^eZdZdZdZdZdZdZdZdZ dZ dd Z d Z d Z d Zd ZdZdZy)TestIdz Activate to add a test id (like #1) to each test name output. Activate with --failed to rerun failing tests only. idNTFctj||||jdddddd|jdd d d d y)z&Register commandline options. z --id-filestore testIdFilez.noseidsFILEzfStore test ids found in test runs in this file. Default is the file .noseids in the working directory.)actiondestdefaultmetavarhelpz--failed store_truefailedFz/Run the tests that failed in the last test run.)rrrrN)roptions add_option)selfparserenvs B/opt/hc_python/lib/python3.12/site-packages/nose/plugins/testid.pyrzTestId.optionsxsZ tVS)+gL",f /  0 *\' &  'c,tj||||jr#d|_d|_t j dtjj|j|_ tjj|js9tjj|j|j|_ d|_i|_i|_g|_g|_i|_|j(dk\|_y)zConfigure plugin. TzLooping on failed testsN)r configurerenabled loopOnFailedlogdebugospath expanduserr idfileisabsjoin workingDirr idstests source_names_seen verbosity _write_hashes)rrconfs rr zTestId.configures w- >>DL $D  II/ 0gg((););< ww}}T[[)'',,t DDK   !^^q0rc |jrg|_|jratt t t |j jt |j j}n |j}t|jd}t||j|jd||jtj!d||j|jy)z&Save new ids file, if needed. wb)r,rr.z#Saved test ids: %s, failed %s to %sN) wasSuccessfulr collectingdictlistzipr-valueskeysr,openr(rr.closer#r$)rresultr,fhs rfinalizezTestId.finalizes    !DK ??tCTZZ%6%6%8 94 @Q;RSTUC((C $++t $ S "//124 6   7t{{DKK 1rc tjd|| t|jd}t |}d|vr|d|_|d|_|d|_n||_g|_||_|j rt|j dz|_ tttt|j jt|j j|_nd|_ tjd|j |j|j |j|j|j!|j(r&|j rd |_|j }g|_g}g}g}|D];} |j-| } | | k7r|j/| +|j/| =|rlt1|} t1|j} tjd | | |D cgc]} | | vr|  }} |r|jj3||s |}nd |_tjd |||d ||zxs|fS#t"$r5}tjd|jt%|Yd }~Id }~wt&$r$tjd |jYxwxYwcc} w)zTranslate ids in the list of requested names into their test addresses, if they are found in my dict of tests. z ltfn %s %srbr,rr.rz8Loaded test ids %s tests %s failed %s sources %s from %szError loading %s : %sNzIO error reading %sFzold: %s new: %sz&translated: %s new sources %s names %s)r#r$r<r(rr,rr.maxr r7r8r9r:r;r-r= ValueErrorstrIOErrorr"r6trappendrextend)rnamesmoduler?datae translated new_source really_newnametransnew_setold_setss rloadTestsFromNameszTestId.loadTestsFromNamesss ,v. :dkk4(B8D};"8n $($8!   $)!xxdhh-!+!$s40A+BDDY'Z"[\  IIJ$**dkk43D3D   HHJ   #DOKKEDK   DGGDME}!!%(!!$'  *oG$++,G II'' :%//Z!"gZJ/!!((4#$DO :j% 1j:-677W D II-t{{CF C C : II+T[[ 9 :0/s$E I4 K 4 K=*J--,KKcptjd||\}}}| t|}n|}||d|S|S)Nz Make name %s:)r#r$r)raddrfilenamerKcallheads rmakeNamezTestId.makeNamesF .$'!%&$  x=DD  "D) ) rc||_y)zBGet handle on output stream so the plugin can print id #s N)stream)rr_s rsetOutputStreamzTestId.setOutputStreams  rc|j}tjd|||jv||jvrQ||jvr|j dy|j d|j|zd|j|<y|j |j|<|j d|j z|xj dz c_y)zMaybe output an id # before the test name. Example output:: #1 test.test ... ok #2 test.test_two ... ok zstart test %s (%s)z z#%s rN)addressr#r$r-r/writer )rtestadrs r startTestzTestId.startTestslln &SDJJ->? $** djj  5!  6DJJsO34"# 3 '' 3 6DGG#$ 1 rc|jdurR t|j|j}||jvr|jj |yyy#t $rYywxYw)NF)passedrEr-rbrrHKeyError)rrdkeys r afterTestzTestId.afterTestsj ;;%  ,$**T\\^45 dkk)KK&&s+*   s&A"" A.-A.ctjd| t|jdd}tjd|||j vr|j |j |S|S#t$r|cYSwxYw)Nztr '%s'#z Got key %s)r#r$intreplacerDr,r])rrQrjs rrGz TestId.tr(sy )T" dll3+,C ,$ $((?==#/ /  K sA77 BBcT|jr|jj|yyN)r1r_rc)routputs rrcz TestId.write5s"    KK  f % rrr)__name__ __module__ __qualname____doc__rQr(r6r"rr r@rVr]r`rfrkrGrcrrr r nsQ D FJL '1.1"F8P  , , &rr )rw__test__loggingr% nose.pluginsr nose.utilrrpicklerr ImportError getLoggerrtr#r rxrrrs`]|  "!g!I&VI& "!!"sA AA