
    9[g                        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y)    )annotations)nodes)Cache)Config)Parser)Session)
TestReportzcache/stepwisec                    | j                  d      }|j                  dddddd       |j                  d	d
dddd       y )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)parsergroups     K/var/www/html/bid-api/venv/lib/python3.12/site-packages/_pytest/stepwise.pypytest_addoptionr      sZ    OOI&E	OOQ   
OO)      c                    | j                   j                  rd| j                   _        | j                  d      r&| j                  j                  t        |       d       y y )NTr   stepwiseplugin)optionr   r   	getoptionpluginmanagerregisterStepwisePlugin)configs    r   pytest_configurer"   #   sJ    }}""!%
#%%nV&<>NO $r   c                    | j                   j                  d      sZ| j                   j                  J t        | j                   d      ry | j                   j                  j	                  t
        g        y y )Nr   workerinput)r!   r   cachehasattrsetSTEPWISE_CACHE_DIRsessions    r   pytest_sessionfinishr+   +   s]    >>##J/~~##///7>>=1   !3R8 0r   c                  H    e Zd ZddZd	dZ	 	 	 	 	 	 d
dZddZddZddZy)r    c                    || _         d | _        d| _        |j                  J |j                  | _        | j                  j	                  t
        d       | _        |j                  d      | _        y )N r   )	r!   r*   report_statusr%   getr(   
lastfailedr   skip)selfr!   s     r   __init__zStepwisePlugin.__init__7   s\    '+||'''"LL
&*jjnn5G&N **?;	r   c                    || _         y )Nr)   )r3   r*   s     r   pytest_sessionstartz"StepwisePlugin.pytest_sessionstart@   s	    r   c                   | j                   sd| _        y d }t        |      D ]"  \  }}|j                  | j                   k(  s |} n |d| _        y d| d| _        |d | }|d |= |j                  j                  |       y )Nz)no previously failed tests, not skipping.z/previously failed test not found, not skipping.z	skipping z already passed items.)items)r1   r/   	enumeratenodeidhookpytest_deselected)r3   r!   r8   failed_indexindexitem
deselecteds          r   pytest_collection_modifyitemsz,StepwisePlugin.pytest_collection_modifyitemsC   s     !LD $U+KE4{{doo-$ , !RD#,\N:P!QD}-Jm|m$KK))
);r   c                H   |j                   re| j                  r(|j                  | j                  k(  rd | _        d| _        y |j                  | _        | j                  J d| j                  _        y |j                  dk(  r"|j                  | j                  k(  rd | _        y y y )NFz0Test failed, continuing from this test next run.call)failedr2   r:   r1   r*   
shouldstopwhen)r3   reports     r   pytest_runtest_logreportz'StepwisePlugin.pytest_runtest_logreport[   s    ==yy ==DOO3&*DO!	 #)--||///F ' {{f$==DOO3&*DO 4 %r   c                t    | j                   j                         dk\  r| j                  rd| j                   S y )Nr   z
stepwise: )r!   get_verbosityr/   r3   s    r   pytest_report_collectionfinishz-StepwisePlugin.pytest_report_collectionfinishs   s6    ;;$$&!+0B0B 2 2344r   c                    t        | j                  d      ry | j                  j                  t        | j
                         y )Nr$   )r&   r!   r%   r'   r(   r1   rK   s    r   r+   z#StepwisePlugin.pytest_sessionfinishx   s,    4;;. 

)4??;r   Nr!   r   returnNoner*   r   rO   rP   )r!   r   r8   zlist[nodes.Item]rO   rP   )rG   r	   rO   rP   )rO   z
str | None)rO   rP   )	__name__
__module____qualname__r4   r6   rA   rH   rL   r+    r   r   r    r    6   s8    <<<%5<	<0+0
<r   r    N)r   r   rO   rP   rN   rQ   )
__future__r   _pytestr   _pytest.cacheproviderr   _pytest.configr   _pytest.config.argparsingr   _pytest.mainr   _pytest.reportsr	   r(   r   r"   r+   r    rU   r   r   <module>r]      s>    "  ' ! ,   & & *P9G< G<r   