
    pj                        d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZ dZddZddZddZ G d d          ZdS )    )annotations)nodes)Cache)Config)Parser)Session)
TestReportzcache/stepwiseparserr   returnNonec                    |                      d          }|                    dddddd           |                    d	d
dddd           d S )Ngeneralz--swz
--stepwise
store_trueFstepwisezBExit on test failure and continue from last failing test next time)actiondefaultdesthelpz	--sw-skipz--stepwise-skipstepwise_skipz_Ignore the first failing test but stop on the next failing test. Implicitly enables --stepwise.)getgroup	addoption)r
   groups     `/lsinfo/ai/hellotax_ai/data_center/backend/venv/lib/python3.11/site-packages/_pytest/stepwise.pypytest_addoptionr      s{    OOI&&E	OOQ     
OO)          configr   c                    | j         j        rd| j         _        |                     d          r*| j                            t          |           d           d S d S )NTr   stepwiseplugin)optionr   r   	getoptionpluginmanagerregisterStepwisePlugin)r   s    r   pytest_configurer$   #   sd    }" &!%
## P%%nV&<&<>NOOOOOP Pr   sessionr   c                    | j                             d          sL| j         j        J t          | j         d          rd S | j         j                            t
          g            d S d S )Nr   workerinput)r   r    cachehasattrsetSTEPWISE_CACHE_DIRr%   s    r   pytest_sessionfinishr-   +   sr    >##J// 9~#///7>=11 	 F  !3R888889 9r   c                  >    e Zd ZddZddZddZddZddZddZdS )r#   r   r   r   r   c                    || _         d | _        d| _        |j        J |j        | _        | j                            t
          d           | _        |                    d          | _        d S )N r   )	r   r%   report_statusr(   getr+   
lastfailedr    skip)selfr   s     r   __init__zStepwisePlugin.__init__7   s`    '+|'''"L
&*jnn5G&N&N **?;;			r   r%   r   c                    || _         d S )Nr,   )r5   r%   s     r   pytest_sessionstartz"StepwisePlugin.pytest_sessionstart@   s    r   itemslist[nodes.Item]c                    | j         s	d| _        d S d }t          |          D ]\  }}|j        | j         k    r|} n|	d| _        d S d| d| _        |d |         }|d |= |j                            |           d S )Nz)no previously failed tests, not skipping.z/previously failed test not found, not skipping.z	skipping z already passed items.)r9   )r3   r1   	enumeratenodeidhookpytest_deselected)r5   r   r9   failed_indexindexitem
deselecteds          r   pytest_collection_modifyitemsz,StepwisePlugin.pytest_collection_modifyitemsC   s      	!LDF $U++ 	 	KE4{do--$ . !RD!Q\!Q!Q!QD}}-Jm|m$K))
);;;;;r   reportr	   c                    |j         rJ| j        r |j        | j        k    rd | _        d| _        d S |j        | _        | j        J d| j        _        d S |j        dk    r|j        | j        k    rd | _        d S d S d S )NFz0Test failed, continuing from this test next run.call)failedr4   r=   r3   r%   
shouldstopwhen)r5   rE   s     r   pytest_runtest_logreportz'StepwisePlugin.pytest_runtest_logreport[   s    = 	+y  =DO33&*DO!			 #)-|///F ''' {f$$=DO33&*DOOO %$33r   
str | Nonec                b    | j                                         dk    r| j        r
d| j         S d S )Nr   z
stepwise: )r   get_verbosityr1   r5   s    r   pytest_report_collectionfinishz-StepwisePlugin.pytest_report_collectionfinishs   s9    ;$$&&!++0B+4 2444tr   c                ~    t          | j        d          rd S | j                            t          | j                   d S )Nr'   )r)   r   r(   r*   r+   r3   rO   s    r   r-   z#StepwisePlugin.pytest_sessionfinishx   s<    4;.. 	 F
)4?;;;;;r   Nr   r   r   r   r%   r   r   r   )r   r   r9   r:   r   r   )rE   r	   r   r   )r   rL   )r   r   )	__name__
__module____qualname__r6   r8   rD   rK   rP   r-    r   r   r#   r#   6   s        < < < <   < < < <0+ + + +0   
< < < < < <r   r#   N)r
   r   r   r   rR   rS   )
__future__r   _pytestr   _pytest.cacheproviderr   _pytest.configr   _pytest.config.argparsingr   _pytest.mainr   _pytest.reportsr	   r+   r   r$   r-   r#   rW   r   r   <module>r_      s   " " " " " "       ' ' ' ' ' ' ! ! ! ! ! ! , , , , , ,             & & & & & & &    *P P P P9 9 9 9G< G< G< G< G< G< G< G< G< G<r   