
    	hj                         d dl mZ d dl mZ d dl mZ d dl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 erd d
lmZ dZde
ddfdZej        deddfd            ZdeddfdZ G d d          ZdS )    )List)Optional)TYPE_CHECKINGN)nodes)Config)Parser)Session)
TestReport)Cachezcache/stepwiseparserreturnc                     |                      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     ]/var/www/html/web-builder-api.evdpl.com/venv/lib/python3.11/site-packages/_pytest/stepwise.pypytest_addoptionr      s{    OOI&&E	OOQ     
OO)          configc                     | 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   sessionc                     | 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.   0   sr    >##J// 9~#///7>=11 	 F  !3R888889 9r   c                       e Zd ZdeddfdZdeddfdZdedeej	                 ddfdZ
d	eddfd
Zdee         fdZddZdS )r$   r   r   Nc                     || _         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__<   s`    *.|'''"L
)-8JD)Q)Q **?;;			r   r&   c                     || _         d S )Nr-   )r6   r&   s     r   pytest_sessionstartz"StepwisePlugin.pytest_sessionstartE   s    r   itemsc                     | 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.)r:   )r4   r2   	enumeratenodeidhookpytest_deselected)r6   r   r:   failed_indexindexitem
deselecteds          r   pytest_collection_modifyitemsz,StepwisePlugin.pytest_collection_modifyitemsH   s      	!LDF $U++ 	 	KE4{do--$ . !RD!Q\!Q!Q!QD}}-Jm|m$K))
);;;;;r   reportc                     |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)failedr5   r=   r4   r&   
shouldstopwhen)r6   rE   s     r   pytest_runtest_logreportz'StepwisePlugin.pytest_runtest_logreport`   s    = 	+y  =DO33&*DO!			 #)-|///F ''' {f$$=DO33&*DOOO %$33r   c                 d    | j                             d          dk    r| j        r
d| j         S d S )Nverboser   z
stepwise: )r   r!   r2   r6   s    r   pytest_report_collectionfinishz-StepwisePlugin.pytest_report_collectionfinishx   s;    ;  ++q00T5G04 2444tr   c                 ~    t          | j        d          rd S | j                            t          | j                   d S )Nr(   )r*   r   r)   r+   r,   r4   rN   s    r   r.   z#StepwisePlugin.pytest_sessionfinish}   s<    4;.. 	 F
)4?;;;;;r   )r   N)__name__
__module____qualname__r   r7   r	   r9   r   r   ItemrD   r
   rK   r   strrO   r.    r   r   r$   r$   ;   s        <v <$ < < < <7 t    <<%)%*%5<	< < < <0+z +d + + + +0    
< < < < < <r   r$   )typingr   r   r   pytest_pytestr   _pytest.configr   _pytest.config.argparsingr   _pytest.mainr	   _pytest.reportsr
   _pytest.cacheproviderr   r,   r   hookimplr%   r.   r$   rV   r   r   <module>r`      st                                  ! ! ! ! ! ! , , , , , ,             & & & & & & ,++++++% V     * PV P P P P P9' 9d 9 9 9 9G< G< G< G< G< G< G< G< G< G<r   