
    [j4                       d 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dl	mZ dd	l	mZ dd
l	mZ ddlZddlZ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 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dl(m*Z* ddl(m+Z+ ddl,m-Z- ddl.m/Z/ ddl.m0Z0 dd l.m1Z1 dd!l2m3Z3 erdd"l4m5Z5 dMd'Z6 ej7        d(d(d()           G d* d+                      Z8 ej7        d,-           G d. d/e-                      Z9e&dNd3            Z: G d4 d2          Z;ej7         G d5 d6                      Z<edOd8            Z=edPd:            Z>ej7         G d; d<                      Z?ej7         G d= d>                      Z@dQdBZAdRdFZB e3eeCeDf                              ZEdSdIZF e d(J          dTdL            ZGdS )Uz*Builtin plugin that adds subtests support.    )annotations)defaultdict)Callable)Iterator)Mapping)AbstractContextManager)contextmanager)	ExitStack)nullcontextN)TracebackType)Any)TYPE_CHECKING)ExceptionInfosaferepr)CaptureFixture)	FDCapture)
SysCapture)Config)hookimpl)Parser)check_ispytest)fixture)
SubRequest)catching_logs)LogCaptureHandler)LoggingPlugin)
TestReport)CallInfo)check_interactive_exception)get_reraise_exceptions)StashKey)Selfparserr   returnNonec                H    t          j        | t           j        d           d S )NzSpecify verbosity level for subtests. Higher levels will generate output for passed subtests. Failed subtests are always reported.)help)r   _add_verbosity_iniVERBOSITY_SUBTESTS)r$   s    T/var/www/app.qaans.com/backend/venv/lib/python3.11/site-packages/_pytest/subtests.pypytest_addoptionr,   .   s5    
!k	         T)frozenslotskw_onlyc                  P    e Zd ZU dZded<   ded<   ddZdd
Zedd            ZdS )SubtestContextzJThe values passed to Subtests.test() that are included in the test report.
str | NonemsgzMapping[str, Any]kwargsr%   r&   c                    t                               | dd | j                                        D                        d S )Nr5   c                4    i | ]\  }}|t          |          S  r   .0kvs      r+   
<dictcomp>z0SubtestContext.__post_init__.<locals>.<dictcomp>C   s$    NNNAQNNNr-   )object__setattr__r5   items)selfs    r+   __post_init__zSubtestContext.__post_init__@   sH    (NN$+:K:K:M:MNNN	
 	
 	
 	
 	
r-   dict[str, Any]c                .    t          j        |           }|S N)dataclassesasdict)rA   results     r+   _to_jsonzSubtestContext._to_jsonF   s    #D))r-   dr#   c                4     | |d         |d                   S )Nr4   r5   r4   r5   r8   )clsrJ   s     r+   
_from_jsonzSubtestContext._from_jsonJ   s    sqx(4444r-   Nr%   r&   r%   rC   )rJ   rC   r%   r#   )	__name__
__module____qualname____doc____annotations__rB   rI   classmethodrN   r8   r-   r+   r2   r2   9   sy         TTOOO
 
 
 
    5 5 5 [5 5 5r-   r2   F)initc                       e Zd ZU ded<   edd            ZddZd fdZed fd
            Z	ed fd            Z
 xZS )SubtestReportr2   contextr%   strc                J    | j         \  }}}| d|                                  S )N )location_sub_test_description)rA   _domains      r+   	head_linezSubtestReport.head_lineS   s/    }1f9945577999r-   c                R   g }| j         j        #|                    d| j         j         d           | j         j        rTd                    d | j         j                                        D                       }|                    d| d           d                    |          pdS )	N[]z, c              3  *   K   | ]\  }}| d | V  dS )=Nr8   r9   s      r+   	<genexpr>z6SubtestReport._sub_test_description.<locals>.<genexpr>]   sA       $ $%11

q

