• File: testid.cpython-37.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/opt/alt/python37/lib/python3.7/site-packages/nose/plugins/__pycache__/testid.cpython-37.pyc
  • Date Modified: 07/07/2021 11:30 PM
  • File size: 7.74 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit
B

9`&@sdZdZddlZddlZddlmZddlmZmZyddl	m
Z
mZWn$ek
rlddl	m
Z
mZYnXe
eZGdddeZdS)	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@sreZdZdZdZdZdZdZddZdd	Z	d
dZ
ddd
ZddZddZ
ddZddZddZddZdS)TestIdz
    Activate to add a test id (like #1) to each test name output. Activate
    with --failed to rerun failing tests only.
    idNTFcCs<t||||jddddddd|jdd	d
ddd
dS)z&Register commandline options.
        z	--id-fileZstore
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.)rrr
rN)roptionsZ
add_option)selfparserenvrD/opt/alt/python37/lib/python3.7/site-packages/nose/plugins/testid.pyrxs
zTestId.optionscCst||||jr*d|_d|_tdtj	|j
|_tj|js\tj
|j|j|_d|_i|_i|_g|_g|_i|_|jdk|_dS)zConfigure plugin.
        TzLooping on failed testsN)r	configurerZenabledloopOnFailedlogdebugospath
expanduserr	idfileisabsjoinZ
workingDirridstestssource_names_seen	verbosity
_write_hashes)rrZconfrrrrs
zTestId.configurecCs|rg|_|jr<tttt|jt|j}n|j	}t
|jd}t||j|j
d||td||j|jdS)z&Save new ids file, if needed.
        wb)r$rr&z#Saved test ids: %s, failed %s to %sN)Z
wasSuccessfulr
collectingdictlistzipr%valueskeysr$openr!rr&closerr)rresultr$fhrrrfinalizes(zTestId.finalizec
std||yt|jd}t|}d|krL|d|_|d|_|d|_n||_g|_||_|jrt|jd|_	t
ttt|j
t|j|_nd|_	td|j|j|j|j|j|WnZtk
r}ztd|jt|Wd	d	}~XYn$tk
r&td
|jYnX|jrJ|jrJd|_|j}g|_g}g}g}x8|D]0}	||	}
|
|	kr||
n
||	q\W|rt|}t|jtd|fd
d|D}|r|j||s|}nd|_td|||d	||p
|fS)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: %scsg|]}|kr|qSrr).0s)old_setrr
<listcomp>sz-TestId.loadTestsFromNames.<locals>.<listcomp>z&translated: %s new sources %s names %s)rrr1r!rr$rr&maxrr,r-r.r/r0r%r2
ValueErrorstrIOErrorrr+trappendrextend)rnamesmoduler4dataeZ
translatedZ
new_sourceZ
really_newnameZtransZnew_setr)r9rloadTestsFromNamessb

*$




zTestId.loadTestsFromNamescCsDtd||\}}}|dk	r(t|}n|}|dk	r@d||fS|S)NzMake name %sz%s:%s)rrr)rZaddrfilenamerCZcallheadrrrmakeNames

zTestId.makeNamecCs
||_dS)zBGet handle on output stream so the plugin can print id #s
        N)stream)rrKrrrsetOutputStreamszTestId.setOutputStreamcCs|}td|||jk||jkr^||jkr<|dn|d|j|d|j|<dS|j|j|<|d|j|jd7_dS)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)addressrrr%r'writer)rtestZadrrrr	startTests	


zTestId.startTestcCsP|jdkrLyt|j|}Wntk
r4YnX||jkrL|j|dS)NF)Zpassedr=r%rMKeyErrorrr@)rrOkeyrrr	afterTests

zTestId.afterTestcCs`td|yt|dd}Wntk
r4|SXtd|||jkr\||j|S|S)Nztr '%s'#z
Got key %s)rrintreplacer<r$rJ)rrFrRrrrr?(s
z	TestId.trcCs|jr|j|dS)N)r)rKrN)routputrrrrN5szTestId.write)N)__name__
__module____qualname____doc__rFr!r+rrrr5rGrJrLrPrSr?rNrrrrrns
H
r)r\Z__test__ZloggingrZnose.pluginsrZ	nose.utilrrpicklerrImportErrorZ	getLoggerrYrrrrrr<module>^s