PK APOCALYPSE V1

APOCALYPSE V1

Current Path : /opt/hc_python/lib/python3.12/site-packages/nose/plugins/__pycache__/
Upload File :
Current File : //opt/hc_python/lib/python3.12/site-packages/nose/plugins/__pycache__/testid.cpython-312.pyc

�

���g�&���dZdZddlZddlZddlmZddlmZmZ	ddl	m
Z
mZeje�ZGd�de�Zy#e$rddl	m
Z
mZY�-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.
  
F�N)�Plugin)�src�set)�dump�loadc�^�eZdZdZdZdZdZdZd�Zd�Z	d�Z
dd	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zy)�TestIdz
    Activate to add a test id (like #1) to each test name output. Activate
    with --failed to rerun failing tests only.
    �idNTFc��tj|||�|jdddddd��|jdd	d
dd�
�y)z&Register commandline options.
        z	--id-file�store�
testIdFilez.noseids�FILEzfStore test ids found in test runs in this file. Default is the file .noseids in the working directory.)�action�dest�default�metavar�helpz--failed�
store_true�failedFz/Run the tests that failed in the last test run.)rrrrN)r�options�
add_option)�self�parser�envs   �B/opt/hc_python/lib/python3.12/site-packages/nose/plugins/testid.pyrzTestId.optionsxsZ��	���t�V�S�)����+�g�L�",�f� /�	�	0�
	���*�\�'�� &�	�	'�c�,�tj|||�|jr#d|_d|_t
j
d�tjj|j�|_tjj|j�s9tjj|j|j�|_d|_i|_i|_g|_g|_i|_|j(dk\|_y)zConfigure plugin.
        TzLooping on failed tests��N)r�	configurer�enabled�loopOnFailed�log�debug�os�path�
expanduserr
�idfile�isabs�join�
workingDirr
�ids�tests�source_names�_seen�	verbosity�
_write_hashes)rr�confs   rr zTestId.configure�s���	����w��-��>�>��D�L� $�D���I�I�/�0��g�g�(�(��);�);�<����w�w�}�}�T�[�[�)��'�'�,�,�t������D�D�K���������
���������
�!�^�^�q�0��rc��|j�rg|_|jratt	tt	|jj��t	|jj�����}n|j}t|jd�}t||j|jd�|�|j�tj!d||j|j�y)z&Save new ids file, if needed.
        �wb)r,rr.z#Saved test ids: %s, failed %s to %sN)�
wasSuccessfulr�
collecting�dict�list�zipr-�values�keysr,�openr(rr.�closer#r$)r�resultr,�fhs    r�finalizezTestId.finalize�s������!��D�K��?�?��t�C��T�Z�Z�%6�%6�%8� 9�4��
�
���@Q�;R�S�T�U�C��(�(�C�
�$�+�+�t�
$���S����"�/�/�1�24�	6�	���
��	�	�7��t�{�{�D�K�K�	1rc���tjd||�	t|jd�}t	|�}d|vr|d|_|d|_|d|_n||_g|_||_|j
r�t|j
�dz|_	tttt|j
j��t|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
|j�Y��xwxYwcc}
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 %s�rbr,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=�
ValueError�str�IOErrorr"r6�tr�appendr�extend)r�names�moduler?�data�e�
translated�
new_source�
really_new�name�trans�new_set�old_set�ss              r�loadTestsFromNameszTestId.loadTestsFromNames�ss��	�	�	�,��v�.�	:��d�k�k�4�(�B���8�D���}���;���"�8�n���$(��$8��!� ��� ���$)��!��x�x��d�h�h�-�!�+���!�$�s�4������0A�+B�D�������DY�'Z�"[�\��
�����I�I�J����$�*�*�d�k�k�4�3D�3D����
�
�H�H�J�������#�D�O��K�K�E��D�K��
��
��
��D��G�G�D�M�E���}��!�!�%�(��!�!�$�'����*�o�G��$�+�+�,�G��I�I�'��'�:�%/�/�Z��!"�g���Z�J�/���!�!�(�(��4��#��$�D�O��	�	�:��j�%�	1��j�:�-�6��7�7��W�	D�
�I�I�-�t�{�{�C��F�C�C���	:��I�I�+�T�[�[�9�	:��0/s$�EI4�
K �4	K�=*J-�-,K�Kc�p�tjd|�|\}}}|�t|�}n|}|�|�d|��S|S)NzMake name %s�:)r#r$r)r�addr�filenamerK�call�heads      r�makeNamezTestId.makeName�sF���	�	�.�$�'�!%���&�$����x�=�D��D���"�D�)�)��rc��||_y)zBGet handle on output stream so the plugin can print id #s
        N)�stream)rr_s  r�setOutputStreamzTestId.setOutputStreams����rc��|j�}tjd|||jv�||jvrQ||jvr|jd�y|jd|j|z�d|j|<y|j|j|<|jd|jz�|xjdz
c_y)z�Maybe 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
)r�test�adrs   r�	startTestzTestId.startTests����l�l�n���	�	�&��S�D�J�J�->�?��$�*�*���d�j�j� ��
�
�5�!�
��
�
�6�D�J�J�s�O�3�4�"#��
�
�3����'�'��
�
�3���
�
�6�D�G�G�#�$����1��rc���|jdurR	t|j|j��}||jvr|jj|�yyy#t$rYywxYw)NF)�passedrEr-rbrrH�KeyError)rrd�keys   r�	afterTestzTestId.afterTestsj���;�;�%��
,��$�*�*�T�\�\�^�4�5��
�d�k�k�)��K�K�&�&�s�+�*� ���
��
�s�&A"�"	A.�-A.c��tjd|�	t|jdd��}tjd|�||j
vr|j
|j
|�S|S#t$r|cYSwxYw)Nztr '%s'�#�z
Got key %s)r#r$�int�replacerDr,r])rrQrjs   rrGz	TestId.tr(sy���	�	�)�T�"�	��d�l�l�3��+�,�C�	�	�	�,��$��$�(�(�?��=�=����#��/�/�����	��K�	�s�A7�7B�Bc�T�|jr|jj|�yy�N)r1r_rc)r�outputs  rrczTestId.write5s"������K�K���f�%�rrr)�__name__�
__module__�__qualname__�__doc__rQr(r6r"rr r@rVr]r`rfrkrGrc�rrr	r	nsQ����D�
�F��J��L�'�1�.1�"F8�P	��
�,
,��&rr	)rw�__test__�loggingr%�nose.pluginsr�	nose.utilrr�picklerr�ImportError�	getLoggerrtr#r	rxrr�<module>r�s`��]�|���	���"�!��g����!��I&�V�I&��
�"�!�!�"�s�A�
A�A

if you don't want to be vaporized in a nuclear explosion, i simply have to become nuclear myself… i am atomic