$ $ $ $ $ $r-   ()r]   z(<subtest>))rZ   r4   appendr5   joinr@   )rA   partsparams_descs      r+   r_   z#SubtestReport._sub_test_descriptionX   s    <'LL0T\-000111< 	-)) $ $)-)<)B)B)D)D$ $ $  K LL+[+++,,,xx/-/r-   rC   c                    t                                                      }|d= d|d<   | j                                        |d<   |S )NrZ   SubTestReport_report_type_subtest.context)superrI   rZ   )rA   data	__class__s     r+   rI   zSubtestReport._to_jsonc   sG    ww!!O.^#'<#8#8#:#: r-   
reportdictc                    t                                          |          }t                              |d                   |_        |S )Nrr   )rs   rN   r2   rZ   )rM   rv   reportru   s      r+   rN   zSubtestReport._from_jsonj   s:    ##J//'22:>P3QRRr-   test_reportr   captured_outputCaptured | Nonecaptured_logsCapturedLogs | Noner#   c                   t                                          |                                          }||_        |rP|j        r!|j                            d|j        f           |j        r!|j                            d|j        f           |r<|j        j	        
                                x}r|j                            d|f           |S )NzCaptured stdout callzCaptured stderr callzCaptured log call)rs   rN   rI   rZ   outsectionsrk   errhandlerstreamgetvalue)rM   ry   rZ   rz   r|   rH   logru   s          r+   _newzSubtestReport._newp   s     ##K$8$8$:$:;;  	V" V&&(>@S'TUUU" V&&(>@S'TUUU 	?]%:%A%J%J%L%LLc 	?O""$7#=>>>r-   )r%   r[   rP   )rv   rC   r%   rY   )
ry   r   rZ   r2   rz   r{   r|   r}   r%   r#   )rQ   rR   rS   rU   propertyrb   r_   rI   rV   rN   r   __classcell__)ru   s   @r+   rY   rY   O   s         : : : X:	0 	0 	0 	0           [
      [    r-   rY   requestr   Subtestsc                    | j         j        j                            d          }||j        nt
          }t          | j         j        || d          S )z Provides subtests functionality.capturemanagerNT	_ispytest)nodeconfigpluginmanager
get_pluginglobal_and_fixture_disabledr   r   ihook)r   capmamsuspend_capture_ctxs      r+   subtestsr      sU     \ .99:JKKF.4.@**k  GL&(;WPTUUUUr-   c                  ,    e Zd ZdZddddZ	 dddZdS )r   z_Subtests fixture, enables declaring subtests inside test functions via the :meth:`test` method.Fr   r   pluggy.HookRelayr   *Callable[[], AbstractContextManager[None]]r   r   r   boolr%   r&   c               N    t          |           || _        || _        || _        d S rE   )r   _ihook_suspend_capture_ctx_request)rA   r   r   r   r   s        r+   __init__zSubtests.__init__   s,     	y!!!$7!r-   Nr4   r3   r5   r   _SubTestContextManagerc                ^    t          | j        ||| j        | j        | j        j                  S )ad  
        Context manager for subtests, capturing exceptions raised inside the subtest scope and
        reporting assertion failures and errors individually.

        Usage
        -----

        .. code-block:: python

            def test(subtests):
                for i in range(5):
                    with subtests.test("custom message", i=i):
                        assert i % 2 == 0

        :param msg:
            If given, the message will be shown in the test report in case of subtest failure.

        :param kwargs:
            Arbitrary values that are also added to the subtest report.
        )r   r   r   )r   r   r   r   r   )rA   r4   r5   s      r+   testzSubtests.test   s9    2 &KM $ 9='
 
 
 	
r-   )
r   r   r   r   r   r   r   r   r%   r&   rE   )r4   r3   r5   r   r%   r   )rQ   rR   rS   rT   r   r   r8   r-   r+   r   r      s[        ii               
  
  
  
  
  
  
r-   c                  `    e Zd ZU dZded<   ded<   ded<   ded	<   d
ed<   ded<   ddZddZdS )r   z
    Context manager for subtests, capturing exceptions raised inside the subtest scope and handling
    them through the pytest machinery.
    r   r   r3   r4   rC   r5   r   r   r   r   r   r   r%   r&   c                b   d}t          j                     | _        t          j                    | _        d | _        t                      | _        | j                            t          | j	                            | _
        | j                            t          | j	                            | _        d S )NT)time_startperf_counter_precise_start	_exc_infor
   _exit_stackenter_contextcapturing_outputr   _captured_outputcapturing_logs_captured_logs)rA   __tracebackhide__s     r+   	__enter__z _SubTestContextManager.__enter__   s     ikk"/11$;; $ 0 > >T\**!
 !
 #.<<4<((
 
r-   exc_typetype[BaseException] | Noneexc_valBaseException | Noneexc_tbTracebackType | Noner   c           	        d}|t          j        |          }nd }| j                                         t	          j                    }|| j        z
  }t	          j                    }t          d          d || j        ||dd          }	| j	        
                    | j        j        |	          }
t                              |
t          | j        | j                  | j        | j                  }|j        r6| j        j        t.                   }|| j        j        j        xx         dz  cc<   |                                 5  | j	                            |           d d d            n# 1 swxY w Y   t7          |	|          r'| j	                            | j        j        |	|	           |7t;          |t=          | j                            rd
S | j        j        j         rd
S dS )NTcall)startstopdurationwhenr   )itemr   rL   )rz   r|      rx   )r   r   rx   F)!r   from_exceptionr   closer   r   r   r   r   r   pytest_runtest_makereportr   r   rY   r   r2   r4   r5   r   r   failedr   stashfailed_subtests_keynodeidr   pytest_runtest_logreportr    pytest_exception_interact
isinstancer!   session
shouldfail)rA   r   r   r   r   exc_infoprecise_stopr   r   	call_inforx   
sub_reportfailed_subtestss                r+   __exit__z_SubTestContextManager.__exit__   sM    !$3G<<HHH   (**$"55y{{TN+
 
 
	 55" 6 
 
 #''tx<<< 1-	 ( 
 

  	;"k/0CDODL-4555:555%%'' 	C 	CJ//z/BBB	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 'y*== 	J00\&Yz 1    '#9$+#F#FGG u|#. uts   >E&&E*-E*NrO   )r   r   r   r   r   r   r%   r   )rQ   rR   rS   rT   rU   r   r   r8   r-   r+   r   r      s           OOOCCCCNNN
 
 
 
6 6 6 6 6 6r-   r   Iterator[Captured]c              #  <  K   | j                             dd           }| j         j                            d          }t	          |dd           rd }n>|dk    rt          t          | d          }n |dk    rt          t          | d          }nd }| |j                     t                      }	 |V  |1 |j
                    \  }} |j                     ||_        ||_        d S d S # |/ |j
                    \  }} |j                     ||_        ||_        w xY w)Ncapturer   _capture_fixturesysTr   fd)r   	getoptionr   	getplugingetattrr   r   r   r   Captured
readouterrr   r   r   )r   optioncapmanr   capturedr   r   s          r+   r   r     sD     ^%%i66F^)334DEEFv)400 	5 WEEE	4 GtDDDzzH)w)++HCGMOOOHLHLLL	 7)w)++HCGMOOOHLHLs   /C( (3DIterator[CapturedLogs | None]c              #  ,  K   | j         j                            d          }|d V  d S t                      }|                    |j                   t          |          }t          ||j                  5  |V  d d d            d S # 1 swxY w Y   d S )Nzlogging-plugin)level)	r   r   r   r   setFormatter	formatterCapturedLogsr   	log_level)r   logging_pluginr   r|   s       r+   r   r   <  s       ,3>+G+Q+Q, ,N 




#%%^5666$W--7.*BCCC 	  	 	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 s   7B		BBc                  ,    e Zd ZU dZded<   dZded<   dS )r    r[   r   r   N)rQ   rR   rS   r   rU   r   r8   r-   r+   r   r   N  s*         CMMMMCMMMMMMr-   r   c                      e Zd ZU ded<   dS )r   r   r   N)rQ   rR   rS   rU   r8   r-   r+   r   r   T  s         r-   r   rx   r   dict[str, Any] | Nonec                X    t          | t                    r|                                 S d S rE   )r   rY   rI   r   s    r+   pytest_report_to_serializabler   Y  s)    &-(( !   4r-   rt   rC   SubtestReport | Nonec                l    |                      d          dk    rt                              |           S d S )Nrq   rp   )getrY   rN   )rt   s    r+   pytest_report_from_serializabler   _  s2    xx?22''---4r-   r   r   c                H    t          t                    | j        t          <   d S rE   )r   intr   r   )r   s    r+   pytest_configurer   j  s    (3C(8(8FL$%%%r-   )tryfirst0tuple[str, str, str | Mapping[str, bool]] | Nonec                    | j         dk    rd S |                    t          j                  dk    }t	          | t
                    r| j        }|                                 }t          | d          r|rdS |dk    rd}d}d}nd S ||| | fS | j	        r|d	d
| fS | j
        r|rdS d| d	d| fS | j        r|rdS |dd| fS nH|j        t                   | j                 }| j
        r$|dk    rd| _        |dk    rdnd}	d| d|	 | _        d S )Nr   r   wasxfail)r   r   r   skippedxfailedySUBXFAILu	SUBFAILEDz	subtests 	SUBPASSED-
SUBSKIPPEDr   r   sr   z	contains z failed subtest)r   get_verbosityr   r*   r   rY   outcomer_   hasattrr   passedr   r   r   r   longrepr)
rx   r   quietr  descriptioncategoryshortstatusfailed_subtests_countsuffixs
             r+   pytest_report_teststatusr  n  s   
 {ft  !:;;q@E&-(( )Y.22446:&& 	= !zI%%$# tUv$<{$<$<<<= 	DC!:[!:!:::} 	D Q%:0w00#7P;7P7PPP D D%:"C)Ck)C)CCC	D !'-@ A&- P= 	Y2Q66%FN1A55SS2FX*?XXPVXXFO4r-   )r$   r   r%   r&   )r   r   r%   r   )r   r   r%   r   )r   r   r%   r   )rx   r   r%   r   )rt   rC   r%   r   )r   r   r%   r&   )rx   r   r   r   r%   r   )HrT   
__future__r   collectionsr   collections.abcr   r   r   
contextlibr   r	   r
   r   rF   r   typesr   typingr   r   pluggy_pytest._coder   _pytest._io.safereprr   _pytest.capturer   r   r   _pytest.configr   r   _pytest.config.argparsingr   _pytest.deprecatedr   _pytest.fixturesr   r   _pytest.loggingr   r   r   _pytest.reportsr   _pytest.runnerr   r    r!   _pytest.stashr"   typing_extensionsr#   r,   	dataclassr2   rY   r   r   r   r   r   r   r   r   r   r[   r   r   r   r  r8   r-   r+   <module>r&     s   0 0 " " " " " " # # # # # # $ $ $ $ $ $ $ $ $ $ $ $ # # # # # # - - - - - - % % % % % %             " " " " " "                               ' ' ' ' ' ' ) ) ) ) ) ) * * * * * * % % % % % % & & & & & & ! ! ! ! ! ! # # # # # # , , , , , , - - - - - - $ $ $ $ $ $ ' ' ' ' ' ' ) ) ) ) ) ) - - - - - - ) ) ) ) ) ) & & & & & & # # # # # # 6 6 6 6 6 6 1 1 1 1 1 1 " " " " " "  '&&&&&&    d$===5 5 5 5 5 5 5 >=5* E"""4 4 4 4 4J 4 4 #"4n 	V V V 	V0
 0
 0
 0
 0
 0
 0
 0
f W W W W W W W Wt    8        "        
               6h{384577 9 9 9 9 
43 3 3 3 3 3r-   